├── .editorconfig
├── .gitignore
├── LICENSE
├── README.md
├── angular.json
├── e2e
├── protractor.conf.js
├── src
│ ├── app.e2e-spec.ts
│ └── app.po.ts
└── tsconfig.e2e.json
├── package-lock.json
├── package.json
├── projects
└── ms-adal-angular6
│ ├── README.md
│ ├── karma.conf.js
│ ├── ng-package.json
│ ├── ng-package.prod.json
│ ├── package.json
│ ├── public_api.ts
│ ├── src
│ ├── authentication-guard.ts
│ ├── ms-adal-angular6.module.ts
│ ├── ms-adal-angular6.service.spec.ts
│ └── ms-adal-angular6.service.ts
│ ├── test.ts
│ ├── tsconfig.lib.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── src
├── app
│ ├── app.component.css
│ ├── app.component.html
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ └── app.module.ts
├── assets
│ └── .gitkeep
├── browserslist
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── karma.conf.js
├── main.ts
├── polyfills.ts
├── styles.css
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── tslint.json
├── tsconfig.json
└── tslint.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | yarn-error.log
34 | testem.log
35 | /typings
36 |
37 | # System Files
38 | .DS_Store
39 | Thumbs.db
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Manish Ramchand
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Active Directory Authentication Library (ADAL) for Angular 6+ (Angular 6.X.X and Angular 7.X.X)
2 |
3 | This is a wrapper library for Angular 6+ (Angular 6.X.X and Angular 7.X.X) modules over Microsoft ADAL (Azure Active Directory Authentication Library) - [https://github.com/AzureAD/azure-activedirectory-library-for-js](https://github.com/AzureAD/azure-activedirectory-library-for-js) that helps you integrate your web app with Microsoft's AAD (Azure Active Directory) for authentication scenarios.
4 |
5 | Working example at [https://github.com/manishrasrani/ms-adal-angular6-example](https://github.com/manishrasrani/ms-adal-angular6-example)
6 |
7 | ___
8 |
9 | For information on how to configure Azure Active Directory refer - [https://docs.microsoft.com/en-us/azure/app-service/app-service-mobile-how-to-configure-active-directory-authentication](https://docs.microsoft.com/en-us/azure/app-service/app-service-mobile-how-to-configure-active-directory-authentication)
10 |
11 |
Consumption of the library
12 |
13 | **Step 1: Install the package**
14 | ```bash
15 | npm i microsoft-adal-angular6
16 | ```
17 | Also add it to your dependencies section in package.json so that it is restored when you do an npm install.
18 |
19 | **Step 2: Import MsAdalModule and configure Adal options**
20 |
21 | In the root module of your application, import the MsAdalModule module.
22 | ```bash
23 | import { MsAdalAngular6Module } from 'microsoft-adal-angular6';
24 | ```
25 | Configure Adal options while importing the module.
26 | ```bash
27 | @NgModule({
28 | imports: [
29 | MsAdalAngular6Module.forRoot({
30 | tenant: '',<-------------------------------- ADD
31 | clientId: '',<--------------------- ADD
32 | redirectUri: window.location.origin,
33 | endpoints: { <------------------------------------------- ADD
34 | "https://localhost/Api/": "xxx-bae6-4760-b434-xxx",
35 | ---
36 | ---
37 | },
38 | navigateToLoginRequestUrl: false,
39 | cacheLocation: '', <------ ADD
40 | }),
41 | ---
42 | ---
43 | ],
44 | ---
45 | ---
46 | })
47 | ```
48 |
49 | In case you need to set configuration values dynamically at runtime, you can also pass a function:
50 | ```typescript
51 |
52 | export function getAdalConfig() {
53 | return {
54 | tenant: '',
55 | clientId: '',
56 | redirectUri: window.location.origin,
57 | endpoints: {
58 | "https://localhost/Api/": "xxx-bae6-4760-b434-xxx",
59 | },
60 | navigateToLoginRequestUrl: false,
61 | cacheLocation: '',
62 | };
63 | }
64 |
65 | @NgModule({
66 | imports: [
67 | MsAdalAngular6Module.forRoot(getAdalConfig),
68 | ],
69 | })
70 | ```
71 |
72 | This might be the case if you need to pass `window.location.origin` as `redirectUri`, since the Angular AOT compiler applies a [special behavior](https://github.com/manishrasrani/ms-adal-angular6/issues/7) when compiling @Decorators.
73 |
74 | For a list of all available adal configuration options, refer - [https://github.com/AzureAD/azure-activedirectory-library-for-js/blob/dev/lib/adal.js](https://github.com/AzureAD/azure-activedirectory-library-for-js/blob/dev/lib/adal.js)
75 |
76 | **Step 3: Secure individual routes**
77 |
78 | Use the AuthenticationGuard to secure indivuadual routes in your application. This ensures that users navigating to them must be authenticated with AAD to view them.
79 |
80 | Import AuthenticationGuard and add it as a provider in your root module.
81 | ```bash
82 | import { AuthenticationGuard } from 'microsoft-adal-angular6';
83 | ```
84 |
85 | ```bash
86 | @NgModule({
87 | providers: [AuthenticationGuard],
88 | ---
89 | ---
90 | })
91 | ```
92 | In your routing module, add it to the routes you want to secure -
93 | ```bash
94 | const routes: Routes = [
95 | { path: '', component: AppComponent, pathMatch:'full', canActivate: [AuthenticationGuard]}
96 | ];
97 | @NgModule({
98 | imports: [
99 | RouterModule.forRoot(routes),
100 | ],
101 | exports: [
102 | RouterModule
103 | ]
104 | })
105 | export class AppRoutingModule { }
106 | ```
107 |
108 | **Step 4 (Optional): Generating resource tokens**
109 |
110 | To generate resource level tokens for APIs your website may consume, specify the resources in your endpoints array while injecting adalConfig into MsAdalAngular6Module.
111 | Then to generate token, use acquireToken() of MsAdalAngular6Service-
112 | ```bash
113 | constructor(private adalSvc: MsAdalAngular6Service) {
114 | this.adalSvc.acquireToken('').subscribe((resToken: string) => {
115 | console.log(resToken);
116 | });
117 | ```
118 |
119 | **Step 5 (Optional): Other properties and methods**
120 |
121 | Based on your application needs you could use the below supported properties and methods of adalSvc -
122 | ```bash
123 | this.adalSvc.userInfo // Gives you the complete user object with various properties about the logged in user
124 | ```
125 | ```bash
126 | this.adalSvc.LoggedInUserEmail // Gets the LoggedInUserEmail
127 | ```
128 | ```bash
129 | this.adalSvc.LoggedInUserName // Gets the LoggedInUserName
130 | ```
131 | ```bash
132 | this.adalSvc.RenewToken() // Renews the AAD token
133 | ```
134 | ```bash
135 | this.adalSvc.logout() // Logs out the signed in user
136 | ```
137 |
138 |
139 | With these steps your application should be up and running with ADAL.
140 |
141 | **Important links**
142 | 1. [Azure Active Directory Overview](https://docs.microsoft.com/en-us/azure/active-directory/active-directory-whatis)
143 | 2. [Configure Azure Active Directory](https://docs.microsoft.com/en-us/azure/app-service/app-service-mobile-how-to-configure-active-directory-authentication)
144 | 3. [Azure Active Directory Pricing](https://azure.microsoft.com/en-in/pricing/details/active-directory/)
145 | 4. [Active Directory Authentication Library (ADAL) for JavaScript](https://github.com/AzureAD/azure-activedirectory-library-for-js)
146 | 5. [Sample Angular6 app that consumes this library](https://github.com/manishrasrani/ms-adal-angular6-example)
147 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "AdalAngular6-client": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {},
12 | "architect": {
13 | "build": {
14 | "builder": "@angular-devkit/build-angular:browser",
15 | "options": {
16 | "outputPath": "dist/AdalAngular6-client",
17 | "index": "src/index.html",
18 | "main": "src/main.ts",
19 | "polyfills": "src/polyfills.ts",
20 | "tsConfig": "src/tsconfig.app.json",
21 | "assets": [
22 | "src/favicon.ico",
23 | "src/assets"
24 | ],
25 | "styles": [
26 | "src/styles.css"
27 | ],
28 | "scripts": []
29 | },
30 | "configurations": {
31 | "production": {
32 | "fileReplacements": [
33 | {
34 | "replace": "src/environments/environment.ts",
35 | "with": "src/environments/environment.prod.ts"
36 | }
37 | ],
38 | "optimization": true,
39 | "outputHashing": "all",
40 | "sourceMap": false,
41 | "extractCss": true,
42 | "namedChunks": false,
43 | "aot": true,
44 | "extractLicenses": true,
45 | "vendorChunk": false,
46 | "buildOptimizer": true
47 | }
48 | }
49 | },
50 | "serve": {
51 | "builder": "@angular-devkit/build-angular:dev-server",
52 | "options": {
53 | "browserTarget": "AdalAngular6-client:build"
54 | },
55 | "configurations": {
56 | "production": {
57 | "browserTarget": "AdalAngular6-client:build:production"
58 | }
59 | }
60 | },
61 | "extract-i18n": {
62 | "builder": "@angular-devkit/build-angular:extract-i18n",
63 | "options": {
64 | "browserTarget": "AdalAngular6-client:build"
65 | }
66 | },
67 | "test": {
68 | "builder": "@angular-devkit/build-angular:karma",
69 | "options": {
70 | "main": "src/test.ts",
71 | "polyfills": "src/polyfills.ts",
72 | "tsConfig": "src/tsconfig.spec.json",
73 | "karmaConfig": "src/karma.conf.js",
74 | "styles": [
75 | "src/styles.css"
76 | ],
77 | "scripts": [],
78 | "assets": [
79 | "src/favicon.ico",
80 | "src/assets"
81 | ]
82 | }
83 | },
84 | "lint": {
85 | "builder": "@angular-devkit/build-angular:tslint",
86 | "options": {
87 | "tsConfig": [
88 | "src/tsconfig.app.json",
89 | "src/tsconfig.spec.json"
90 | ],
91 | "exclude": [
92 | "**/node_modules/**"
93 | ]
94 | }
95 | }
96 | }
97 | },
98 | "AdalAngular6-client-e2e": {
99 | "root": "e2e/",
100 | "projectType": "application",
101 | "architect": {
102 | "e2e": {
103 | "builder": "@angular-devkit/build-angular:protractor",
104 | "options": {
105 | "protractorConfig": "e2e/protractor.conf.js",
106 | "devServerTarget": "AdalAngular6-client:serve"
107 | }
108 | },
109 | "lint": {
110 | "builder": "@angular-devkit/build-angular:tslint",
111 | "options": {
112 | "tsConfig": "e2e/tsconfig.e2e.json",
113 | "exclude": [
114 | "**/node_modules/**"
115 | ]
116 | }
117 | }
118 | }
119 | },
120 | "ms-adal-angular6": {
121 | "root": "projects/ms-adal-angular6",
122 | "sourceRoot": "projects/ms-adal-angular6/src",
123 | "projectType": "library",
124 | "prefix": "lib",
125 | "architect": {
126 | "build": {
127 | "builder": "@angular-devkit/build-ng-packagr:build",
128 | "options": {
129 | "tsConfig": "projects/ms-adal-angular6/tsconfig.lib.json",
130 | "project": "projects/ms-adal-angular6/ng-package.json"
131 | },
132 | "configurations": {
133 | "production": {
134 | "project": "projects/ms-adal-angular6/ng-package.prod.json"
135 | }
136 | }
137 | },
138 | "test": {
139 | "builder": "@angular-devkit/build-angular:karma",
140 | "options": {
141 | "main": "projects/ms-adal-angular6/src/test.ts",
142 | "tsConfig": "projects/ms-adal-angular6/tsconfig.spec.json",
143 | "karmaConfig": "projects/ms-adal-angular6/karma.conf.js"
144 | }
145 | },
146 | "lint": {
147 | "builder": "@angular-devkit/build-angular:tslint",
148 | "options": {
149 | "tsConfig": [
150 | "projects/ms-adal-angular6/tsconfig.lib.json",
151 | "projects/ms-adal-angular6/tsconfig.spec.json"
152 | ],
153 | "exclude": [
154 | "**/node_modules/**"
155 | ]
156 | }
157 | }
158 | }
159 | }
160 | },
161 | "defaultProject": "AdalAngular6-client"
162 | }
--------------------------------------------------------------------------------
/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './src/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: require('path').join(__dirname, './tsconfig.e2e.json')
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
--------------------------------------------------------------------------------
/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('workspace-project App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to app!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "adal-angular6-client",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/common": "^6.0.2",
15 | "@angular/core": "^6.0.2",
16 | "@angular/compiler": "^6.0.2",
17 | "@angular/animations": "^6.0.2",
18 | "@angular/forms": "^6.0.2",
19 | "@angular/http": "^6.0.2",
20 | "@angular/platform-browser": "^6.0.2",
21 | "@angular/platform-browser-dynamic": "^6.0.2",
22 | "@angular/router": "^6.0.2",
23 | "core-js": "^2.5.4",
24 | "rxjs": "^6.0.0",
25 | "zone.js": "^0.8.26",
26 | "@types/adal": "^1.0.29",
27 | "adal-angular": "^1.0.15"
28 | },
29 | "devDependencies": {
30 | "@angular/compiler-cli": "^6.0.2",
31 | "@angular-devkit/build-ng-packagr": "~0.6.3",
32 | "@angular-devkit/build-angular": "~0.6.3",
33 | "ng-packagr": "^3.0.0-rc.2",
34 | "tsickle": ">=0.25.5",
35 | "tslib": "^1.7.1",
36 | "typescript": "~2.7.2",
37 | "@angular/cli": "~6.0.3",
38 | "@angular/language-service": "^6.0.2",
39 | "@types/jasmine": "~2.8.6",
40 | "@types/jasminewd2": "~2.0.3",
41 | "@types/node": "~8.9.4",
42 | "codelyzer": "~4.2.1",
43 | "jasmine-core": "~2.99.1",
44 | "jasmine-spec-reporter": "~4.2.1",
45 | "karma": "~1.7.1",
46 | "karma-chrome-launcher": "~2.2.0",
47 | "karma-coverage-istanbul-reporter": "~1.4.2",
48 | "karma-jasmine": "~1.1.1",
49 | "karma-jasmine-html-reporter": "^0.2.2",
50 | "protractor": "~5.3.0",
51 | "ts-node": "~5.0.1",
52 | "tslint": "~5.9.1"
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/README.md:
--------------------------------------------------------------------------------
1 | # Active Directory Authentication Library (ADAL) for Angular 6+ (Angular 6.X.X and Angular 7.X.X)
2 |
3 | This is a wrapper library for Angular 6+ (Angular 6.X.X and Angular 7.X.X) modules over Microsoft ADAL (Azure Active Directory Authentication Library) - [https://github.com/AzureAD/azure-activedirectory-library-for-js](https://github.com/AzureAD/azure-activedirectory-library-for-js) that helps you integrate your web app with Microsoft's AAD (Azure Active Directory) for authentication scenarios.
4 |
5 | Working example at [https://github.com/manishrasrani/ms-adal-angular6-example](https://github.com/manishrasrani/ms-adal-angular6-example)
6 |
7 | ___
8 |
9 | For information on how to configure Azure Active Directory refer - [https://docs.microsoft.com/en-us/azure/app-service/app-service-mobile-how-to-configure-active-directory-authentication](https://docs.microsoft.com/en-us/azure/app-service/app-service-mobile-how-to-configure-active-directory-authentication)
10 |
11 | Consumption of the library
12 |
13 | **Step 1: Install the package**
14 | ```bash
15 | npm i microsoft-adal-angular6
16 | ```
17 | Also add it to your dependencies section in package.json so that it is restored when you do an npm install.
18 |
19 | **Step 2: Import MsAdalModule and configure Adal options**
20 |
21 | In the root module of your application, import the MsAdalModule module.
22 | ```bash
23 | import { MsAdalAngular6Module } from 'microsoft-adal-angular6';
24 | ```
25 | Configure Adal options while importing the module.
26 | ```bash
27 | @NgModule({
28 | imports: [
29 | MsAdalAngular6Module.forRoot({
30 | tenant: '',<-------------------------------- ADD
31 | clientId: '',<--------------------- ADD
32 | redirectUri: window.location.origin,
33 | endpoints: { <------------------------------------------- ADD
34 | "https://localhost/Api/": "xxx-bae6-4760-b434-xxx",
35 | ---
36 | ---
37 | },
38 | navigateToLoginRequestUrl: false,
39 | cacheLocation: '', <------ ADD
40 | }),
41 | ---
42 | ---
43 | ],
44 | ---
45 | ---
46 | })
47 | ```
48 |
49 | In case you need to set configuration values dynamically at runtime, you can also pass a function:
50 | ```typescript
51 |
52 | export function getAdalConfig() {
53 | return {
54 | tenant: '',
55 | clientId: '',
56 | redirectUri: window.location.origin,
57 | endpoints: {
58 | "https://localhost/Api/": "xxx-bae6-4760-b434-xxx",
59 | },
60 | navigateToLoginRequestUrl: false,
61 | cacheLocation: '',
62 | };
63 | }
64 |
65 | @NgModule({
66 | imports: [
67 | MsAdalAngular6Module.forRoot(getAdalConfig),
68 | ],
69 | })
70 | ```
71 |
72 | This might be the case if you need to pass `window.location.origin` as `redirectUri`, since the Angular AOT compiler applies a [special behavior](https://github.com/manishrasrani/ms-adal-angular6/issues/7) when compiling @Decorators.
73 |
74 | For a list of all available adal configuration options, refer - [https://github.com/AzureAD/azure-activedirectory-library-for-js/blob/dev/lib/adal.js](https://github.com/AzureAD/azure-activedirectory-library-for-js/blob/dev/lib/adal.js)
75 |
76 | **Step 3: Secure individual routes**
77 |
78 | Use the AuthenticationGuard to secure indivuadual routes in your application. This ensures that users navigating to them must be authenticated with AAD to view them.
79 |
80 | Import AuthenticationGuard and add it as a provider in your root module.
81 | ```bash
82 | import { AuthenticationGuard } from 'microsoft-adal-angular6';
83 | ```
84 |
85 | ```bash
86 | @NgModule({
87 | providers: [AuthenticationGuard],
88 | ---
89 | ---
90 | })
91 | ```
92 | In your routing module, add it to the routes you want to secure -
93 | ```bash
94 | const routes: Routes = [
95 | { path: '', component: AppComponent, pathMatch:'full', canActivate: [AuthenticationGuard]}
96 | ];
97 | @NgModule({
98 | imports: [
99 | RouterModule.forRoot(routes),
100 | ],
101 | exports: [
102 | RouterModule
103 | ]
104 | })
105 | export class AppRoutingModule { }
106 | ```
107 |
108 | **Step 4 (Optional): Generating resource tokens**
109 |
110 | To generate resource level tokens for APIs your website may consume, specify the resources in your endpoints array while injecting adalConfig into MsAdalAngular6Module.
111 | Then to generate token, use acquireToken() of MsAdalAngular6Service-
112 | ```bash
113 | constructor(private adalSvc: MsAdalAngular6Service) {
114 | this.adalSvc.acquireToken('').subscribe((resToken: string) => {
115 | console.log(resToken);
116 | });
117 | ```
118 |
119 | **Step 5 (Optional): Other properties and methods**
120 |
121 | Based on your application needs you could use the below supported properties and methods of adalSvc -
122 | ```bash
123 | this.adalSvc.userInfo // Gives you the complete user object with various properties about the logged in user
124 | ```
125 | ```bash
126 | this.adalSvc.LoggedInUserEmail // Gets the LoggedInUserEmail
127 | ```
128 | ```bash
129 | this.adalSvc.LoggedInUserName // Gets the LoggedInUserName
130 | ```
131 | ```bash
132 | this.adalSvc.RenewToken() // Renews the AAD token
133 | ```
134 | ```bash
135 | this.adalSvc.logout() // Logs out the signed in user
136 | ```
137 |
138 |
139 | With these steps your application should be up and running with ADAL.
140 |
141 | **Important links**
142 | 1. [Azure Active Directory Overview](https://docs.microsoft.com/en-us/azure/active-directory/active-directory-whatis)
143 | 2. [Configure Azure Active Directory](https://docs.microsoft.com/en-us/azure/app-service/app-service-mobile-how-to-configure-active-directory-authentication)
144 | 3. [Azure Active Directory Pricing](https://azure.microsoft.com/en-in/pricing/details/active-directory/)
145 | 4. [Active Directory Authentication Library (ADAL) for JavaScript](https://github.com/AzureAD/azure-activedirectory-library-for-js)
146 | 5. [Sample Angular6 app that consumes this library](https://github.com/manishrasrani/ms-adal-angular6-example)
147 |
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../../coverage'),
20 | reports: ['html', 'lcovonly'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
32 |
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/ng-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3 | "dest": "../../dist/ms-adal-angular6",
4 | "deleteDestPath": false,
5 | "lib": {
6 | "entryFile": "public_api.ts"
7 | },
8 | "whitelistedNonPeerDependencies": [
9 | "adal-angular",
10 | "@types/adal"
11 | ]
12 | }
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/ng-package.prod.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3 | "dest": "../../dist/ms-adal-angular6",
4 | "lib": {
5 | "entryFile": "public_api.ts"
6 | }
7 | }
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "microsoft-adal-angular6",
3 | "version": "1.3.0",
4 | "description": "This is a wrapper library for Angular 6 (Angular 6.X.X and Angular 7.X.X) modules over Microsoft ADAL (Azure Active Directory Authentication Library)",
5 | "author": {
6 | "name": "Manish Ramchand"
7 | },
8 | "license": "MIT",
9 | "repository": {
10 | "type": "git",
11 | "url": "https://github.com/manishrasrani/ms-adal-angular6"
12 | },
13 | "keywords": [
14 | "adal",
15 | "angular6",
16 | "angular7",
17 | "adal angular",
18 | "adal angular6",
19 | "adal angular7",
20 | "azure active directory",
21 | "AAD authentication"
22 | ],
23 | "private": false,
24 | "peerDependencies": {
25 | "@angular/common": "^6.0.0-rc.0 || ^6.0.0",
26 | "@angular/core": "^6.0.0-rc.0 || ^6.0.0"
27 | },
28 | "dependencies": {
29 | "adal-angular": "^1.0.15",
30 | "@types/adal": "^1.0.29"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/public_api.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Public API Surface of ms-adal-angular6
3 | */
4 |
5 | export * from './src/ms-adal-angular6.service';
6 | export * from './src/authentication-guard';
7 | export * from './src/ms-adal-angular6.module';
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/src/authentication-guard.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from "@angular/core";
2 | import { CanActivate, CanActivateChild, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
3 | import { MsAdalAngular6Service } from "./ms-adal-angular6.service";
4 |
5 | @Injectable()
6 | export class AuthenticationGuard implements CanActivate, CanActivateChild {
7 | constructor(private adalSvc: MsAdalAngular6Service) { }
8 |
9 | public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
10 | if (this.adalSvc.isAuthenticated) {
11 | return true;
12 | } else {
13 | this.adalSvc.login();
14 | return false;
15 | }
16 | }
17 |
18 | public canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
19 | return this.canActivate(childRoute, state);
20 | }
21 | }
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/src/ms-adal-angular6.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { ModuleWithProviders } from '@angular/core';
3 | import { MsAdalAngular6Service } from './ms-adal-angular6.service';
4 |
5 | @NgModule({
6 | imports: [],
7 | declarations: [],
8 | exports: []
9 | })
10 | export class MsAdalAngular6Module {
11 | static forRoot(adalConfig: any): ModuleWithProviders {
12 | return {
13 | ngModule: MsAdalAngular6Module,
14 | providers: [MsAdalAngular6Service, { provide: 'adalConfig', useValue: adalConfig }]
15 | };
16 | }
17 | }
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/src/ms-adal-angular6.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { MsAdalAngular6Service } from './ms-adal-angular6.service';
4 |
5 | describe('MsAdalAngular6Service', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [MsAdalAngular6Service]
9 | });
10 | });
11 |
12 | it('should be created', inject([MsAdalAngular6Service], (service: MsAdalAngular6Service) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/src/ms-adal-angular6.service.ts:
--------------------------------------------------------------------------------
1 | ///
2 | import { Injectable, Inject } from '@angular/core';
3 | import { Observable, bindCallback } from 'rxjs';
4 | import * as adalLib from 'adal-angular';
5 |
6 | @Injectable({
7 | providedIn: 'root'
8 | })
9 | export class MsAdalAngular6Service {
10 | private context: adal.AuthenticationContext;
11 |
12 | constructor(@Inject('adalConfig') private adalConfig: any) {
13 | if (typeof adalConfig === 'function') {
14 | this.adalConfig = adalConfig();
15 | }
16 | this.context = adalLib.inject(this.adalConfig);
17 | this.handleCallback();
18 | }
19 |
20 | public get LoggedInUserEmail() {
21 | if (this.isAuthenticated) {
22 | return this.context.getCachedUser().userName;
23 | }
24 | return '';
25 | }
26 |
27 | public get LoggedInUserName() {
28 | if (this.isAuthenticated) {
29 | return this.context.getCachedUser().profile.name;
30 | }
31 | return '';
32 | }
33 |
34 | public login() {
35 | this.context.login();
36 | }
37 |
38 | public logout() {
39 | this.context.logOut();
40 | }
41 |
42 | public GetResourceForEndpoint(url: string): string {
43 | let resource = null;
44 | if (url) {
45 | resource = this.context.getResourceForEndpoint(url);
46 | if (!resource) {
47 | resource = this.adalConfig.clientId;
48 | }
49 | }
50 | return resource;
51 | }
52 |
53 | public RenewToken(url: string) {
54 | let resource = this.GetResourceForEndpoint(url);
55 | return this.context.clearCacheForResource(resource); // Trigger the ADAL token renew
56 | }
57 |
58 | public acquireToken(url: string) {
59 | const _this = this; // save outer this for inner function
60 | let errorMessage: string;
61 |
62 | return bindCallback(acquireTokenInternal, (token: string) => {
63 | if (!token && errorMessage) {
64 | throw (errorMessage);
65 | }
66 | return token;
67 | })();
68 |
69 | function acquireTokenInternal(cb: any) {
70 | let s: string = null;
71 | let resource: string;
72 | resource = _this.GetResourceForEndpoint(url);
73 |
74 | _this.context.acquireToken(resource, (error: string, tokenOut: string) => {
75 | if (error) {
76 | _this.context.error('Error when acquiring token for resource: ' + resource, error);
77 | errorMessage = error;
78 | cb(null as string);
79 | } else {
80 | cb(tokenOut);
81 | s = tokenOut;
82 | }
83 | });
84 | return s;
85 | }
86 | }
87 |
88 | public getToken(url: string): string {
89 |
90 | const resource = this.context.getResourceForEndpoint(url);
91 | const storage = this.adalConfig.cacheLocation;
92 | let key;
93 | if (resource) {
94 | key = 'adal.access.token.key' + resource;
95 | } else {
96 | key = 'adal.idtoken';
97 | }
98 | if (storage === 'localStorage') {
99 | return localStorage.getItem(key);
100 | } else {
101 | return sessionStorage.getItem(key);
102 | }
103 | }
104 |
105 | handleCallback() {
106 | this.context.handleWindowCallback();
107 | }
108 |
109 | public get userInfo() {
110 | return this.context.getCachedUser();
111 | }
112 |
113 | public get accessToken() {
114 | return this.context.getCachedToken(this.adalConfig.clientId);
115 | }
116 |
117 | public get isAuthenticated(): boolean {
118 | return (this.userInfo && this.accessToken) ? true : false;
119 | }
120 | }
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'core-js/es7/reflect';
4 | import 'zone.js/dist/zone';
5 | import 'zone.js/dist/zone-testing';
6 | import { getTestBed } from '@angular/core/testing';
7 | import {
8 | BrowserDynamicTestingModule,
9 | platformBrowserDynamicTesting
10 | } from '@angular/platform-browser-dynamic/testing';
11 |
12 | declare const require: any;
13 |
14 | // First, initialize the Angular testing environment.
15 | getTestBed().initTestEnvironment(
16 | BrowserDynamicTestingModule,
17 | platformBrowserDynamicTesting()
18 | );
19 | // Then we find all the tests.
20 | const context = require.context('./', true, /\.spec\.ts$/);
21 | // And load the modules.
22 | context.keys().map(context);
23 |
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/tsconfig.lib.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/lib",
5 | "target": "es2015",
6 | "module": "es2015",
7 | "moduleResolution": "node",
8 | "declaration": true,
9 | "sourceMap": true,
10 | "inlineSources": true,
11 | "emitDecoratorMetadata": true,
12 | "experimentalDecorators": true,
13 | "importHelpers": true,
14 | "types": [],
15 | "lib": [
16 | "dom",
17 | "es2015"
18 | ]
19 | },
20 | "angularCompilerOptions": {
21 | "annotateForClosureCompiler": true,
22 | "skipTemplateCodegen": true,
23 | "strictMetadataEmit": true,
24 | "fullTemplateTypeCheck": true,
25 | "strictInjectionParameters": true,
26 | "flatModuleId": "AUTOGENERATED",
27 | "flatModuleOutFile": "AUTOGENERATED"
28 | },
29 | "exclude": [
30 | "src/test.ts",
31 | "**/*.spec.ts"
32 | ]
33 | }
34 |
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts"
12 | ],
13 | "include": [
14 | "**/*.spec.ts",
15 | "**/*.d.ts"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/projects/ms-adal-angular6/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "lib",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "lib",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manishrasrani/ms-adal-angular6/c9ffd527f3c6a92bc90020f35ccff93f8102492f/src/app/app.component.css
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Welcome to {{ title }}!
5 |
6 |

7 |
8 | Here are some links to help you start:
9 |
10 | -
11 |
12 |
13 | -
14 |
15 |
16 | -
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 | describe('AppComponent', () => {
4 | beforeEach(async(() => {
5 | TestBed.configureTestingModule({
6 | declarations: [
7 | AppComponent
8 | ],
9 | }).compileComponents();
10 | }));
11 | it('should create the app', async(() => {
12 | const fixture = TestBed.createComponent(AppComponent);
13 | const app = fixture.debugElement.componentInstance;
14 | expect(app).toBeTruthy();
15 | }));
16 | it(`should have as title 'app'`, async(() => {
17 | const fixture = TestBed.createComponent(AppComponent);
18 | const app = fixture.debugElement.componentInstance;
19 | expect(app.title).toEqual('app');
20 | }));
21 | it('should render title in a h1 tag', async(() => {
22 | const fixture = TestBed.createComponent(AppComponent);
23 | fixture.detectChanges();
24 | const compiled = fixture.debugElement.nativeElement;
25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to AdalAngular6-client!');
26 | }));
27 | });
28 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'app';
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppComponent } from './app.component';
5 |
6 | @NgModule({
7 | declarations: [
8 | AppComponent
9 | ],
10 | imports: [
11 | BrowserModule
12 | ],
13 | providers: [],
14 | bootstrap: [AppComponent]
15 | })
16 | export class AppModule { }
17 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manishrasrani/ms-adal-angular6/c9ffd527f3c6a92bc90020f35ccff93f8102492f/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/browserslist:
--------------------------------------------------------------------------------
1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed
5 | > 0.5%
6 | last 2 versions
7 | Firefox ESR
8 | not dead
9 | # IE 9-11
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * In development mode, to ignore zone related error stack frames such as
11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
12 | * import the following file, but please comment it out in production mode
13 | * because it will have performance impact when throw error
14 | */
15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
16 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manishrasrani/ms-adal-angular6/c9ffd527f3c6a92bc90020f35ccff93f8102492f/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AdalAngular6Client
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../coverage'),
20 | reports: ['html', 'lcovonly'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.log(err));
13 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
39 |
40 | /** IE10 and IE11 requires the following for the Reflect API. */
41 | // import 'core-js/es6/reflect';
42 |
43 |
44 | /** Evergreen browsers require these. **/
45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46 | import 'core-js/es7/reflect';
47 |
48 |
49 | /**
50 | * Web Animations `@angular/platform-browser/animations`
51 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
52 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
53 | **/
54 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
55 |
56 | /**
57 | * By default, zone.js will patch all possible macroTask and DomEvents
58 | * user can disable parts of macroTask/DomEvents patch by setting following flags
59 | */
60 |
61 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
62 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
63 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
64 |
65 | /*
66 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
67 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
68 | */
69 | // (window as any).__Zone_enable_cross_context_check = true;
70 |
71 | /***************************************************************************************************
72 | * Zone JS is required by default for Angular itself.
73 | */
74 | import 'zone.js/dist/zone'; // Included with Angular CLI.
75 |
76 |
77 |
78 | /***************************************************************************************************
79 | * APPLICATION IMPORTS
80 | */
81 |
--------------------------------------------------------------------------------
/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "types": []
7 | },
8 | "exclude": [
9 | "src/test.ts",
10 | "**/*.spec.ts"
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "types": [
7 | "jasmine",
8 | "node"
9 | ]
10 | },
11 | "files": [
12 | "test.ts",
13 | "polyfills.ts"
14 | ],
15 | "include": [
16 | "**/*.spec.ts",
17 | "**/*.d.ts"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/src/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "app",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "app",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2017",
17 | "dom"
18 | ],
19 | "paths": {
20 | "ms-adal-angular6": [
21 | "dist/ms-adal-angular6"
22 | ]
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs/Rx"
22 | ],
23 | "import-spacing": true,
24 | "indent": [
25 | true,
26 | "spaces"
27 | ],
28 | "interface-over-type-literal": true,
29 | "label-position": true,
30 | "max-line-length": [
31 | true,
32 | 140
33 | ],
34 | "member-access": false,
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-arg": true,
47 | "no-bitwise": true,
48 | "no-console": [
49 | true,
50 | "debug",
51 | "info",
52 | "time",
53 | "timeEnd",
54 | "trace"
55 | ],
56 | "no-construct": true,
57 | "no-debugger": true,
58 | "no-duplicate-super": true,
59 | "no-empty": false,
60 | "no-empty-interface": true,
61 | "no-eval": true,
62 | "no-inferrable-types": [
63 | true,
64 | "ignore-params"
65 | ],
66 | "no-misused-new": true,
67 | "no-non-null-assertion": true,
68 | "no-shadowed-variable": true,
69 | "no-string-literal": false,
70 | "no-string-throw": true,
71 | "no-switch-case-fall-through": true,
72 | "no-trailing-whitespace": true,
73 | "no-unnecessary-initializer": true,
74 | "no-unused-expression": true,
75 | "no-use-before-declare": true,
76 | "no-var-keyword": true,
77 | "object-literal-sort-keys": false,
78 | "one-line": [
79 | true,
80 | "check-open-brace",
81 | "check-catch",
82 | "check-else",
83 | "check-whitespace"
84 | ],
85 | "prefer-const": true,
86 | "quotemark": [
87 | true,
88 | "single"
89 | ],
90 | "radix": true,
91 | "semicolon": [
92 | true,
93 | "always"
94 | ],
95 | "triple-equals": [
96 | true,
97 | "allow-null-check"
98 | ],
99 | "typedef-whitespace": [
100 | true,
101 | {
102 | "call-signature": "nospace",
103 | "index-signature": "nospace",
104 | "parameter": "nospace",
105 | "property-declaration": "nospace",
106 | "variable-declaration": "nospace"
107 | }
108 | ],
109 | "unified-signatures": true,
110 | "variable-name": false,
111 | "whitespace": [
112 | true,
113 | "check-branch",
114 | "check-decl",
115 | "check-operator",
116 | "check-separator",
117 | "check-type"
118 | ],
119 | "no-output-on-prefix": true,
120 | "use-input-property-decorator": true,
121 | "use-output-property-decorator": true,
122 | "use-host-property-decorator": true,
123 | "no-input-rename": true,
124 | "no-output-rename": true,
125 | "use-life-cycle-interface": true,
126 | "use-pipe-transform-interface": true,
127 | "component-class-suffix": true,
128 | "directive-class-suffix": true
129 | }
130 | }
131 |
--------------------------------------------------------------------------------