Skip to content

Commit 10779ca

Browse files
committed
Merge branch 'known-authorities' of https://github.com/AzureAD/microsoft-authentication-library-for-js into known-authorities
2 parents 3c3e5c7 + 21324e5 commit 10779ca

File tree

99 files changed

+8353
-1965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+8353
-1965
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ The Microsoft Authentication Library for JavaScript enables client-side JavaScri
66

77
### Core and wrapper libaries
88

9-
The [`lib`](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib) folder contains the source code for all of our libraries. You will also find all the details about **installing the libraries**, in their respective Readme.md.
9+
The [`lib`](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib) folder contains the source code for all of our libraries. You will also find all the details about **installing the libraries**, in their respective README.md.
1010

11-
- [Microsoft Authentication Library for JavaScript v2.x](lib/msal-browser/): A browser-based, framework-agnostic browser library that enables authentication and token acquisition with the Microsoft Identity platform in JavaScript applications. Implements the OAuth 2.0 [Authorization Code Flow with PKCE](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow), and is [OpenID-compliant](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc).
11+
- [Microsoft Authentication Library for JavaScript v2.x (Preview)](lib/msal-browser/): A browser-based, framework-agnostic browser library that enables authentication and token acquisition with the Microsoft Identity platform in JavaScript applications. Implements the OAuth 2.0 [Authorization Code Flow with PKCE](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow), and is [OpenID-compliant](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc).
1212

1313
- [Microsoft Authentication Library for JavaScript v1.x](lib/msal-core/): A browser-based, framework-agnostic core library that enables authentication and token acquisition with the Microsoft Identity platform in JavaScript applications. Implements the OAuth 2.0 [Implicit Grant Flow](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-implicit-grant-flow), and is [OpenID-compliant](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc).
1414

@@ -20,7 +20,7 @@ A wrapper of the core 1.x library for apps using AngularJS framework.
2020

2121
### Samples
2222

23-
The [`samples`](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples) folder contains sample applications for our libaries. A complete list of samples can be found [on our wiki](https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/Samples).
23+
The [`samples`](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples) folder contains sample applications for our libaries. A complete list of samples can be found in the respective package folders or [on our wiki](https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/Samples).
2424

2525
## Package versioning
2626

build/npm-build-steps.yml

+12
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,36 @@ steps:
77
displayName: 'Install Node.js'
88

99
- task: Npm@1
10+
displayName: 'npm ci & lerna bootstrap'
1011
inputs:
1112
command: 'custom'
1213
customCommand: 'ci'
1314
verbose: true
1415

1516
- task: Npm@1
17+
displayName: 'Build Packages'
1618
inputs:
1719
command: 'custom'
1820
customCommand: 'run build'
1921

2022
- task: Npm@1
23+
displayName: 'Unit Tests'
2124
inputs:
2225
command: 'custom'
2326
customCommand: 'run test:coverage'
2427

2528
- task: Npm@1
29+
displayName: 'Code Coverage Reporting'
2630
env:
2731
COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN)
2832
inputs:
2933
command: 'custom'
3034
customCommand: 'run test:report'
35+
36+
- task: Npm@1
37+
displayName: 'End-to-End Tests'
38+
env:
39+
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
40+
inputs:
41+
command: 'custom'
42+
customCommand: 'run test:e2e'

build/postinstall.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
let exec = require("child_process").exec;
2+
3+
if (parseInt(process.env.RUNNING_NODE_CI)) {
4+
console.log("Running scoped bootstrap");
5+
exec("lerna --scope @azure/* --scope msal --scope vanilla-js-test* --ignore @azure/msal-angularjs bootstrap", function (error, stdout, stderr) {
6+
if (stdout) {
7+
console.log('stdout' + stdout);
8+
}
9+
console.error('stderr: ' + stderr);
10+
if (error !== null) {
11+
console.log('exec error: ' + error);
12+
}
13+
});
14+
} else {
15+
console.log("Running full bootstrap");
16+
exec("lerna bootstrap", function (error, stdout, stderr) {
17+
if (stdout) {
18+
console.log('stdout' + stdout);
19+
}
20+
console.error('stderr: ' + stderr);
21+
if (error !== null) {
22+
console.log('exec error: ' + error);
23+
}
24+
});
25+
}

lerna.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
"lerna": "3.16.4",
33
"command": {
44
"run": {
5-
"scope": ["msal", "@azure/msal-common", "@azure/msal-browser", "@azure/msal-angular"]
5+
"scope": [
6+
"msal",
7+
"@azure/msal-common",
8+
"@azure/msal-browser",
9+
"@azure/msal-angular",
10+
"vanilla-js-test-app",
11+
"vanilla-js-test-app-2.0"
12+
]
613
}
714
},
815
"packages": [

lib/msal-angular/package-lock.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/msal-angular/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"peerDependencies": {
3232
"@angular/common": ">= 6.0.0",
3333
"@angular/core": ">= 6.0.0",
34-
"msal": "^1.2.2-beta.2",
34+
"msal": "^1.3.0-beta.0",
3535
"rxjs": "^6.0.0"
3636
},
3737
"devDependencies": {
@@ -74,7 +74,7 @@
7474
"karma-spec-reporter": "0.0.32",
7575
"karma-verbose-reporter": "0.0.6",
7676
"karma-webpack": "^3.0.0",
77-
"msal": "^1.2.2-beta.0",
77+
"msal": "^1.3.0-beta.0",
7878
"ng-packagr": "^9.0.2",
7979
"phantomjs-polyfill": "0.0.2",
8080
"reflect-metadata": "^0.1.3",

lib/msal-angular/src/msal-guard.service.ts

+27-10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ export class MsalGuard implements CanActivate {
2727
private broadcastService: BroadcastService
2828
) {}
2929

30+
/**
31+
* Builds the absolute url for the destination page
32+
* @param path Relative path of requested page
33+
* @returns Full destination url
34+
*/
35+
getDestinationUrl(path: string): string {
36+
// Absolute base url for the application (default to origin if base element not present)
37+
const baseElements = document.getElementsByTagName("base");
38+
const baseUrl = this.location.normalize(baseElements.length ? baseElements[0].href : window.location.origin);
39+
40+
// Path of page (including hash, if using hash routing)
41+
const pathUrl = this.location.prepareExternalUrl(path);
42+
43+
// Hash location strategy
44+
if (pathUrl.startsWith("#")) {
45+
return `${baseUrl}/${pathUrl}`;
46+
}
47+
48+
// If using path location strategy, pathUrl will include the relative portion of the base path (e.g. /base/page).
49+
// Since baseUrl also includes /base, can just concatentate baseUrl + path
50+
return `${baseUrl}${path}`;
51+
}
52+
3053
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Promise<boolean> {
3154
this.authService.getLogger().verbose("location change event from old url to new url");
3255

@@ -47,25 +70,19 @@ export class MsalGuard implements CanActivate {
4770
.catch(() => false);
4871
}
4972

50-
const routePath = `${window.location.origin}${state.url}`;
73+
const redirectStartPage = this.getDestinationUrl(state.url);
5174

5275
this.authService.loginRedirect({
53-
redirectStartPage: routePath,
76+
redirectStartPage,
5477
scopes: this.msalAngularConfig.consentScopes,
5578
extraQueryParameters: this.msalAngularConfig.extraQueryParameters
5679
});
5780
} else {
5881
return this.authService.acquireTokenSilent({
5982
scopes: [this.msalConfig.auth.clientId]
6083
})
61-
.then((result: AuthResponse) => {
62-
this.broadcastService.broadcast("msal:loginSuccess", result);
63-
return true;
64-
})
65-
.catch((error: AuthError) => {
66-
this.broadcastService.broadcast("msal:loginFailure", error);
67-
return false;
68-
});
84+
.then(() => true)
85+
.catch(() => false);
6986
}
7087

7188
}

lib/msal-angular/src/msal.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class MsalService extends UserAgentApplication {
6060
for (var i = 0; i < router.config.length; i++) {
6161
if (!router.config[i].canActivate) {
6262
if (this.msalAngularConfig.unprotectedResources) {
63-
if (!this.isUnprotectedResource(router.config[i].path) && !this.isEmpty(router.config[i].path)) {
63+
if (!this.isEmpty(router.config[i].path) && !this.isUnprotectedResource(router.config[i].path)) {
6464
this.msalAngularConfig.unprotectedResources.push(router.config[i].path);
6565
}
6666
}

lib/msal-browser/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,4 @@ node_modules/
262262
typings/
263263
lib/
264264
dist/
265+
ref/

lib/msal-browser/FAQ.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
# How do I get an authorization code from the library?
44

5-
# Iframe support
5+
Currently the msal-browser package is designed for Single-Page Applications that are handling all authentication through the browser client. We have not yet optimized this to work with server-side components. As such, requests to retrieve the authorization code from the first leg of the flow can't be met currently. We are currently working on an [implementation of msal that will run in node libraries](https://github.com/AzureAD/microsoft-authentication-library-for-js/projects/4), and as part of that we will explore options to make msal-browser work with server-side components.
66

7-
# B2C
7+
# Does this library work for iframed applications?
8+
9+
We are currently working on support for iframed applications as well as solutions for applications affected by ITP 2.x changes. You can monitor the first of those tickets [here](#1410).
10+
11+
# Will MSAL 2.x support B2C?
12+
13+
We are currently working with the B2C service team to allow for authorization code flow to work in the browser with B2C tenants. We hope to have this available shortly after release.

0 commit comments

Comments
 (0)