Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #174 from AzureAD/dev
Browse files Browse the repository at this point in the history
Release 1.0.23
  • Loading branch information
lovemaths authored Oct 26, 2017
2 parents 96c582c + 2ef72bc commit c3f0840
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 20 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
The ADAL for node.js library makes it easy for node.js applications to authenticate to AAD in order to access AAD protected web resources. It supports 3 authentication modes shown in the quickstart code below.

## Versions
Current version - 0.1.22
Current version - 0.1.23
Minimum recommended version - 0.1.22
You can find the changes for each version in the [change log](https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/master/changelog.txt).

## Samples and Documentation

[We provide a full suite of sample applications and documentation on GitHub](https://github.com/AzureADSamples) to help you get started with learning the Azure Identity system. This includes tutorials for native clients such as Windows, Windows Phone, iOS, OSX, Android, and Linux. We also provide full walkthroughs for authentication flows such as OAuth2, OpenID Connect, Graph API, and other awesome features.
[We provide a full suite of sample applications and documentation on GitHub](https://github.com/azure-samples?q=active-directory) to help you get started with learning the Azure Identity system. This includes tutorials for native clients such as Windows, Windows Phone, iOS, OSX, Android, and Linux. We also provide full walkthroughs for authentication flows such as OAuth2, OpenID Connect, Graph API, and other awesome features.

## Community Help and Support

Expand Down Expand Up @@ -106,15 +106,15 @@ See the [client credentials sample](https://github.com/MSOpenTech/azure-activedi
var adal = require('adal-node').AuthenticationContext;

var authorityHostUrl = 'https://login.windows.net';
var tenant = 'myTenant';
var tenant = 'myTenant.onmicrosoft.com'; // AAD Tenant name.
var authorityUrl = authorityHostUrl + '/' + tenant;
var clientId = 'yourClientIdHere';
var clientSecret = 'yourAADIssuedClientSecretHere'
var resource = '00000002-0000-0000-c000-000000000000';
var applicationId = 'yourApplicationIdHere'; // Application Id of app registered under AAD.
var clientSecret = 'yourAADIssuedClientSecretHere'; // Secret generated for app. Read this environment variable.
var resource = '00000002-0000-0000-c000-000000000000'; // URI that identifies the resource for which the token is valid.

var context = new AuthenticationContext(authorityUrl);

context.acquireTokenWithClientCredentials(resource, clientId, clientSecret, function(err, tokenResponse) {
context.acquireTokenWithClientCredentials(resource, applicationId, clientSecret, function(err, tokenResponse) {
if (err) {
console.log('well that didn\'t work: ' + err.stack);
} else {
Expand Down
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Version 0.1.23
--------------
Release Date: 26 Oct 2017
* Fix Issue #95 - Change npm licenses to license and use spdx syntax
* Fix Issue #122 - Broken link on README file
* Fix Issue #155 - remove need for dynamic access to package.json to obtain lib version (util.js)
* Fix Issue #172 - Add login.microsoftonline.us endpoint
* Added Windows Graph Sample

Version 0.1.22
--------------
Release Date: 1 Aug 2016
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var Constants = {

AADConstants : {
WORLD_WIDE_AUTHORITY : 'login.windows.net',
WELL_KNOWN_AUTHORITY_HOSTS : ['login.windows.net', 'login.microsoftonline.com', 'login.chinacloudapi.cn', 'login-us.microsoftonline.com', 'login.microsoftonline.de'],
WELL_KNOWN_AUTHORITY_HOSTS : ['login.windows.net', 'login.microsoftonline.com', 'login.chinacloudapi.cn', 'login-us.microsoftonline.com', 'login.microsoftonline.de', 'login.microsoftonline.us'],
INSTANCE_DISCOVERY_ENDPOINT_TEMPLATE : 'https://{authorize_host}/common/discovery/instance?authorization_endpoint={authorize_endpoint}&api-version=1.0',
AUTHORIZE_ENDPOINT_PATH : '/oauth2/authorize',
TOKEN_ENDPOINT_PATH : '/oauth2/token',
Expand Down
5 changes: 1 addition & 4 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

var _ = require('underscore');
var adalIdConstants = require('./constants').AdalIdParameters;
var fs = require('fs');
var os = require('os');
var url = require('url');

Expand All @@ -34,9 +33,7 @@ var ADAL_VERSION;
*/

function loadAdalVersion() {
var packageData = fs.readFileSync(__dirname + '/../package.json');
var packageJson = JSON.parse(packageData);
ADAL_VERSION = packageJson.version;
ADAL_VERSION = require('../package.json').version;
}

function adalInit() {
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
"email": "[email protected]",
"url": "http://msopentech.com/"
},
"licenses": [
{
"type": "Apache 2.0",
"url": "https://github.com/AzureAD/aal/raw/master/License.txt"
}
],
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/AzureAD/azure-activedirectory-library-for-nodejs.git"
},
"version": "0.1.22",
"version": "0.1.23",
"description": "Windows Azure Active Directory Client Library for node",
"keywords": [ "node", "azure", "AAD", "adal", "adfs", "oauth" ],
"main": "./lib/adal.js",
Expand Down
1 change: 1 addition & 0 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, "version": "0.0.1"
, "private": true
, "dependencies": {
"@microsoft/microsoft-graph-client": "^1.0.0",
"adal-node": ">= 0.1.3",
"express": "3.x",
"connect-logger": "0.x",
Expand Down
34 changes: 34 additions & 0 deletions sample/windows-graph-sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const AuthenticationContext = require('adal-node').AuthenticationContext;
const MicrosoftGraph = require("@microsoft/microsoft-graph-client");

const authorityHostUrl = 'https://login.windows.net';
const tenantName = ''; //azure active directory tenant name. ie: name.onmicrosoft.com
const authorityUrl = authorityHostUrl + '/' + tenantName;
const applicationId = ''; //application id for registered app
const clientSecret = ''; //azure active directory registered app secret
const resource = "https://graph.microsoft.com"; //URI of resource where token is valid

const context = new AuthenticationContext(authorityUrl);

context.acquireTokenWithClientCredentials(
resource,
applicationId,
clientSecret,
function(err, tokenResponse) {
if (err) {
console.log('well that didn\'t work: ' + err.stack);
} else {
let client = MicrosoftGraph.Client.init({
defaultVersion: 'v1.0',
authProvider: (done) => {
done(null, tokenResponse.accessToken);
},
});

client
.api('/users')
.get((err, result) => {
console.log(result, err);
});
}
});
6 changes: 6 additions & 0 deletions test/authority.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ suite('Authority', function() {
return;
}
performStaticInstanceDiscovery('login-us.microsoftonline.com', function(err4) {
if(err4) {
done(err4);
return;
}
performStaticInstanceDiscovery('login.microsoftonline.us', function(err5) {
done(err5);
})
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ parameters.password = '<password>';
parameters.authorityHosts = {
global : 'login.windows.net',
china : 'login.chinacloudapi.cn',
gov : 'login-us.microsoftonline.com'
gov : 'login-us.microsoftonline.com',
us : 'login.microsoftonline.us'
};
parameters.language = 'en';
parameters.deviceCode = 'ABCDE:device_code';
Expand Down

0 comments on commit c3f0840

Please sign in to comment.