forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node clientruntime updates (Azure#1244)
* remove stale token from tokencache for sp auth as adal does not remove it. * more improvements * jshint fixes * application token creds update * update version * auth updates to node azure clientruntime * fix to make nodejs tests work for 6.x as well as 4.x
- Loading branch information
1 parent
aaf8fd1
commit 7045fdb
Showing
13 changed files
with
533 additions
and
466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ var AzureEnvironment = require('../azureEnvironment'); | |
* @param {string} [options.username] The user name for account in the form: '[email protected]'. | ||
* @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. Default environment is "Azure" popularly known as "Public Azure Cloud". | ||
* @param {string} [options.domain] The domain or tenant id containing this application. Default value is 'common' | ||
* @param {string} [options.tokenAudience] The audience for which the token is requested. Valid value is 'graph'. If tokenAudience is provided | ||
* then domain should also be provided and its value should not be the default 'common' tenant. It must be a string (preferrably in a guid format). | ||
* @param {string} [options.clientId] The active directory application client id. | ||
* See {@link https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/ Active Directory Quickstart for .Net} | ||
* for an example. | ||
|
@@ -55,7 +57,18 @@ function DeviceTokenCredentials(options) { | |
if (!options.tokenCache) { | ||
options.tokenCache = new adal.MemoryCache(); | ||
} | ||
|
||
|
||
if (options.tokenAudience) { | ||
if (options.tokenAudience.toLowerCase() !== 'graph') { | ||
throw new Error('Valid value for \'tokenAudience\' is \'graph\'.'); | ||
} | ||
if (options.domain.toLowerCase() === 'common') { | ||
throw new Error('If the tokenAudience is specified as \'graph\' then \'domain\' cannot be the default \'commmon\' tenant. ' + | ||
'It must be the actual tenant (preferrably a string in a guid format).'); | ||
} | ||
} | ||
|
||
this.tokenAudience = options.tokenAudience; | ||
this.username = options.username; | ||
this.environment = options.environment; | ||
this.domain = options.domain; | ||
|
@@ -68,7 +81,9 @@ function DeviceTokenCredentials(options) { | |
|
||
DeviceTokenCredentials.prototype.retrieveTokenFromCache = function (callback) { | ||
var self = this; | ||
self.context.acquireToken(self.environment.activeDirectoryResourceId, self.username, self.clientId, function (err, result) { | ||
var resource = self.environment.activeDirectoryResourceId; | ||
if (self.tokenAudience && self.tokenAudience.toLowerCase() === 'graph') resource = self.environment.activeDirectoryGraphResourceId; | ||
self.context.acquireToken(resource, self.username, self.clientId, function (err, result) { | ||
if (err) return callback(err); | ||
return callback(null, result.tokenType, result.accessToken); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"email": "[email protected]", | ||
"url": "https://github.com/Azure/AutoRest" | ||
}, | ||
"version": "1.14.4", | ||
"version": "1.14.5", | ||
"description": "Client Runtime for Node.js Azure client libraries generated using AutoRest", | ||
"tags": [ "node", "microsoft", "autorest", "azure", "clientruntime" ], | ||
"keywords": [ "node", "microsoft", "autorest", "azure", "clientruntime" ], | ||
|
@@ -15,7 +15,7 @@ | |
"async": "0.2.7", | ||
"uuid": "2.0.1", | ||
"adal-node": "^0.1.17", | ||
"ms-rest": "^1.14.3", | ||
"ms-rest": "^1.14.4", | ||
"moment": "^2.6.0", | ||
"azure-arm-resource": "^1.4.4-preview" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"email": "[email protected]", | ||
"url": "https://github.com/Azure/AutoRest" | ||
}, | ||
"version": "1.14.3", | ||
"version": "1.14.4", | ||
"description": "Client Runtime for Node.js client libraries generated using AutoRest", | ||
"tags": ["node", "microsoft", "autorest", "clientruntime"], | ||
"keywords": ["node", "microsoft", "autorest", "clientruntime"], | ||
|
@@ -15,10 +15,10 @@ | |
"dependencies": { | ||
"underscore": "^1.4.0", | ||
"tunnel": "~0.0.2", | ||
"request": "2.69.0", | ||
"request": "2.72.0", | ||
"duplexer": "~0.1.1", | ||
"through": "~2.3.4", | ||
"moment": "^2.9.0" | ||
"moment": "^2.14.1" | ||
}, | ||
"devDependencies": { | ||
"jshint": "2.6.3", | ||
|
Oops, something went wrong.