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

Commit c3f0840

Browse files
authored
Merge pull request #174 from AzureAD/dev
Release 1.0.23
2 parents 96c582c + 2ef72bc commit c3f0840

File tree

9 files changed

+63
-20
lines changed

9 files changed

+63
-20
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
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.
33

44
## Versions
5-
Current version - 0.1.22
5+
Current version - 0.1.23
66
Minimum recommended version - 0.1.22
77
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).
88

99
## Samples and Documentation
1010

11-
[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.
11+
[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.
1212

1313
## Community Help and Support
1414

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

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

115115
var context = new AuthenticationContext(authorityUrl);
116116

117-
context.acquireTokenWithClientCredentials(resource, clientId, clientSecret, function(err, tokenResponse) {
117+
context.acquireTokenWithClientCredentials(resource, applicationId, clientSecret, function(err, tokenResponse) {
118118
if (err) {
119119
console.log('well that didn\'t work: ' + err.stack);
120120
} else {

changelog.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Version 0.1.23
2+
--------------
3+
Release Date: 26 Oct 2017
4+
* Fix Issue #95 - Change npm licenses to license and use spdx syntax
5+
* Fix Issue #122 - Broken link on README file
6+
* Fix Issue #155 - remove need for dynamic access to package.json to obtain lib version (util.js)
7+
* Fix Issue #172 - Add login.microsoftonline.us endpoint
8+
* Added Windows Graph Sample
9+
110
Version 0.1.22
211
--------------
312
Release Date: 1 Aug 2016

lib/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ var Constants = {
140140

141141
AADConstants : {
142142
WORLD_WIDE_AUTHORITY : 'login.windows.net',
143-
WELL_KNOWN_AUTHORITY_HOSTS : ['login.windows.net', 'login.microsoftonline.com', 'login.chinacloudapi.cn', 'login-us.microsoftonline.com', 'login.microsoftonline.de'],
143+
WELL_KNOWN_AUTHORITY_HOSTS : ['login.windows.net', 'login.microsoftonline.com', 'login.chinacloudapi.cn', 'login-us.microsoftonline.com', 'login.microsoftonline.de', 'login.microsoftonline.us'],
144144
INSTANCE_DISCOVERY_ENDPOINT_TEMPLATE : 'https://{authorize_host}/common/discovery/instance?authorization_endpoint={authorize_endpoint}&api-version=1.0',
145145
AUTHORIZE_ENDPOINT_PATH : '/oauth2/authorize',
146146
TOKEN_ENDPOINT_PATH : '/oauth2/token',

lib/util.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
var _ = require('underscore');
2424
var adalIdConstants = require('./constants').AdalIdParameters;
25-
var fs = require('fs');
2625
var os = require('os');
2726
var url = require('url');
2827

@@ -34,9 +33,7 @@ var ADAL_VERSION;
3433
*/
3534

3635
function loadAdalVersion() {
37-
var packageData = fs.readFileSync(__dirname + '/../package.json');
38-
var packageJson = JSON.parse(packageData);
39-
ADAL_VERSION = packageJson.version;
36+
ADAL_VERSION = require('../package.json').version;
4037
}
4138

4239
function adalInit() {

package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@
55
"email": "[email protected]",
66
"url": "http://msopentech.com/"
77
},
8-
"licenses": [
9-
{
10-
"type": "Apache 2.0",
11-
"url": "https://github.com/AzureAD/aal/raw/master/License.txt"
12-
}
13-
],
8+
"license": "Apache-2.0",
149
"repository": {
1510
"type": "git",
1611
"url": "https://github.com/AzureAD/azure-activedirectory-library-for-nodejs.git"
1712
},
18-
"version": "0.1.22",
13+
"version": "0.1.23",
1914
"description": "Windows Azure Active Directory Client Library for node",
2015
"keywords": [ "node", "azure", "AAD", "adal", "adfs", "oauth" ],
2116
"main": "./lib/adal.js",

sample/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
, "version": "0.0.1"
44
, "private": true
55
, "dependencies": {
6+
"@microsoft/microsoft-graph-client": "^1.0.0",
67
"adal-node": ">= 0.1.3",
78
"express": "3.x",
89
"connect-logger": "0.x",

sample/windows-graph-sample.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const AuthenticationContext = require('adal-node').AuthenticationContext;
2+
const MicrosoftGraph = require("@microsoft/microsoft-graph-client");
3+
4+
const authorityHostUrl = 'https://login.windows.net';
5+
const tenantName = ''; //azure active directory tenant name. ie: name.onmicrosoft.com
6+
const authorityUrl = authorityHostUrl + '/' + tenantName;
7+
const applicationId = ''; //application id for registered app
8+
const clientSecret = ''; //azure active directory registered app secret
9+
const resource = "https://graph.microsoft.com"; //URI of resource where token is valid
10+
11+
const context = new AuthenticationContext(authorityUrl);
12+
13+
context.acquireTokenWithClientCredentials(
14+
resource,
15+
applicationId,
16+
clientSecret,
17+
function(err, tokenResponse) {
18+
if (err) {
19+
console.log('well that didn\'t work: ' + err.stack);
20+
} else {
21+
let client = MicrosoftGraph.Client.init({
22+
defaultVersion: 'v1.0',
23+
authProvider: (done) => {
24+
done(null, tokenResponse.accessToken);
25+
},
26+
});
27+
28+
client
29+
.api('/users')
30+
.get((err, result) => {
31+
console.log(result, err);
32+
});
33+
}
34+
});

test/authority.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ suite('Authority', function() {
130130
return;
131131
}
132132
performStaticInstanceDiscovery('login-us.microsoftonline.com', function(err4) {
133+
if(err4) {
133134
done(err4);
135+
return;
136+
}
137+
performStaticInstanceDiscovery('login.microsoftonline.us', function(err5) {
138+
done(err5);
139+
})
134140
});
135141
});
136142
});

test/util/util.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ parameters.password = '<password>';
100100
parameters.authorityHosts = {
101101
global : 'login.windows.net',
102102
china : 'login.chinacloudapi.cn',
103-
gov : 'login-us.microsoftonline.com'
103+
gov : 'login-us.microsoftonline.com',
104+
us : 'login.microsoftonline.us'
104105
};
105106
parameters.language = 'en';
106107
parameters.deviceCode = 'ABCDE:device_code';

0 commit comments

Comments
 (0)