Read connection request creds from parameters
This commit is contained in:
1 parent
33b01d68ca
commit
3e4f4b29ab
2 files changed
+13
-2
No files matched your search
@@ -92,7 +92,11 @@ connectionRequest = (deviceId, callback) ->
|
|||||||
|
|
||||||
proj = {
|
proj = {
|
||||||
'Device.ManagementServer.ConnectionRequestURL._value' : 1,
|
'Device.ManagementServer.ConnectionRequestURL._value' : 1,
|
||||||
'InternetGatewayDevice.ManagementServer.ConnectionRequestURL._value' : 1
|
'Device.ManagementServer.ConnectionRequestUsername._value',
|
||||||
|
'Device.ManagementServer.ConnectionRequestPassword._value',
|
||||||
|
'InternetGatewayDevice.ManagementServer.ConnectionRequestURL._value' : 1,
|
||||||
|
'InternetGatewayDevice.ManagementServer.ConnectionRequestUsername._value',
|
||||||
|
'InternetGatewayDevice.ManagementServer.ConnectionRequestPassword._value'
|
||||||
}
|
}
|
||||||
|
|
||||||
db.devicesCollection.findOne({_id : deviceId}, proj, (err, device)->
|
db.devicesCollection.findOne({_id : deviceId}, proj, (err, device)->
|
||||||
@@ -102,14 +106,20 @@ connectionRequest = (deviceId, callback) ->
|
|||||||
|
|
||||||
if device.Device? # TR-181 data model
|
if device.Device? # TR-181 data model
|
||||||
connectionRequestUrl = device.Device.ManagementServer.ConnectionRequestURL._value
|
connectionRequestUrl = device.Device.ManagementServer.ConnectionRequestURL._value
|
||||||
|
username = device.Device.ManagementServer.ConnectionRequestUsername?._value
|
||||||
|
password = device.Device.ManagementServer.ConnectionRequestPassword?._value
|
||||||
else # TR-098 data model
|
else # TR-098 data model
|
||||||
connectionRequestUrl = device.InternetGatewayDevice.ManagementServer.ConnectionRequestURL._value
|
connectionRequestUrl = device.InternetGatewayDevice.ManagementServer.ConnectionRequestURL._value
|
||||||
|
username = device.InternetGatewayDevice.ManagementServer.ConnectionRequestUsername?._value
|
||||||
|
password = device.InternetGatewayDevice.ManagementServer.ConnectionRequestPassword?._value
|
||||||
|
|
||||||
# for testing
|
# for testing
|
||||||
#connectionRequestUrl = connectionRequestUrl.replace(/^(http:\/\/)([0-9\.]+)(\:[0-9]+\/[a-zA-Z0-9]+\/?$)/, '$110.1.1.254$3')
|
#connectionRequestUrl = connectionRequestUrl.replace(/^(http:\/\/)([0-9\.]+)(\:[0-9]+\/[a-zA-Z0-9]+\/?$)/, '$110.1.1.254$3')
|
||||||
conReq(connectionRequestUrl, null, (statusCode, authHeader) ->
|
conReq(connectionRequestUrl, null, (statusCode, authHeader) ->
|
||||||
if statusCode == 401
|
if statusCode == 401
|
||||||
|
if not (username and password) and config.auth?.connectionRequest
|
||||||
[username, password] = config.auth.connectionRequest(deviceId)
|
[username, password] = config.auth.connectionRequest(deviceId)
|
||||||
|
|
||||||
if authHeader.method is 'Basic'
|
if authHeader.method is 'Basic'
|
||||||
authString = auth.basic(username, password)
|
authString = auth.basic(username, password)
|
||||||
else if authHeader.method is 'Digest'
|
else if authHeader.method is 'Digest'
|
||||||
|
|||||||
+2
-1
@@ -160,7 +160,8 @@ get = (option, deviceId) ->
|
|||||||
|
|
||||||
|
|
||||||
# load authentication scripts
|
# load authentication scripts
|
||||||
exports.auth = require(path.resolve(allConfig.CONFIG_DIR, 'auth'))
|
try
|
||||||
|
exports.auth = require(path.resolve(allConfig.CONFIG_DIR, 'auth'))
|
||||||
|
|
||||||
exports.get = get
|
exports.get = get
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user