From 3cb1bec905206a38888bda22a340e39d0d10a8f5 Mon Sep 17 00:00:00 2001 From: Amar Zavery Date: Fri, 20 May 2016 20:02:16 -0700 Subject: [PATCH] interactive login in the node runtime (ms-rest-azure) (#1066) * inital commit * minor update * some more updates --- .../Azure.NodeJS/AzureNodeJSCodeGenerator.cs | 2 +- .../NodeJS/NodeJS/NodeJSCodeGenerator.cs | 2 +- ClientRuntimes/NodeJS/ms-rest-azure/README.md | 36 +++- .../NodeJS/ms-rest-azure/lib/constants.js | 8 +- .../applicationTokenCredentials.js | 25 +-- .../lib/credentials/deviceTokenCredentials.js | 93 +++++++++ .../lib/credentials/userTokenCredentials.js | 50 +++-- .../NodeJS/ms-rest-azure/lib/login.js | 187 ++++++++++++++++++ .../NodeJS/ms-rest-azure/lib/msRestAzure.js | 5 +- .../NodeJS/ms-rest-azure/package.json | 6 +- .../test/azureServiceClientTests.js | 2 +- ClientRuntimes/NodeJS/ms-rest/README.md | 2 +- .../NodeJS/ms-rest/lib/constants.js | 4 +- ClientRuntimes/NodeJS/ms-rest/package.json | 2 +- 14 files changed, 370 insertions(+), 54 deletions(-) create mode 100644 ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/deviceTokenCredentials.js create mode 100644 ClientRuntimes/NodeJS/ms-rest-azure/lib/login.js diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS/AzureNodeJSCodeGenerator.cs b/AutoRest/Generators/NodeJS/Azure.NodeJS/AzureNodeJSCodeGenerator.cs index e68eb4727a6dc..b69f65ab8247a 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS/AzureNodeJSCodeGenerator.cs +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS/AzureNodeJSCodeGenerator.cs @@ -18,7 +18,7 @@ namespace Microsoft.Rest.Generator.Azure.NodeJS { public class AzureNodeJSCodeGenerator : NodeJSCodeGenerator { - private const string ClientRuntimePackage = "ms-rest-azure version 1.13.1"; + private const string ClientRuntimePackage = "ms-rest-azure version 1.14.0"; // List of models with paging extensions. private IList pageModels; diff --git a/AutoRest/Generators/NodeJS/NodeJS/NodeJSCodeGenerator.cs b/AutoRest/Generators/NodeJS/NodeJS/NodeJSCodeGenerator.cs index 2e59314d876df..98d40be85a514 100644 --- a/AutoRest/Generators/NodeJS/NodeJS/NodeJSCodeGenerator.cs +++ b/AutoRest/Generators/NodeJS/NodeJS/NodeJSCodeGenerator.cs @@ -16,7 +16,7 @@ namespace Microsoft.Rest.Generator.NodeJS { public class NodeJSCodeGenerator : CodeGenerator { - private const string ClientRuntimePackage = "ms-rest version 1.13.1"; + private const string ClientRuntimePackage = "ms-rest version 1.14.0"; public NodeJsCodeNamer Namer { get; private set; } diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/README.md b/ClientRuntimes/NodeJS/ms-rest-azure/README.md index fa4dfef78d951..fcb28f9478d83 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/README.md +++ b/ClientRuntimes/NodeJS/ms-rest-azure/README.md @@ -2,7 +2,7 @@ Infrastructure for error handling, tracing, and http client pipeline configuration. Required by nodeJS Azure client libraries, generated using AutoRest. -- **Node.js version: 0.10.0 or higher** +- **Node.js version: 4.x.x or higher** ## How to Install @@ -17,14 +17,40 @@ var msrestAzure = require('ms-rest-azure'); ``` ## Authentication +#### Interactive Login is the simplest and the best way to authenticate. +It provides a url and code that needs to be copied and pasted in a browser and authenticated over there. If successful, +the user will get a DeviceTokenCredentials object. +```javascript + var someAzureServiceClient = require('azure-arm-someService'); + msRestAzure.interactiveLogin(function(err, credentials) { + var client = new someAzureServiceClient(credentials, 'your-subscriptionId'); + client.someOperationGroup.method(param1, param2, function(err, result) { + if (err) console.log(err); + console.log(result); + }); + }); +``` + +#### Login with username and password +This mechanism will only work for organizational ids and ids that are not 2FA enabled. +Otherwise it is better to use the above mechanism (interactive login). +```javascript + var someAzureServiceClient = require('azure-arm-someService'); + msRestAzure.loginWithUsernamePassword(username, password, function(err, credentials) { + var client = new someAzureServiceClient(credentials, 'your-subscriptionId'); + client.someOperationGroup.method(param1, param2, function(err, result) { + if (err) console.log(err); + console.log(result); + }); + }); +``` + +### ServicePrincipal authentication ```javascript - //user authentication - var credentials = new msRestAzure.UserTokenCredentials('your-client-id', 'your-domain', 'your-username', 'your-password', 'your-redirect-uri'); - //service principal authentication var credentials = new msRestAzure.ApplicationTokenCredentials('your-client-id', 'your-domain', 'your-secret'); ``` ### Non-Interactive Authentication -If you need to create an automation account for non interactive or scripting scenarios then please take a look at the documentation over [here](https://github.com/Azure/azure-sdk-for-node/blob/autorest/Documentation/Authentication.md). +If you need to create an automation account for non interactive or scripting scenarios then please take a look at the documentation over [here](https://github.com/Azure/azure-sdk-for-node/blob/master/Documentation/Authentication.md). ## Related Projects diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/constants.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/constants.js index 1341dc4f10365..c2badda1e264e 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/constants.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/constants.js @@ -14,7 +14,13 @@ var Constants = { Succeeded: 'Succeeded', Failed: 'Failed', Canceled: 'Canceled' - } + }, + + DEFAULT_ADAL_CLIENT_ID: '04b07795-8ddb-461a-bbee-02f9e1bf7b46', + + AAD_COMMON_TENANT: 'common', + + DEFAULT_LANGUAGE: 'en-us' }; exports = module.exports = Constants; diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/applicationTokenCredentials.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/applicationTokenCredentials.js index e096edbff2049..9a7885a932c9b 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/applicationTokenCredentials.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/applicationTokenCredentials.js @@ -19,7 +19,7 @@ var AzureEnvironment = require('../azureEnvironment'); * @param {object} [options] Object representing optional parameters. * @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. * @param {string} [options.authorizationScheme] The authorization scheme. Default value is 'bearer'. -* @param {object} [options.tokenCache] The token cache. Default value is null. +* @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. */ function ApplicationTokenCredentials(clientId, domain, secret, options) { if (!Boolean(clientId) || typeof clientId.valueOf() !== 'string') { @@ -39,21 +39,25 @@ function ApplicationTokenCredentials(clientId, domain, secret, options) { } if (!options.environment) { - this.environment = AzureEnvironment.Azure; - } else { - this.environment = options.environment; + options.environment = AzureEnvironment.Azure; } if (!options.authorizationScheme) { - this.authorizationScheme = 'Bearer'; - } else { - this.authorizationScheme = options.authorizationScheme; + options.authorizationScheme = Constants.HeaderConstants.AUTHORIZATION_SCHEME; } - + + if (!options.tokenCache) { + options.tokenCache = new adal.MemoryCache(); + } + + this.environment = options.environment; + this.authorizationScheme = options.authorizationScheme; this.tokenCache = options.tokenCache; this.clientId = clientId; this.domain = domain; this.secret = secret; + var authorityUrl = this.environment.activeDirectoryEndpointUrl + this.domain; + this.context = new adal.AuthenticationContext(authorityUrl, this.environment.validateAuthority, this.tokenCache); } /** @@ -65,10 +69,7 @@ function ApplicationTokenCredentials(clientId, domain, secret, options) { */ ApplicationTokenCredentials.prototype.signRequest = function (webResource, callback) { var self = this; - var authorityUrl = self.environment.activeDirectoryEndpointUrl + self.domain; - var context = new adal.AuthenticationContext(authorityUrl, self.environment.validateAuthority, self.tokenCache); - - context.acquireTokenWithClientCredentials(self.environment.activeDirectoryResourceId, self.clientId, self.secret, function (err, result) { + self.context.acquireTokenWithClientCredentials(self.environment.activeDirectoryResourceId, self.clientId, self.secret, function (err, result) { if (err) { return callback(new Error('Failed to acquire token for application. \n' + err)); } diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/deviceTokenCredentials.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/deviceTokenCredentials.js new file mode 100644 index 0000000000000..48cb16802acb3 --- /dev/null +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/deviceTokenCredentials.js @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +var util = require('util'); +var msrest = require('ms-rest'); +var adal = require('adal-node'); +var Constants = msrest.Constants; + +var azureConstants = require('../constants'); +var AzureEnvironment = require('../azureEnvironment'); + +/** +* Creates a new DeviceTokenCredentials object that gets a new access token using userCodeInfo (contains user_code, device_code) +* for authenticating user on device. +* +* When this credential is used, the script will provide a url and code. The user needs to copy the url and the code, paste it +* in a browser and authenticate over there. If successful, the script will get the access token. +* +* @constructor +* @param {object} [options] Object representing optional parameters. +* @param {string} [options.username] The user name for account in the form: 'user@example.com'. +* @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.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. +* @param {string} [options.authorizationScheme] The authorization scheme. Default value is 'bearer'. +* @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. +*/ +function DeviceTokenCredentials(options) { + if (!options) { + options = {}; + } + + if (!options.username) { + options.username = 'user@example.com'; + } + + if (!options.environment) { + options.environment = AzureEnvironment.Azure; + } + + if (!options.domain) { + options.domain = azureConstants.AAD_COMMON_TENANT; + } + + if (!options.clientId) { + options.clientId = azureConstants.DEFAULT_ADAL_CLIENT_ID; + } + + if (!options.authorizationScheme) { + options.authorizationScheme = Constants.HeaderConstants.AUTHORIZATION_SCHEME; + } + + if (!options.tokenCache) { + options.tokenCache = new adal.MemoryCache(); + } + + this.username = options.username; + this.environment = options.environment; + this.domain = options.domain; + this.clientId = options.clientId; + this.authorizationScheme = options.authorizationScheme; + this.tokenCache = options.tokenCache; + var authorityUrl = this.environment.activeDirectoryEndpointUrl + this.domain; + this.context = new adal.AuthenticationContext(authorityUrl, this.environment.validateAuthority, this.tokenCache); +} + +DeviceTokenCredentials.prototype.retrieveTokenFromCache = function (callback) { + var self = this; + self.context.acquireToken(self.environment.activeDirectoryResourceId, self.username, self.clientId, function (err, result) { + if (err) return callback(err); + return callback(null, result.tokenType, result.accessToken); + }); +}; + + +/** +* Signs a request with the Authentication header. +* +* @param {webResource} The WebResource to be signed. +* @param {function(error)} callback The callback function. +* @return {undefined} +*/ +DeviceTokenCredentials.prototype.signRequest = function (webResource, callback) { + return this.retrieveTokenFromCache(function(err, scheme, token) { + if (err) return callback(err); + webResource.headers[Constants.HeaderConstants.AUTHORIZATION] = util.format('%s %s', scheme, token); + return callback(null); + }); +}; + +module.exports = DeviceTokenCredentials; \ No newline at end of file diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/userTokenCredentials.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/userTokenCredentials.js index 7b4f02cf720bf..19eed7559a8df 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/userTokenCredentials.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/userTokenCredentials.js @@ -18,13 +18,12 @@ var AzureEnvironment = require('../azureEnvironment'); * @param {string} domain The domain or tenant id containing this application. * @param {string} username The user name for the Organization Id account. * @param {string} password The password for the Organization Id account. -* @param {string} clientRedirectUri The Uri where the user will be redirected after authenticating with AD. * @param {object} [options] Object representing optional parameters. * @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. * @param {string} [options.authorizationScheme] The authorization scheme. Default value is 'bearer'. -* @param {object} [options.tokenCache] The token cache. Default value is null. +* @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. */ -function UserTokenCredentials(clientId, domain, username, password, clientRedirectUri, options) { +function UserTokenCredentials(clientId, domain, username, password, options) { if (!Boolean(clientId) || typeof clientId.valueOf() !== 'string') { throw new Error('clientId must be a non empty string.'); } @@ -40,35 +39,42 @@ function UserTokenCredentials(clientId, domain, username, password, clientRedire if (!Boolean(password) || typeof password.valueOf() !== 'string') { throw new Error('password must be a non empty string.'); } - - if (!Boolean(clientRedirectUri) || typeof clientRedirectUri.valueOf() !== 'string') { - throw new Error('clientRedirectUri cannot be null.'); - } if (!options) { options = {}; } if (!options.environment) { - this.environment = AzureEnvironment.Azure; - } else { - this.environment = options.environment; + options.environment = AzureEnvironment.Azure; } if (!options.authorizationScheme) { - this.authorizationScheme = 'Bearer'; - } else { - this.authorizationScheme = options.authorizationScheme; + options.authorizationScheme = Constants.HeaderConstants.AUTHORIZATION_SCHEME; + } + + if (!options.tokenCache) { + options.tokenCache = new adal.MemoryCache(); } + this.environment = options.environment; + this.authorizationScheme = options.authorizationScheme; this.tokenCache = options.tokenCache; this.clientId = clientId; this.domain = domain; this.username = username; this.password = password; - this.clientRedirectUri = clientRedirectUri; + var authorityUrl = this.environment.activeDirectoryEndpointUrl + this.domain; + this.context = new adal.AuthenticationContext(authorityUrl, this.environment.validateAuthority, this.tokenCache); } +UserTokenCredentials.prototype.retrieveTokenFromCache = function (callback) { + var self = this; + self.context.acquireToken(self.environment.activeDirectoryResourceId, self.username, self.clientId, function (err, result) { + if (err) return callback(err); + return callback(null, result.tokenType, result.accessToken); + }); +}; + /** * Signs a request with the Authentication header. * @@ -77,18 +83,10 @@ function UserTokenCredentials(clientId, domain, username, password, clientRedire * @return {undefined} */ UserTokenCredentials.prototype.signRequest = function (webResource, callback) { - var self = this; - var authorityUrl = self.environment.activeDirectoryEndpointUrl + self.domain; - var context = new adal.AuthenticationContext(authorityUrl, self.environment.validateAuthority, self.tokenCache); - - context.acquireTokenWithUsernamePassword(self.environment.activeDirectoryResourceId, self.username, self.password, self.clientId, function (err, result) { - if (err) { - return callback(new Error('Failed to acquire token. \n' + err)); - } - - webResource.headers[Constants.HeaderConstants.AUTHORIZATION] = - util.format('%s %s', self.authorizationScheme, result.accessToken); - callback(null); + return this.retrieveTokenFromCache(function(err, scheme, token) { + if (err) return callback(err); + webResource.headers[Constants.HeaderConstants.AUTHORIZATION] = util.format('%s %s', scheme, token); + return callback(null); }); }; diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/login.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/login.js new file mode 100644 index 0000000000000..1bcd458631679 --- /dev/null +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/login.js @@ -0,0 +1,187 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +var adal= require('adal-node'); +var async = require('async'); +var msrest = require('ms-rest'); +var Constants = msrest.Constants; + +var azureConstants = require('./constants'); +var UserTokenCredentials = require('./credentials/userTokenCredentials'); +var DeviceTokenCredentials = require('./credentials/deviceTokenCredentials'); +var AzureEnvironment = require('./azureEnvironment'); + +function _createDeviceCredentials(tokenResponse) { + var options = {}; + options.environment = this.environment; + options.domain = this.domain; + options.clientId = this.clientId; + options.tokenCache = this.tokenCache; + options.username = tokenResponse.userId; + options.authorizationScheme = tokenResponse.tokenType; + var credentials = new DeviceTokenCredentials(options); + return credentials; +} + +function _createUserCredentials(tokenResponse) { + var options = {}; + options.environment = this.environment; + options.tokenCache = this.tokenCache; + options.authorizationScheme = tokenResponse.tokenType; + var credentials = new UserTokenCredentials(this.clientId, this.domain, tokenResponse.userId, this.password, options); + return credentials; +} + +/** + * Provides a url and code that needs to be copy and pasted in a browser and authenticated over there. If successful, the user will get a + * DeviceTokenCredentials object + * + * @param {object} [options] Object representing optional parameters. + * + * @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. + * + * @param {string} [options.domain] The domain or tenant id containing this application. Default value is 'common' + * + * @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. Default environment is "Public Azure". + * + * @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. + * + * @param {object} [options.language] The language code specifying how the message should be localized to. Default value 'en-us'. + * + * @param {function} callback The language code specifying how the message should be localized to. Default value 'en-us'. + * + * @returns {function} callback(err, credentials) + * + * {Error} [err] - The Error object if an error occurred, null otherwise. + * + * {DeviceTokenCredentials} [credentials] - The DeviceTokenCredentials object + */ +exports.interactive = function interactive(options, callback) { + if(!callback && typeof options === 'function') { + callback = options; + options = {}; + } + + if (!options.environment) { + options.environment = AzureEnvironment.Azure; + } + + if (!options.domain) { + options.domain = azureConstants.AAD_COMMON_TENANT; + } + + if (!options.clientId) { + options.clientId = azureConstants.DEFAULT_ADAL_CLIENT_ID; + } + + if (!options.tokenCache) { + options.tokenCache = new adal.MemoryCache(); + } + + if (!options.language) { + options.language = azureConstants.DEFAULT_LANGUAGE; + } + + this.environment = options.environment; + this.domain = options.domain; + this.clientId = options.clientId; + this.tokenCache = options.tokenCache; + this.language = options.language; + var authorityUrl = this.environment.activeDirectoryEndpointUrl + this.domain; + this.context = new adal.AuthenticationContext(authorityUrl, this.environment.validateAuthority, this.tokenCache); + var self = this; + async.waterfall([ + function (callback) { + self.context.acquireUserCode(self.environment.activeDirectoryResourceId, self.clientId, self.language, function (err, userCodeResponse) { + if (err) return callback(err); + console.log(userCodeResponse.message); + return callback(null, userCodeResponse); + }); + }, + function (userCodeResponse, callback) { + self.context.acquireTokenWithDeviceCode(self.environment.activeDirectoryResourceId, self.clientId, userCodeResponse, function (err, tokenResponse) { + if (err) return callback(err); + return callback(null, tokenResponse); + }); + } + ], function(err, tokenResponse) { + if (err) return callback(err); + return callback(null, _createDeviceCredentials.call(self, tokenResponse)); + }); +}; + +/** +* Provides a UserTokenCredentials object if successful. +* +* @param {string} username The user name for the Organization Id account. +* @param {string} password The password for the Organization Id account. +* @param {object} [options] Object representing optional parameters. +* @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. +* @param {string} [options.domain] The domain or tenant id containing this application. Default value 'common'. +* @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. +* @param {string} [options.authorizationScheme] The authorization scheme. Default value is 'bearer'. +* @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. +* @param {function} callback The language code specifying how the message should be localized to. Default value 'en-us'. +* +* @returns {function} callback(err, credentials) +* +* {Error} [err] - The Error object if an error occurred, null otherwise. +* +* {UserTokenCredentials} [credentials] - The UserTokenCredentials object +*/ +exports.withUsernamePassword = function withUsernamePassword(username, password, options, callback) { + if(!callback && typeof options === 'function') { + callback = options; + options = {}; + } + + if (!Boolean(username) || typeof username.valueOf() !== 'string') { + throw new Error('username must be a non empty string.'); + } + + if (!Boolean(password) || typeof password.valueOf() !== 'string') { + throw new Error('password must be a non empty string.'); + } + + if (!options.domain) { + options.domain = azureConstants.AAD_COMMON_TENANT; + } + + if (!options.clientId) { + options.clientId = azureConstants.DEFAULT_ADAL_CLIENT_ID; + } + + if (!options.environment) { + options.environment = AzureEnvironment.Azure; + } + + if (!options.authorizationScheme) { + options.authorizationScheme = Constants.HeaderConstants.AUTHORIZATION_SCHEME; + } + + if (!options.tokenCache) { + options.tokenCache = new adal.MemoryCache(); + } + + this.environment = options.environment; + this.authorizationScheme = options.authorizationScheme; + this.tokenCache = options.tokenCache; + this.domain = options.domain; + this.clientId = options.clientId; + this.username = username; + this.password = password; + var authorityUrl = this.environment.activeDirectoryEndpointUrl + this.domain; + this.context = new adal.AuthenticationContext(authorityUrl, this.environment.validateAuthority, this.tokenCache); + var self = this; + self.context.acquireTokenWithUsernamePassword(self.environment.activeDirectoryResourceId, self.username, + self.password, self.clientId, function (err, tokenResponse) { + if (err) return callback(new Error('Failed to acquire token. \n' + err)); + return callback(null, _createUserCredentials.call(self, tokenResponse)); + }); +}; + +exports = module.exports; \ No newline at end of file diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/msRestAzure.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/msRestAzure.js index ff592098b3ec8..aec8292d060b5 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/msRestAzure.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/msRestAzure.js @@ -5,10 +5,13 @@ exports.AzureServiceClient = require('./azureServiceClient'); exports.UserTokenCredentials = require('./credentials/userTokenCredentials'); exports.ApplicationTokenCredentials = require('./credentials/applicationTokenCredentials'); +exports.DeviceTokenCredentials = require('./credentials/deviceTokenCredentials'); exports.AzureEnvironment = require('./azureEnvironment'); exports.BaseResource = require('./baseResource'); exports.CloudError = require('./cloudError'); exports.TokenCredentials = require('ms-rest').TokenCredentials; -exports.generateUuid = require('./utils').generateUuid; +exports.generateUuid = require('./utils').generateUuid; +exports.interactiveLogin = require('./login').interactive; +exports.loginWithUsernamePassword = require('./login').withUsernamePassword; exports = module.exports; \ No newline at end of file diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/package.json b/ClientRuntimes/NodeJS/ms-rest-azure/package.json index cd4e61c7c9655..3e196bf039e69 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/package.json +++ b/ClientRuntimes/NodeJS/ms-rest-azure/package.json @@ -5,7 +5,7 @@ "email": "azsdkteam@microsoft.com", "url": "https://github.com/Azure/AutoRest" }, - "version": "1.13.1", + "version": "1.14.0", "description": "Client Runtime for Node.js Azure client libraries generated using AutoRest", "tags": [ "node", "microsoft", "autorest", "azure", "clientruntime" ], "keywords": [ "node", "microsoft", "autorest", "azure", "clientruntime" ], @@ -17,8 +17,8 @@ "dependencies": { "async": "0.2.7", "uuid": "2.0.1", - "adal-node": "0.1.17", - "ms-rest": "^1.13.1", + "adal-node": "^0.1.17", + "ms-rest": "^1.14.0", "moment": "^2.6.0" }, "devDependencies": { diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js b/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js index 8e11e689690b7..b9e71b6134694 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js @@ -10,7 +10,7 @@ var AzureServiceClient = require('../lib/azureServiceClient'); var LroStates = require('../lib/constants').LongRunningOperationStates; var msRest = require('ms-rest'); var UserTokenCredentials = require('../lib/credentials/userTokenCredentials'); -var credentials = new UserTokenCredentials('clientId', 'domain', 'username', 'password', 'clientredirecturi'); +var credentials = new UserTokenCredentials('clientId', 'domain', 'username', 'password'); describe('AzureServiceClient', function () { describe('Constructor intialization', function () { diff --git a/ClientRuntimes/NodeJS/ms-rest/README.md b/ClientRuntimes/NodeJS/ms-rest/README.md index 1da52bff1ac92..cf74c263c7df3 100644 --- a/ClientRuntimes/NodeJS/ms-rest/README.md +++ b/ClientRuntimes/NodeJS/ms-rest/README.md @@ -2,7 +2,7 @@ Infrastructure for serialization/deserialization, error handling, tracing, and http client pipeline configuration. Required by nodeJS client libraries generated using AutoRest. -- **Node.js version: 0.10.0 or higher** +- **Node.js version: 4.x.x or higher** ## How to Install diff --git a/ClientRuntimes/NodeJS/ms-rest/lib/constants.js b/ClientRuntimes/NodeJS/ms-rest/lib/constants.js index 42722e9342ccf..fa8a3137306b1 100644 --- a/ClientRuntimes/NodeJS/ms-rest/lib/constants.js +++ b/ClientRuntimes/NodeJS/ms-rest/lib/constants.js @@ -62,7 +62,9 @@ var Constants = { * @const * @type {string} */ - AUTHORIZATION: 'authorization' + AUTHORIZATION: 'authorization', + + AUTHORIZATION_SCHEME: 'Bearer' } }; diff --git a/ClientRuntimes/NodeJS/ms-rest/package.json b/ClientRuntimes/NodeJS/ms-rest/package.json index 656299783e9f9..8dabfaf0e6a6a 100644 --- a/ClientRuntimes/NodeJS/ms-rest/package.json +++ b/ClientRuntimes/NodeJS/ms-rest/package.json @@ -5,7 +5,7 @@ "email": "azsdkteam@microsoft.com", "url": "https://github.com/Azure/AutoRest" }, - "version": "1.13.1", + "version": "1.14.0", "description": "Client Runtime for Node.js client libraries generated using AutoRest", "tags": ["node", "microsoft", "autorest", "clientruntime"], "keywords": ["node", "microsoft", "autorest", "clientruntime"],