Minor cleanup on connection request authentication code.

This commit is contained in:
Zaid Abdulla committed 2013-09-12 08:56:12 +03:00
1 parent 3c7f554264
commit a8ee773a39
2 files changed
+8 -6

No files matched your search

+5 -4
View File
@@ -9,11 +9,12 @@ auth = require './auth'
connectionRequest = (deviceId, callback) -> connectionRequest = (deviceId, callback) ->
conReq = (url, authString, callback) -> conReq = (url, authString, callback) ->
if authString options = URL.parse(url)
url = URL.parse(url)
url.headers = {'Authorization' : authString}
request = http.get(url, (res) -> if authString
options.headers = {'Authorization' : authString}
request = http.get(options, (res) ->
if res.statusCode == 401 if res.statusCode == 401
authHeader = auth.parseAuthHeader(res.headers['www-authenticate']) authHeader = auth.parseAuthHeader(res.headers['www-authenticate'])
callback(res.statusCode, authHeader) callback(res.statusCode, authHeader)
+3 -2
View File
@@ -54,8 +54,9 @@ exports.digest = (username, password, uri, httpMethod, body, authHeader) ->
authString += ",realm=\"#{authHeader.realm}\"" authString += ",realm=\"#{authHeader.realm}\""
authString += ",nonce=\"#{authHeader.nonce}\"" authString += ",nonce=\"#{authHeader.nonce}\""
authString += ",uri=\"#{uri}\"" authString += ",uri=\"#{uri}\""
authString += ",qop=\"#{qop}\"" authString += ",algorithm=#{authHeader.algorithm}" if authHeader.algorithm?
authString += ",nc=\"#{nc}\"" authString += ",qop=#{qop}"
authString += ",nc=#{nc}"
authString += ",cnonce=\"#{cnonce}\"" authString += ",cnonce=\"#{cnonce}\""
authString += ",response=\"#{response}\"" authString += ",response=\"#{response}\""
authString += ",opaque=\"#{authHeader.opaque}\"" authString += ",opaque=\"#{authHeader.opaque}\""