Dynamic Token Per Domain
- 16 Nov 2022
-
DarkLight
-
PDF
Dynamic Token Per Domain
- Updated on 16 Nov 2022
-
DarkLight
-
PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Scenario
This system has authentication on a per domain basis. This means you must authenticate within the domain you are retrieving/updating information in.
This information is Dynamic per request, so the information needs to be provided through the reqObj made on every call. This is done by adding the authData object with the contents you wish to add to the body of the authentication request.
This requires a code change because you need additional data passed down to the adapter, and that data needs to be added to the request object passed down to the adapter library. It does not require any additional coding in the adapter library; the adapter library is prepared to handle this type of action.
Changes to the adapter.js
File:
- You will need to make changes to allow for the Domain to be passed into the adapter methods.
- Adding a parameter to every method in the adapter.js.
- Add this Domain into the authData on the request object in the adapter.js.
adapter.js Example
getMyData(query, domainVar, callback) {
....
const reqObj = {
payload: { garbage: 'need since post' },
uriPathVars: [groupId, deviceId],
uriQuery: { name: 'anyname' },
uriOptions: { page: 2 },
addlHeaders: { audit: 'turnOn' },
authData: {
domain: domainVar
},
callProperties: {
stub: true,
request: {
attempt_timeout: 60000
}
},
filter: '[*name=doggie]'
};
Changes to the pronghorn.json
File:
- You will need to make changes to allow for the Domain to be passed into the adapter methods.
- Adding the input into every method defined in the pronghorn.json file.
pronghorn.json Method Example
{
"name": "getMyData",
"summary": "get my data from blah",
"description": "get my data from blah",
"input": [
{
"name": "query",
"type": "object",
"info": "object containing query fields",
"required": false,
"schema": {
"title": "query",
"type": "object"
}
},
{
"name": "domainVar",
"type": "string",
"info": "the domain to send for authentication",
"required": true,
"schema": {
"title": "domainVar",
"type": "string"
}
}
],
"output": {
"name": "result",
"type": "object",
"description": "A JSON Object containing status, code and the result"
},
"route": {
"verb": "POST",
"path": "/getMyData"
},
"roles": [
"admin"
],
"task": true
},
Was this article helpful?