@meshmakers/shared-auth 0.0.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/esm2020/lib/authorize.guard.mjs +24 -0
- package/esm2020/lib/authorize.interceptor.mjs +60 -0
- package/esm2020/lib/authorize.service.mjs +110 -0
- package/esm2020/lib/login-menu/login-menu.component.mjs +35 -0
- package/esm2020/lib/shared-auth.module.mjs +44 -0
- package/esm2020/meshmakers-shared-auth.mjs +5 -0
- package/esm2020/public-api.mjs +9 -0
- package/fesm2015/meshmakers-shared-auth.mjs +269 -0
- package/fesm2015/meshmakers-shared-auth.mjs.map +1 -0
- package/fesm2020/meshmakers-shared-auth.mjs +267 -0
- package/fesm2020/meshmakers-shared-auth.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/authorize.guard.d.ts +11 -0
- package/lib/authorize.interceptor.d.ts +15 -0
- package/lib/authorize.service.d.ts +39 -0
- package/lib/login-menu/login-menu.component.d.ts +17 -0
- package/lib/shared-auth.module.d.ts +13 -0
- package/package.json +27 -0
- package/public-api.d.ts +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# SharedAuth
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.1.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project shared-auth` to generate a new component. You can also
|
|
8
|
+
use `ng generate directive|pipe|service|class|guard|interface|enum|module --project shared-auth`.
|
|
9
|
+
> Note: Don't forget to add `--project shared-auth` or else it will be added to the default project in
|
|
10
|
+
> your `angular.json` file.
|
|
11
|
+
|
|
12
|
+
## Build
|
|
13
|
+
|
|
14
|
+
Run `ng build shared-auth` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
15
|
+
|
|
16
|
+
## Publishing
|
|
17
|
+
|
|
18
|
+
After building your library with `ng build shared-auth`, go to the dist folder `cd dist/shared-auth` and
|
|
19
|
+
run `npm publish`.
|
|
20
|
+
|
|
21
|
+
## Running unit tests
|
|
22
|
+
|
|
23
|
+
Run `ng test shared-auth` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
24
|
+
|
|
25
|
+
## Further help
|
|
26
|
+
|
|
27
|
+
To get more help on the Angular CLI use `ng help` or go check out
|
|
28
|
+
the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { tap } from 'rxjs/operators';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "./authorize.service";
|
|
5
|
+
export class AuthorizeGuard {
|
|
6
|
+
constructor(authorize) {
|
|
7
|
+
this.authorize = authorize;
|
|
8
|
+
}
|
|
9
|
+
canActivate(_next, state) {
|
|
10
|
+
return this.authorize.getIsAuthenticated()
|
|
11
|
+
.pipe(tap(isAuthenticated => this.handleAuthorization(isAuthenticated)));
|
|
12
|
+
}
|
|
13
|
+
handleAuthorization(isAuthenticated) {
|
|
14
|
+
if (!isAuthenticated) {
|
|
15
|
+
this.authorize.login();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
AuthorizeGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeGuard, deps: [{ token: i1.AuthorizeService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
20
|
+
AuthorizeGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeGuard });
|
|
21
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeGuard, decorators: [{
|
|
22
|
+
type: Injectable
|
|
23
|
+
}], ctorParameters: function () { return [{ type: i1.AuthorizeService }]; } });
|
|
24
|
+
//#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0ZXJTdGF0ZVNuYXBzaG90fSBmcm9tICdAYW5ndWxhci9yb3V0ZXInO1xuaW1wb3J0IHtBdXRob3JpemVTZXJ2aWNlfSBmcm9tICcuL2F1dGhvcml6ZS5zZXJ2aWNlJztcbmltcG9ydCB7dGFwfSBmcm9tICdyeGpzL29wZXJhdG9ycyc7XG5cbkBJbmplY3RhYmxlKClcbmV4cG9ydCBjbGFzcyBBdXRob3JpemVHdWFyZCBpbXBsZW1lbnRzIENhbkFjdGl2YXRlIHtcbiAgY29uc3RydWN0b3IocHJpdmF0ZSBhdXRob3JpemU6IEF1dGhvcml6ZVNlcnZpY2UpIHtcbiAgfVxuXG4gIGNhbkFjdGl2YXRlKFxuICAgIF9uZXh0OiBBY3RpdmF0ZWRSb3V0ZVNuYXBzaG90LFxuICAgIHN0YXRlOiBSb3V0ZXJTdGF0ZVNuYXBzaG90KTogYW55IHtcbiAgICByZXR1cm4gdGhpcy5hdXRob3JpemUuZ2V0SXNBdXRoZW50aWNhdGVkKClcbiAgICAgIC5waXBlKHRhcChpc0F1dGhlbnRpY2F0ZWQgPT4gdGhpcy5oYW5kbGVBdXRob3JpemF0aW9uKGlzQXV0aGVudGljYXRlZCkpKTtcbiAgfVxuXG4gIHByaXZhdGUgaGFuZGxlQXV0aG9yaXphdGlvbihpc0F1dGhlbnRpY2F0ZWQ6IGJvb2xlYW4pIHtcbiAgICBpZiAoIWlzQXV0aGVudGljYXRlZCkge1xuICAgICAgdGhpcy5hdXRob3JpemUubG9naW4oKTtcbiAgICB9XG4gIH1cbn1cbiJdfQ==
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import * as i1 from "./authorize.service";
|
|
4
|
+
export class AuthorizeInterceptor {
|
|
5
|
+
constructor(authorize) {
|
|
6
|
+
this.authorize = authorize;
|
|
7
|
+
authorize.getAccessToken().subscribe(value => this.accessToken = value);
|
|
8
|
+
}
|
|
9
|
+
static isSameOriginUrl(req) {
|
|
10
|
+
// It's an absolute url with the same origin.
|
|
11
|
+
if (req.url.startsWith(`${window.location.origin}/`)) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
// It's a protocol relative url with the same origin.
|
|
15
|
+
// For example: //www.example.com/api/Products
|
|
16
|
+
if (req.url.startsWith(`//${window.location.host}/`)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
// It's a relative url like /api/Products
|
|
20
|
+
if (/^\/[^\/].*/.test(req.url)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
// It's an absolute or protocol relative url that
|
|
24
|
+
// doesn't have the same origin.
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
// Checks if there is an access_token available in the authorize service
|
|
28
|
+
// and adds it to the request in case it's targeted at the same origin as the
|
|
29
|
+
intercept(req, next) {
|
|
30
|
+
return this.processRequestWithToken(this.accessToken, req, next);
|
|
31
|
+
}
|
|
32
|
+
// single page application.
|
|
33
|
+
processRequestWithToken(token, req, next) {
|
|
34
|
+
if (!!token && (AuthorizeInterceptor.isSameOriginUrl(req) || this.isKnownServiceUri(req))) {
|
|
35
|
+
req = req.clone({
|
|
36
|
+
setHeaders: {
|
|
37
|
+
Authorization: `Bearer ${token}`
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return next.handle(req);
|
|
42
|
+
}
|
|
43
|
+
isKnownServiceUri(req) {
|
|
44
|
+
const serviceUris = this.authorize.getServiceUris();
|
|
45
|
+
for (let i = 0; i < serviceUris.length; i++) {
|
|
46
|
+
if (req.url.startsWith(`${serviceUris[i]}`)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// It's an absolute or protocol relative url that
|
|
51
|
+
// doesn't have the same origin.
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
AuthorizeInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeInterceptor, deps: [{ token: i1.AuthorizeService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
56
|
+
AuthorizeInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeInterceptor });
|
|
57
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeInterceptor, decorators: [{
|
|
58
|
+
type: Injectable
|
|
59
|
+
}], ctorParameters: function () { return [{ type: i1.AuthorizeService }]; } });
|
|
60
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXplLmludGVyY2VwdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvbWVzaG1ha2Vycy9zaGFyZWQtYXV0aC9zcmMvbGliL2F1dGhvcml6ZS5pbnRlcmNlcHRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUMsVUFBVSxFQUFDLE1BQU0sZUFBZSxDQUFDOzs7QUFNekMsTUFBTSxPQUFPLG9CQUFvQjtJQUkvQixZQUFvQixTQUEyQjtRQUEzQixjQUFTLEdBQVQsU0FBUyxDQUFrQjtRQUU3QyxTQUFTLENBQUMsY0FBYyxFQUFFLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLFdBQVcsR0FBRyxLQUFLLENBQUMsQ0FBQztJQUUxRSxDQUFDO0lBRU8sTUFBTSxDQUFDLGVBQWUsQ0FBQyxHQUFRO1FBQ3JDLDZDQUE2QztRQUM3QyxJQUFJLEdBQUcsQ0FBQyxHQUFHLENBQUMsVUFBVSxDQUFDLEdBQUcsTUFBTSxDQUFDLFFBQVEsQ0FBQyxNQUFN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cnRzV2l0aChgJHtzZXJ2aWNlVXJpc1tpXX1gKSkge1xuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgIH1cbiAgICB9XG5cbiAgICAvLyBJdCdzIGFuIGFic29sdXRlIG9yIHByb3RvY29sIHJlbGF0aXZlIHVybCB0aGF0XG4gICAgLy8gZG9lc24ndCBoYXZlIHRoZSBzYW1lIG9yaWdpbi5cbiAgICByZXR1cm4gZmFsc2U7XG4gIH1cbn1cbiJdfQ==
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@angular/core';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { filter } from 'rxjs/operators';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import * as i1 from "angular-oauth2-oidc";
|
|
6
|
+
export class AuthorizeOptions {
|
|
7
|
+
}
|
|
8
|
+
export class AuthorizeService {
|
|
9
|
+
constructor(authorizeOptions, oauthService) {
|
|
10
|
+
this.authorizeOptions = authorizeOptions;
|
|
11
|
+
this.oauthService = oauthService;
|
|
12
|
+
this.isAuthenticated = new BehaviorSubject(false);
|
|
13
|
+
this.isAdmin = new BehaviorSubject(false);
|
|
14
|
+
this.authority = new BehaviorSubject(null);
|
|
15
|
+
this.accessToken = new BehaviorSubject(null);
|
|
16
|
+
this.user = new BehaviorSubject(null);
|
|
17
|
+
console.debug("AuthorizeService::created");
|
|
18
|
+
this.getUser().subscribe(s => {
|
|
19
|
+
this.isAuthenticated.next(!!s);
|
|
20
|
+
this.isAdmin.next(!!s && s.role === "Administrators");
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
getServiceUris() {
|
|
24
|
+
return this.authorizeOptions.wellKnownServiceUris;
|
|
25
|
+
}
|
|
26
|
+
getAuthority() {
|
|
27
|
+
return this.authority;
|
|
28
|
+
}
|
|
29
|
+
getIsAuthenticated() {
|
|
30
|
+
return this.isAuthenticated;
|
|
31
|
+
}
|
|
32
|
+
getIsAdmin() {
|
|
33
|
+
return this.isAdmin;
|
|
34
|
+
}
|
|
35
|
+
getAccessToken() {
|
|
36
|
+
return this.accessToken;
|
|
37
|
+
}
|
|
38
|
+
getUser() {
|
|
39
|
+
return this.user;
|
|
40
|
+
}
|
|
41
|
+
login() {
|
|
42
|
+
this.oauthService.initImplicitFlow();
|
|
43
|
+
}
|
|
44
|
+
logout() {
|
|
45
|
+
this.oauthService.logOut(false);
|
|
46
|
+
}
|
|
47
|
+
initialize() {
|
|
48
|
+
console.debug("AuthorizeService::initialize::started");
|
|
49
|
+
const config = {
|
|
50
|
+
responseType: 'code',
|
|
51
|
+
issuer: this.authorizeOptions.issuer,
|
|
52
|
+
redirectUri: this.authorizeOptions.redirectUri,
|
|
53
|
+
postLogoutRedirectUri: this.authorizeOptions.postLogoutRedirectUri,
|
|
54
|
+
clientId: this.authorizeOptions.clientId,
|
|
55
|
+
scope: this.authorizeOptions.scope,
|
|
56
|
+
showDebugInformation: this.authorizeOptions.showDebugInformation,
|
|
57
|
+
sessionChecksEnabled: this.authorizeOptions.sessionChecksEnabled
|
|
58
|
+
};
|
|
59
|
+
this.oauthService.configure(config);
|
|
60
|
+
this.oauthService.setStorage(localStorage);
|
|
61
|
+
this.oauthService.loadDiscoveryDocumentAndTryLogin();
|
|
62
|
+
this.oauthService.setupAutomaticSilentRefresh();
|
|
63
|
+
this.oauthService.events.subscribe(e => {
|
|
64
|
+
// tslint:disable-next-line:no-console
|
|
65
|
+
console.debug('oauth/oidc event', e);
|
|
66
|
+
});
|
|
67
|
+
this.oauthService.events
|
|
68
|
+
.pipe(filter(e => e.type === 'session_terminated'))
|
|
69
|
+
.subscribe(e => {
|
|
70
|
+
// tslint:disable-next-line:no-console
|
|
71
|
+
console.debug('Your session has been terminated!');
|
|
72
|
+
});
|
|
73
|
+
this.oauthService.events
|
|
74
|
+
.pipe(filter(e => e.type === 'token_received'))
|
|
75
|
+
.subscribe(e => {
|
|
76
|
+
this.loadUser();
|
|
77
|
+
});
|
|
78
|
+
this.oauthService.events
|
|
79
|
+
.pipe(filter(e => e.type === 'logout'))
|
|
80
|
+
.subscribe(e => {
|
|
81
|
+
this.accessToken.next(null);
|
|
82
|
+
this.user.next(null);
|
|
83
|
+
});
|
|
84
|
+
if (this.oauthService.hasValidAccessToken()) {
|
|
85
|
+
this.loadUser();
|
|
86
|
+
}
|
|
87
|
+
this.authority.next(this.authorizeOptions.issuer);
|
|
88
|
+
console.debug("AuthorizeService::initialize::done");
|
|
89
|
+
}
|
|
90
|
+
loadUser() {
|
|
91
|
+
const claims = this.oauthService.getIdentityClaims();
|
|
92
|
+
if (!claims) {
|
|
93
|
+
console.error("claims where null when loading identity claims");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const user = claims;
|
|
97
|
+
const accessToken = this.oauthService.getAccessToken();
|
|
98
|
+
this.user.next(user);
|
|
99
|
+
this.accessToken.next(accessToken);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
AuthorizeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeService, deps: [{ token: AuthorizeOptions }, { token: i1.OAuthService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
103
|
+
AuthorizeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeService });
|
|
104
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeService, decorators: [{
|
|
105
|
+
type: Injectable
|
|
106
|
+
}], ctorParameters: function () { return [{ type: AuthorizeOptions, decorators: [{
|
|
107
|
+
type: Inject,
|
|
108
|
+
args: [AuthorizeOptions]
|
|
109
|
+
}] }, { type: i1.OAuthService }]; } });
|
|
110
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXplLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiw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jcmliZShlID0+IHtcbiAgICAgICAgdGhpcy5hY2Nlc3NUb2tlbi5uZXh0KG51bGwpO1xuICAgICAgICB0aGlzLnVzZXIubmV4dChudWxsKTtcbiAgICAgIH0pO1xuXG4gICAgaWYgKHRoaXMub2F1dGhTZXJ2aWNlLmhhc1ZhbGlkQWNjZXNzVG9rZW4oKSkge1xuICAgICAgdGhpcy5sb2FkVXNlcigpO1xuICAgIH1cblxuICAgIHRoaXMuYXV0aG9yaXR5Lm5leHQodGhpcy5hdXRob3JpemVPcHRpb25zLmlzc3Vlcik7XG5cbiAgICBjb25zb2xlLmRlYnVnKFwiQXV0aG9yaXplU2VydmljZTo6aW5pdGlhbGl6ZTo6ZG9uZVwiKTtcblxuICB9XG5cbiAgcHJpdmF0ZSBsb2FkVXNlcigpIHtcbiAgICBjb25zdCBjbGFpbXMgPSB0aGlzLm9hdXRoU2VydmljZS5nZXRJZGVudGl0eUNsYWltcygpO1xuICAgIGlmICghY2xhaW1zKSB7XG4gICAgICBjb25zb2xlLmVycm9yKFwiY2xhaW1zIHdoZXJlIG51bGwgd2hlbiBsb2FkaW5nIGlkZW50aXR5IGNsYWltc1wiKTtcbiAgICAgIHJldHVybjtcbiAgICB9XG5cbiAgICBjb25zdCB1c2VyID0gPElVc2VyPmNsYWltcztcbiAgICBjb25zdCBhY2Nlc3NUb2tlbiA9IHRoaXMub2F1dGhTZXJ2aWNlLmdldEFjY2Vzc1Rva2VuKCk7XG4gICAgdGhpcy51c2VyLm5leHQodXNlcik7XG4gICAgdGhpcy5hY2Nlc3NUb2tlbi5uZXh0KGFjY2Vzc1Rva2VuKTtcbiAgfVxufVxuIl19
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { map } from 'rxjs/operators';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "../authorize.service";
|
|
5
|
+
import * as i2 from "@angular/common";
|
|
6
|
+
export class LoginMenuComponent {
|
|
7
|
+
constructor(authorizeService) {
|
|
8
|
+
this.authorizeService = authorizeService;
|
|
9
|
+
}
|
|
10
|
+
ngOnInit() {
|
|
11
|
+
const isIFrame = window.self !== window.top;
|
|
12
|
+
console.log("app-login-menu::created");
|
|
13
|
+
this.isAuthenticated = this.authorizeService.getIsAuthenticated();
|
|
14
|
+
this.userName = this.authorizeService.getUser().pipe(map(u => u && u.name));
|
|
15
|
+
this.isAdmin = this.authorizeService.getIsAdmin();
|
|
16
|
+
this.isAuthenticated.subscribe(x => {
|
|
17
|
+
console.log(`isAuthenticated changed to ${x} (iframe ${isIFrame})`);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
login() {
|
|
21
|
+
this.authorizeService.login();
|
|
22
|
+
}
|
|
23
|
+
logout() {
|
|
24
|
+
this.authorizeService.logout();
|
|
25
|
+
}
|
|
26
|
+
register() {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
LoginMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: LoginMenuComponent, deps: [{ token: i1.AuthorizeService }], target: i0.ɵɵFactoryTarget.Component });
|
|
30
|
+
LoginMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.2", type: LoginMenuComponent, selector: "app-login-menu", ngImport: i0, template: "<ul *ngIf=\"isAuthenticated | async\" class=\"navbar-nav\">\n <li class=\"nav-item dropdown\">\n <a aria-expanded=\"false\" aria-haspopup=\"true\" class=\"nav-link dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\"\n id=\"navbarDropdownLogin\" role=\"button\">\n {{ userName | async }} <b class=\"caret\"></b>\n </a>\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Grants\">Client Application Access</a>-->\n <!--<a class=\"dropdown-item\" [routerLink]='[\"/authentication/profile\"]' title=\"Manage\">Manage</a>-->\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Diagnostics\">Diagnostics</a>-->\n <div class=\"dropdown-divider\"></div>\n <a (click)='logout()' class=\"dropdown-item\" routerLink=\"\" title=\"Logout\">Logout</a>\n </div>\n </li>\n</ul>\n<ul *ngIf=\"!(isAuthenticated | async)\" class=\"navbar-nav\">\n <li class=\"nav-item\">\n <a (click)='register()' class=\"nav-link\" routerLink=\"\">Register</a>\n </li>\n <li class=\"nav-item\">\n <a (click)='login()' class=\"nav-link\" routerLink=\"\">Login</a>\n </li>\n</ul>\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }] });
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: LoginMenuComponent, decorators: [{
|
|
32
|
+
type: Component,
|
|
33
|
+
args: [{ selector: 'app-login-menu', template: "<ul *ngIf=\"isAuthenticated | async\" class=\"navbar-nav\">\n <li class=\"nav-item dropdown\">\n <a aria-expanded=\"false\" aria-haspopup=\"true\" class=\"nav-link dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\"\n id=\"navbarDropdownLogin\" role=\"button\">\n {{ userName | async }} <b class=\"caret\"></b>\n </a>\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Grants\">Client Application Access</a>-->\n <!--<a class=\"dropdown-item\" [routerLink]='[\"/authentication/profile\"]' title=\"Manage\">Manage</a>-->\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Diagnostics\">Diagnostics</a>-->\n <div class=\"dropdown-divider\"></div>\n <a (click)='logout()' class=\"dropdown-item\" routerLink=\"\" title=\"Logout\">Logout</a>\n </div>\n </li>\n</ul>\n<ul *ngIf=\"!(isAuthenticated | async)\" class=\"navbar-nav\">\n <li class=\"nav-item\">\n <a (click)='register()' class=\"nav-link\" routerLink=\"\">Register</a>\n </li>\n <li class=\"nav-item\">\n <a (click)='login()' class=\"nav-link\" routerLink=\"\">Login</a>\n </li>\n</ul>\n" }]
|
|
34
|
+
}], ctorParameters: function () { return [{ type: i1.AuthorizeService }]; } });
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9naW4tbWVudS5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9tZXNobWFrZXJzL3NoYXJlZC1hdXRoL3NyYy9saWIvbG9naW4tbWVudS9sb2dpbi1tZW51LmNvbXBvbmVudC50cyIsIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL21lc2htYWtlcnMvc2hhcmVkLWF1dGgvc3JjL2xpYi9sb2dpbi1tZW51L2xvZ2luLW1lbnUuY29tcG9uZW50Lmh0bWwiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFDLFNBQVMsRUFBUyxNQUFNLGVBQWUsQ0FBQztBQUdoRCxPQUFPLEVBQUMsR0FBRyxFQUFDLE1BQU0sZ0JBQWdCLENBQUM7Ozs7QUFPbkMsTUFBTSxPQUFPLGtCQUFrQjtJQUs3QixZQUFvQixnQkFBa0M7UUFBbEMscUJBQWdCLEdBQWhCLGdCQUFnQixDQUFrQjtJQUN0RCxDQUFDO0lBRUQsUUFBUTtRQUNOLE1BQU0sUUFBUSxHQUFHLE1BQU0sQ0FBQyxJQUFJLEtBQUssTUFBTSxDQUFDLEdBQUcsQ0FBQztRQUU1QyxPQUFPLENBQUMsR0FBRyxDQUFDLHlCQUF5QixDQUFDLENBQUM7UUFFdkMsSUFBSSxDQUFDLGVBQWUsR0FBRyxJQUFJLENBQUMs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PCEtLTxhIGNsYXNzPVwiZHJvcGRvd24taXRlbVwiIFtyb3V0ZXJMaW5rXT0nW1wiL2F1dGhlbnRpY2F0aW9uL3Byb2ZpbGVcIl0nIHRpdGxlPVwiTWFuYWdlXCI+TWFuYWdlPC9hPi0tPlxuICAgICAgPCEtLTxhIGNsYXNzPVwiZHJvcGRvd24taXRlbVwiIGFzcC1hY3Rpb249XCJJbmRleFwiIGFzcC1hcmVhPVwiQXV0aGVudGljYXRpb25cIiBhc3AtY29udHJvbGxlcj1cIkRpYWdub3N0aWNzXCI+RGlhZ25vc3RpY3M8L2E+LS0+XG4gICAgICA8ZGl2IGNsYXNzPVwiZHJvcGRvd24tZGl2aWRlclwiPjwvZGl2PlxuICAgICAgPGEgKGNsaWNrKT0nbG9nb3V0KCknIGNsYXNzPVwiZHJvcGRvd24taXRlbVwiIHJvdXRlckxpbms9XCJcIiB0aXRsZT1cIkxvZ291dFwiPkxvZ291dDwvYT5cbiAgICA8L2Rpdj5cbiAgPC9saT5cbjwvdWw+XG48dWwgKm5nSWY9XCIhKGlzQXV0aGVudGljYXRlZCB8IGFzeW5jKVwiIGNsYXNzPVwibmF2YmFyLW5hdlwiPlxuICA8bGkgY2xhc3M9XCJuYXYtaXRlbVwiPlxuICAgIDxhIChjbGljayk9J3JlZ2lzdGVyKCknIGNsYXNzPVwibmF2LWxpbmtcIiByb3V0ZXJMaW5rPVwiXCI+UmVnaXN0ZXI8L2E+XG4gIDwvbGk+XG4gIDxsaSBjbGFzcz1cIm5hdi1pdGVtXCI+XG4gICAgPGEgKGNsaWNrKT0nbG9naW4oKScgY2xhc3M9XCJuYXYtbGlua1wiIHJvdXRlckxpbms9XCJcIj5Mb2dpbjwvYT5cbiAgPC9saT5cbjwvdWw+XG4iXX0=
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from "@angular/common";
|
|
3
|
+
import { HttpClientModule } from "@angular/common/http";
|
|
4
|
+
import { LoginMenuComponent } from "./login-menu/login-menu.component";
|
|
5
|
+
import { AuthorizeOptions, AuthorizeService } from "./authorize.service";
|
|
6
|
+
import { OAuthModule } from "angular-oauth2-oidc";
|
|
7
|
+
import { AuthorizeGuard } from "./authorize.guard";
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
import * as i1 from "angular-oauth2-oidc";
|
|
10
|
+
export class SharedAuthModule {
|
|
11
|
+
static forRoot(authorizeOptions) {
|
|
12
|
+
return {
|
|
13
|
+
ngModule: SharedAuthModule,
|
|
14
|
+
providers: [
|
|
15
|
+
{
|
|
16
|
+
provide: AuthorizeOptions,
|
|
17
|
+
useValue: authorizeOptions
|
|
18
|
+
},
|
|
19
|
+
AuthorizeService,
|
|
20
|
+
AuthorizeGuard
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
SharedAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
26
|
+
SharedAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, declarations: [LoginMenuComponent], imports: [CommonModule,
|
|
27
|
+
HttpClientModule, i1.OAuthModule], exports: [LoginMenuComponent] });
|
|
28
|
+
SharedAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, imports: [CommonModule,
|
|
29
|
+
HttpClientModule,
|
|
30
|
+
OAuthModule.forRoot()] });
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, decorators: [{
|
|
32
|
+
type: NgModule,
|
|
33
|
+
args: [{
|
|
34
|
+
declarations: [LoginMenuComponent],
|
|
35
|
+
exports: [LoginMenuComponent],
|
|
36
|
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JpemVHdWFyZH0gZnJvbSBcIi4vYXV0aG9yaXplLmd1YXJkXCI7XG5cbkBOZ01vZHVsZSh7XG4gIGRlY2xhcmF0aW9uczogW0xvZ2luTWVudUNvbXBvbmVudF0sXG4gIGV4cG9ydHM6IFtMb2dpbk1lbnVDb21wb25lbnRdLFxuICBwcm92aWRlcnM6IFtdLFxuICBpbXBvcnRzOiBbXG4gICAgQ29tbW9uTW9kdWxlLFxuICAgIEh0dHBDbGllbnRNb2R1bGUsXG4gICAgT0F1dGhNb2R1bGUuZm9yUm9vdCgpXG4gIF1cbn0pXG5leHBvcnQgY2xhc3MgU2hhcmVkQXV0aE1vZHVsZSB7XG4gIHN0YXRpYyBmb3JSb290KGF1dGhvcml6ZU9wdGlvbnM6IEF1dGhvcml6ZU9wdGlvbnMpOiBNb2R1bGVXaXRoUHJvdmlkZXJzPFNoYXJlZEF1dGhNb2R1bGU+IHtcbiAgICByZXR1cm4ge1xuICAgICAgbmdNb2R1bGU6IFNoYXJlZEF1dGhNb2R1bGUsXG4gICAgICBwcm92aWRlcnM6IFtcbiAgICAgICAge1xuICAgICAgICAgIHByb3ZpZGU6IEF1dGhvcml6ZU9wdGlvbnMsXG4gICAgICAgICAgdXNlVmFsdWU6IGF1dGhvcml6ZU9wdGlvbnNcbiAgICAgICAgfSxcbiAgICAgICAgQXV0aG9yaXplU2VydmljZSxcbiAgICAgICAgQXV0aG9yaXplR3VhcmRcbiAgICAgIF1cbiAgICB9XG4gIH1cbn1cbiJdfQ==
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './public-api';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVzaG1ha2Vycy1zaGFyZWQtYXV0aC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL21lc2htYWtlcnMvc2hhcmVkLWF1dGgvc3JjL21lc2htYWtlcnMtc2hhcmVkLWF1dGgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGNBQWMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcbiJdfQ==
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of shared-auth
|
|
3
|
+
*/
|
|
4
|
+
export * from './lib/authorize.service';
|
|
5
|
+
export * from './lib/login-menu/login-menu.component';
|
|
6
|
+
export * from './lib/shared-auth.module';
|
|
7
|
+
export * from './lib/authorize.interceptor';
|
|
8
|
+
export * from './lib/authorize.guard';
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL21lc2htYWtlcnMvc2hhcmVkLWF1dGgvc3JjL3B1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLHlCQUF5QixDQUFDO0FBQ3hDLGNBQWMsdUNBQXVDLENBQUM7QUFDdEQsY0FBYywwQkFBMEIsQ0FBQztBQUN6QyxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMsdUJBQXVCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogUHVibGljIEFQSSBTdXJmYWNlIG9mIHNoYXJlZC1hdXRoXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9saWIvYXV0aG9yaXplLnNlcnZpY2UnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvbG9naW4tbWVudS9sb2dpbi1tZW51LmNvbXBvbmVudCc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9zaGFyZWQtYXV0aC5tb2R1bGUnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvYXV0aG9yaXplLmludGVyY2VwdG9yJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL2F1dGhvcml6ZS5ndWFyZCc7XG4iXX0=
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Inject, Component, NgModule } from '@angular/core';
|
|
3
|
+
import { BehaviorSubject } from 'rxjs';
|
|
4
|
+
import { filter, map, tap } from 'rxjs/operators';
|
|
5
|
+
import * as i1 from 'angular-oauth2-oidc';
|
|
6
|
+
import { OAuthModule } from 'angular-oauth2-oidc';
|
|
7
|
+
import * as i2 from '@angular/common';
|
|
8
|
+
import { CommonModule } from '@angular/common';
|
|
9
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
10
|
+
|
|
11
|
+
class AuthorizeOptions {
|
|
12
|
+
}
|
|
13
|
+
class AuthorizeService {
|
|
14
|
+
constructor(authorizeOptions, oauthService) {
|
|
15
|
+
this.authorizeOptions = authorizeOptions;
|
|
16
|
+
this.oauthService = oauthService;
|
|
17
|
+
this.isAuthenticated = new BehaviorSubject(false);
|
|
18
|
+
this.isAdmin = new BehaviorSubject(false);
|
|
19
|
+
this.authority = new BehaviorSubject(null);
|
|
20
|
+
this.accessToken = new BehaviorSubject(null);
|
|
21
|
+
this.user = new BehaviorSubject(null);
|
|
22
|
+
console.debug("AuthorizeService::created");
|
|
23
|
+
this.getUser().subscribe(s => {
|
|
24
|
+
this.isAuthenticated.next(!!s);
|
|
25
|
+
this.isAdmin.next(!!s && s.role === "Administrators");
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getServiceUris() {
|
|
29
|
+
return this.authorizeOptions.wellKnownServiceUris;
|
|
30
|
+
}
|
|
31
|
+
getAuthority() {
|
|
32
|
+
return this.authority;
|
|
33
|
+
}
|
|
34
|
+
getIsAuthenticated() {
|
|
35
|
+
return this.isAuthenticated;
|
|
36
|
+
}
|
|
37
|
+
getIsAdmin() {
|
|
38
|
+
return this.isAdmin;
|
|
39
|
+
}
|
|
40
|
+
getAccessToken() {
|
|
41
|
+
return this.accessToken;
|
|
42
|
+
}
|
|
43
|
+
getUser() {
|
|
44
|
+
return this.user;
|
|
45
|
+
}
|
|
46
|
+
login() {
|
|
47
|
+
this.oauthService.initImplicitFlow();
|
|
48
|
+
}
|
|
49
|
+
logout() {
|
|
50
|
+
this.oauthService.logOut(false);
|
|
51
|
+
}
|
|
52
|
+
initialize() {
|
|
53
|
+
console.debug("AuthorizeService::initialize::started");
|
|
54
|
+
const config = {
|
|
55
|
+
responseType: 'code',
|
|
56
|
+
issuer: this.authorizeOptions.issuer,
|
|
57
|
+
redirectUri: this.authorizeOptions.redirectUri,
|
|
58
|
+
postLogoutRedirectUri: this.authorizeOptions.postLogoutRedirectUri,
|
|
59
|
+
clientId: this.authorizeOptions.clientId,
|
|
60
|
+
scope: this.authorizeOptions.scope,
|
|
61
|
+
showDebugInformation: this.authorizeOptions.showDebugInformation,
|
|
62
|
+
sessionChecksEnabled: this.authorizeOptions.sessionChecksEnabled
|
|
63
|
+
};
|
|
64
|
+
this.oauthService.configure(config);
|
|
65
|
+
this.oauthService.setStorage(localStorage);
|
|
66
|
+
this.oauthService.loadDiscoveryDocumentAndTryLogin();
|
|
67
|
+
this.oauthService.setupAutomaticSilentRefresh();
|
|
68
|
+
this.oauthService.events.subscribe(e => {
|
|
69
|
+
// tslint:disable-next-line:no-console
|
|
70
|
+
console.debug('oauth/oidc event', e);
|
|
71
|
+
});
|
|
72
|
+
this.oauthService.events
|
|
73
|
+
.pipe(filter(e => e.type === 'session_terminated'))
|
|
74
|
+
.subscribe(e => {
|
|
75
|
+
// tslint:disable-next-line:no-console
|
|
76
|
+
console.debug('Your session has been terminated!');
|
|
77
|
+
});
|
|
78
|
+
this.oauthService.events
|
|
79
|
+
.pipe(filter(e => e.type === 'token_received'))
|
|
80
|
+
.subscribe(e => {
|
|
81
|
+
this.loadUser();
|
|
82
|
+
});
|
|
83
|
+
this.oauthService.events
|
|
84
|
+
.pipe(filter(e => e.type === 'logout'))
|
|
85
|
+
.subscribe(e => {
|
|
86
|
+
this.accessToken.next(null);
|
|
87
|
+
this.user.next(null);
|
|
88
|
+
});
|
|
89
|
+
if (this.oauthService.hasValidAccessToken()) {
|
|
90
|
+
this.loadUser();
|
|
91
|
+
}
|
|
92
|
+
this.authority.next(this.authorizeOptions.issuer);
|
|
93
|
+
console.debug("AuthorizeService::initialize::done");
|
|
94
|
+
}
|
|
95
|
+
loadUser() {
|
|
96
|
+
const claims = this.oauthService.getIdentityClaims();
|
|
97
|
+
if (!claims) {
|
|
98
|
+
console.error("claims where null when loading identity claims");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const user = claims;
|
|
102
|
+
const accessToken = this.oauthService.getAccessToken();
|
|
103
|
+
this.user.next(user);
|
|
104
|
+
this.accessToken.next(accessToken);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
AuthorizeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeService, deps: [{ token: AuthorizeOptions }, { token: i1.OAuthService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
108
|
+
AuthorizeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeService });
|
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeService, decorators: [{
|
|
110
|
+
type: Injectable
|
|
111
|
+
}], ctorParameters: function () {
|
|
112
|
+
return [{ type: AuthorizeOptions, decorators: [{
|
|
113
|
+
type: Inject,
|
|
114
|
+
args: [AuthorizeOptions]
|
|
115
|
+
}] }, { type: i1.OAuthService }];
|
|
116
|
+
} });
|
|
117
|
+
|
|
118
|
+
class LoginMenuComponent {
|
|
119
|
+
constructor(authorizeService) {
|
|
120
|
+
this.authorizeService = authorizeService;
|
|
121
|
+
}
|
|
122
|
+
ngOnInit() {
|
|
123
|
+
const isIFrame = window.self !== window.top;
|
|
124
|
+
console.log("app-login-menu::created");
|
|
125
|
+
this.isAuthenticated = this.authorizeService.getIsAuthenticated();
|
|
126
|
+
this.userName = this.authorizeService.getUser().pipe(map(u => u && u.name));
|
|
127
|
+
this.isAdmin = this.authorizeService.getIsAdmin();
|
|
128
|
+
this.isAuthenticated.subscribe(x => {
|
|
129
|
+
console.log(`isAuthenticated changed to ${x} (iframe ${isIFrame})`);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
login() {
|
|
133
|
+
this.authorizeService.login();
|
|
134
|
+
}
|
|
135
|
+
logout() {
|
|
136
|
+
this.authorizeService.logout();
|
|
137
|
+
}
|
|
138
|
+
register() {
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
LoginMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: LoginMenuComponent, deps: [{ token: AuthorizeService }], target: i0.ɵɵFactoryTarget.Component });
|
|
142
|
+
LoginMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.2", type: LoginMenuComponent, selector: "app-login-menu", ngImport: i0, template: "<ul *ngIf=\"isAuthenticated | async\" class=\"navbar-nav\">\n <li class=\"nav-item dropdown\">\n <a aria-expanded=\"false\" aria-haspopup=\"true\" class=\"nav-link dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\"\n id=\"navbarDropdownLogin\" role=\"button\">\n {{ userName | async }} <b class=\"caret\"></b>\n </a>\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Grants\">Client Application Access</a>-->\n <!--<a class=\"dropdown-item\" [routerLink]='[\"/authentication/profile\"]' title=\"Manage\">Manage</a>-->\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Diagnostics\">Diagnostics</a>-->\n <div class=\"dropdown-divider\"></div>\n <a (click)='logout()' class=\"dropdown-item\" routerLink=\"\" title=\"Logout\">Logout</a>\n </div>\n </li>\n</ul>\n<ul *ngIf=\"!(isAuthenticated | async)\" class=\"navbar-nav\">\n <li class=\"nav-item\">\n <a (click)='register()' class=\"nav-link\" routerLink=\"\">Register</a>\n </li>\n <li class=\"nav-item\">\n <a (click)='login()' class=\"nav-link\" routerLink=\"\">Login</a>\n </li>\n</ul>\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }] });
|
|
143
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: LoginMenuComponent, decorators: [{
|
|
144
|
+
type: Component,
|
|
145
|
+
args: [{ selector: 'app-login-menu', template: "<ul *ngIf=\"isAuthenticated | async\" class=\"navbar-nav\">\n <li class=\"nav-item dropdown\">\n <a aria-expanded=\"false\" aria-haspopup=\"true\" class=\"nav-link dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\"\n id=\"navbarDropdownLogin\" role=\"button\">\n {{ userName | async }} <b class=\"caret\"></b>\n </a>\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Grants\">Client Application Access</a>-->\n <!--<a class=\"dropdown-item\" [routerLink]='[\"/authentication/profile\"]' title=\"Manage\">Manage</a>-->\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Diagnostics\">Diagnostics</a>-->\n <div class=\"dropdown-divider\"></div>\n <a (click)='logout()' class=\"dropdown-item\" routerLink=\"\" title=\"Logout\">Logout</a>\n </div>\n </li>\n</ul>\n<ul *ngIf=\"!(isAuthenticated | async)\" class=\"navbar-nav\">\n <li class=\"nav-item\">\n <a (click)='register()' class=\"nav-link\" routerLink=\"\">Register</a>\n </li>\n <li class=\"nav-item\">\n <a (click)='login()' class=\"nav-link\" routerLink=\"\">Login</a>\n </li>\n</ul>\n" }]
|
|
146
|
+
}], ctorParameters: function () { return [{ type: AuthorizeService }]; } });
|
|
147
|
+
|
|
148
|
+
class AuthorizeGuard {
|
|
149
|
+
constructor(authorize) {
|
|
150
|
+
this.authorize = authorize;
|
|
151
|
+
}
|
|
152
|
+
canActivate(_next, state) {
|
|
153
|
+
return this.authorize.getIsAuthenticated()
|
|
154
|
+
.pipe(tap(isAuthenticated => this.handleAuthorization(isAuthenticated)));
|
|
155
|
+
}
|
|
156
|
+
handleAuthorization(isAuthenticated) {
|
|
157
|
+
if (!isAuthenticated) {
|
|
158
|
+
this.authorize.login();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
AuthorizeGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeGuard, deps: [{ token: AuthorizeService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
163
|
+
AuthorizeGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeGuard });
|
|
164
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeGuard, decorators: [{
|
|
165
|
+
type: Injectable
|
|
166
|
+
}], ctorParameters: function () { return [{ type: AuthorizeService }]; } });
|
|
167
|
+
|
|
168
|
+
class SharedAuthModule {
|
|
169
|
+
static forRoot(authorizeOptions) {
|
|
170
|
+
return {
|
|
171
|
+
ngModule: SharedAuthModule,
|
|
172
|
+
providers: [
|
|
173
|
+
{
|
|
174
|
+
provide: AuthorizeOptions,
|
|
175
|
+
useValue: authorizeOptions
|
|
176
|
+
},
|
|
177
|
+
AuthorizeService,
|
|
178
|
+
AuthorizeGuard
|
|
179
|
+
]
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
SharedAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
184
|
+
SharedAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, declarations: [LoginMenuComponent], imports: [CommonModule,
|
|
185
|
+
HttpClientModule, i1.OAuthModule], exports: [LoginMenuComponent] });
|
|
186
|
+
SharedAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, imports: [CommonModule,
|
|
187
|
+
HttpClientModule,
|
|
188
|
+
OAuthModule.forRoot()] });
|
|
189
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, decorators: [{
|
|
190
|
+
type: NgModule,
|
|
191
|
+
args: [{
|
|
192
|
+
declarations: [LoginMenuComponent],
|
|
193
|
+
exports: [LoginMenuComponent],
|
|
194
|
+
providers: [],
|
|
195
|
+
imports: [
|
|
196
|
+
CommonModule,
|
|
197
|
+
HttpClientModule,
|
|
198
|
+
OAuthModule.forRoot()
|
|
199
|
+
]
|
|
200
|
+
}]
|
|
201
|
+
}] });
|
|
202
|
+
|
|
203
|
+
class AuthorizeInterceptor {
|
|
204
|
+
constructor(authorize) {
|
|
205
|
+
this.authorize = authorize;
|
|
206
|
+
authorize.getAccessToken().subscribe(value => this.accessToken = value);
|
|
207
|
+
}
|
|
208
|
+
static isSameOriginUrl(req) {
|
|
209
|
+
// It's an absolute url with the same origin.
|
|
210
|
+
if (req.url.startsWith(`${window.location.origin}/`)) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
// It's a protocol relative url with the same origin.
|
|
214
|
+
// For example: //www.example.com/api/Products
|
|
215
|
+
if (req.url.startsWith(`//${window.location.host}/`)) {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
// It's a relative url like /api/Products
|
|
219
|
+
if (/^\/[^\/].*/.test(req.url)) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
// It's an absolute or protocol relative url that
|
|
223
|
+
// doesn't have the same origin.
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
// Checks if there is an access_token available in the authorize service
|
|
227
|
+
// and adds it to the request in case it's targeted at the same origin as the
|
|
228
|
+
intercept(req, next) {
|
|
229
|
+
return this.processRequestWithToken(this.accessToken, req, next);
|
|
230
|
+
}
|
|
231
|
+
// single page application.
|
|
232
|
+
processRequestWithToken(token, req, next) {
|
|
233
|
+
if (!!token && (AuthorizeInterceptor.isSameOriginUrl(req) || this.isKnownServiceUri(req))) {
|
|
234
|
+
req = req.clone({
|
|
235
|
+
setHeaders: {
|
|
236
|
+
Authorization: `Bearer ${token}`
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return next.handle(req);
|
|
241
|
+
}
|
|
242
|
+
isKnownServiceUri(req) {
|
|
243
|
+
const serviceUris = this.authorize.getServiceUris();
|
|
244
|
+
for (let i = 0; i < serviceUris.length; i++) {
|
|
245
|
+
if (req.url.startsWith(`${serviceUris[i]}`)) {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// It's an absolute or protocol relative url that
|
|
250
|
+
// doesn't have the same origin.
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
AuthorizeInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeInterceptor, deps: [{ token: AuthorizeService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
255
|
+
AuthorizeInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeInterceptor });
|
|
256
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeInterceptor, decorators: [{
|
|
257
|
+
type: Injectable
|
|
258
|
+
}], ctorParameters: function () { return [{ type: AuthorizeService }]; } });
|
|
259
|
+
|
|
260
|
+
/*
|
|
261
|
+
* Public API Surface of shared-auth
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Generated bundle index. Do not edit.
|
|
266
|
+
*/
|
|
267
|
+
|
|
268
|
+
export { AuthorizeGuard, AuthorizeInterceptor, AuthorizeOptions, AuthorizeService, LoginMenuComponent, SharedAuthModule };
|
|
269
|
+
//# sourceMappingURL=meshmakers-shared-auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meshmakers-shared-auth.mjs","sources":["../../../../projects/meshmakers/shared-auth/src/lib/authorize.service.ts","../../../../projects/meshmakers/shared-auth/src/lib/login-menu/login-menu.component.ts","../../../../projects/meshmakers/shared-auth/src/lib/login-menu/login-menu.component.html","../../../../projects/meshmakers/shared-auth/src/lib/authorize.guard.ts","../../../../projects/meshmakers/shared-auth/src/lib/shared-auth.module.ts","../../../../projects/meshmakers/shared-auth/src/lib/authorize.interceptor.ts","../../../../projects/meshmakers/shared-auth/src/public-api.ts","../../../../projects/meshmakers/shared-auth/src/meshmakers-shared-auth.ts"],"sourcesContent":["import {Inject, Injectable} from '@angular/core';\nimport {BehaviorSubject} from 'rxjs';\nimport {filter} from 'rxjs/operators';\nimport {AuthConfig, OAuthService} from \"angular-oauth2-oidc\";\n\nexport interface IUser {\n name: string;\n role: string;\n}\n\nexport class AuthorizeOptions {\n wellKnownServiceUris: string[];\n // Url of the Identity Provider\n issuer: string;\n // URL of the SPA to redirect the user to after login\n redirectUri: string;\n postLogoutRedirectUri: string;\n // The SPA's id. The SPA is registered with this id at the auth-server\n clientId: string;\n // set the scope for the permissions the client should request\n // The first three are defined by OIDC. The 4th is a use case-specific one\n scope: string;\n showDebugInformation: boolean;\n sessionChecksEnabled: boolean;\n}\n\n@Injectable()\nexport class AuthorizeService {\n private isAuthenticated: BehaviorSubject<boolean> = new BehaviorSubject(false);\n private isAdmin: BehaviorSubject<boolean> = new BehaviorSubject(false);\n private authority: BehaviorSubject<string> = new BehaviorSubject(null);\n private accessToken: BehaviorSubject<string> = new BehaviorSubject(null);\n private user: BehaviorSubject<IUser> = new BehaviorSubject(null);\n\n constructor(@Inject(AuthorizeOptions) private authorizeOptions: AuthorizeOptions, private oauthService: OAuthService) {\n console.debug(\"AuthorizeService::created\");\n this.getUser().subscribe(s => {\n this.isAuthenticated.next(!!s);\n this.isAdmin.next(!!s && s.role === \"Administrators\");\n });\n }\n\n public getServiceUris(): Array<string> {\n return this.authorizeOptions.wellKnownServiceUris;\n }\n\n public getAuthority(): BehaviorSubject<string> {\n return this.authority;\n }\n\n public getIsAuthenticated(): BehaviorSubject<boolean> {\n return this.isAuthenticated;\n }\n\n public getIsAdmin(): BehaviorSubject<boolean> {\n return this.isAdmin;\n }\n\n public getAccessToken(): BehaviorSubject<string> {\n return this.accessToken;\n }\n\n public getUser(): BehaviorSubject<IUser> {\n return this.user;\n }\n\n public login() {\n this.oauthService.initImplicitFlow();\n }\n\n public logout() {\n this.oauthService.logOut(false);\n }\n\n\n public initialize() {\n\n console.debug(\"AuthorizeService::initialize::started\");\n\n const config: AuthConfig = {\n responseType: 'code',\n issuer: this.authorizeOptions.issuer,\n redirectUri: this.authorizeOptions.redirectUri,\n postLogoutRedirectUri: this.authorizeOptions.postLogoutRedirectUri,\n clientId: this.authorizeOptions.clientId,\n scope: this.authorizeOptions.scope,\n showDebugInformation: this.authorizeOptions.showDebugInformation,\n sessionChecksEnabled: this.authorizeOptions.sessionChecksEnabled\n };\n\n this.oauthService.configure(config);\n this.oauthService.setStorage(localStorage);\n this.oauthService.loadDiscoveryDocumentAndTryLogin();\n\n this.oauthService.setupAutomaticSilentRefresh();\n\n this.oauthService.events.subscribe(e => {\n // tslint:disable-next-line:no-console\n console.debug('oauth/oidc event', e);\n });\n\n this.oauthService.events\n .pipe(filter(e => e.type === 'session_terminated'))\n .subscribe(e => {\n // tslint:disable-next-line:no-console\n console.debug('Your session has been terminated!');\n });\n\n this.oauthService.events\n .pipe(filter(e => e.type === 'token_received'))\n .subscribe(e => {\n this.loadUser();\n });\n\n this.oauthService.events\n .pipe(filter(e => e.type === 'logout'))\n .subscribe(e => {\n this.accessToken.next(null);\n this.user.next(null);\n });\n\n if (this.oauthService.hasValidAccessToken()) {\n this.loadUser();\n }\n\n this.authority.next(this.authorizeOptions.issuer);\n\n console.debug(\"AuthorizeService::initialize::done\");\n\n }\n\n private loadUser() {\n const claims = this.oauthService.getIdentityClaims();\n if (!claims) {\n console.error(\"claims where null when loading identity claims\");\n return;\n }\n\n const user = <IUser>claims;\n const accessToken = this.oauthService.getAccessToken();\n this.user.next(user);\n this.accessToken.next(accessToken);\n }\n}\n","import {Component, OnInit} from '@angular/core';\nimport {AuthorizeService} from '../authorize.service';\nimport {BehaviorSubject, Observable} from 'rxjs';\nimport {map} from 'rxjs/operators';\n\n@Component({\n selector: 'app-login-menu',\n templateUrl: './login-menu.component.html',\n styleUrls: ['./login-menu.component.css']\n})\nexport class LoginMenuComponent implements OnInit {\n public isAuthenticated: BehaviorSubject<boolean>;\n public userName: Observable<string>;\n public isAdmin: Observable<boolean>;\n\n constructor(private authorizeService: AuthorizeService) {\n }\n\n ngOnInit() {\n const isIFrame = window.self !== window.top;\n\n console.log(\"app-login-menu::created\");\n\n this.isAuthenticated = this.authorizeService.getIsAuthenticated();\n this.userName = this.authorizeService.getUser().pipe(map(u => u && u.name));\n this.isAdmin = this.authorizeService.getIsAdmin();\n\n this.isAuthenticated.subscribe(x => {\n\n console.log(`isAuthenticated changed to ${x} (iframe ${isIFrame})`);\n });\n }\n\n public login() {\n this.authorizeService.login();\n }\n\n public logout() {\n this.authorizeService.logout();\n }\n\n public register() {\n\n }\n}\n","<ul *ngIf=\"isAuthenticated | async\" class=\"navbar-nav\">\n <li class=\"nav-item dropdown\">\n <a aria-expanded=\"false\" aria-haspopup=\"true\" class=\"nav-link dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\"\n id=\"navbarDropdownLogin\" role=\"button\">\n {{ userName | async }} <b class=\"caret\"></b>\n </a>\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Grants\">Client Application Access</a>-->\n <!--<a class=\"dropdown-item\" [routerLink]='[\"/authentication/profile\"]' title=\"Manage\">Manage</a>-->\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Diagnostics\">Diagnostics</a>-->\n <div class=\"dropdown-divider\"></div>\n <a (click)='logout()' class=\"dropdown-item\" routerLink=\"\" title=\"Logout\">Logout</a>\n </div>\n </li>\n</ul>\n<ul *ngIf=\"!(isAuthenticated | async)\" class=\"navbar-nav\">\n <li class=\"nav-item\">\n <a (click)='register()' class=\"nav-link\" routerLink=\"\">Register</a>\n </li>\n <li class=\"nav-item\">\n <a (click)='login()' class=\"nav-link\" routerLink=\"\">Login</a>\n </li>\n</ul>\n","import {Injectable} from '@angular/core';\nimport {ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot} from '@angular/router';\nimport {AuthorizeService} from './authorize.service';\nimport {tap} from 'rxjs/operators';\n\n@Injectable()\nexport class AuthorizeGuard implements CanActivate {\n constructor(private authorize: AuthorizeService) {\n }\n\n canActivate(\n _next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot): any {\n return this.authorize.getIsAuthenticated()\n .pipe(tap(isAuthenticated => this.handleAuthorization(isAuthenticated)));\n }\n\n private handleAuthorization(isAuthenticated: boolean) {\n if (!isAuthenticated) {\n this.authorize.login();\n }\n }\n}\n","import {ModuleWithProviders, NgModule} from '@angular/core';\nimport {CommonModule} from \"@angular/common\";\nimport {HttpClientModule} from \"@angular/common/http\";\nimport {LoginMenuComponent} from \"./login-menu/login-menu.component\";\nimport {AuthorizeOptions, AuthorizeService} from \"./authorize.service\";\nimport {OAuthModule} from \"angular-oauth2-oidc\";\nimport {AuthorizeGuard} from \"./authorize.guard\";\n\n@NgModule({\n declarations: [LoginMenuComponent],\n exports: [LoginMenuComponent],\n providers: [],\n imports: [\n CommonModule,\n HttpClientModule,\n OAuthModule.forRoot()\n ]\n})\nexport class SharedAuthModule {\n static forRoot(authorizeOptions: AuthorizeOptions): ModuleWithProviders<SharedAuthModule> {\n return {\n ngModule: SharedAuthModule,\n providers: [\n {\n provide: AuthorizeOptions,\n useValue: authorizeOptions\n },\n AuthorizeService,\n AuthorizeGuard\n ]\n }\n }\n}\n","import {Injectable} from '@angular/core';\nimport {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {Observable} from 'rxjs';\nimport {AuthorizeService} from './authorize.service';\n\n@Injectable()\nexport class AuthorizeInterceptor implements HttpInterceptor {\n\n accessToken: string;\n\n constructor(private authorize: AuthorizeService) {\n\n authorize.getAccessToken().subscribe(value => this.accessToken = value);\n\n }\n\n private static isSameOriginUrl(req: any) {\n // It's an absolute url with the same origin.\n if (req.url.startsWith(`${window.location.origin}/`)) {\n return true;\n }\n\n // It's a protocol relative url with the same origin.\n // For example: //www.example.com/api/Products\n if (req.url.startsWith(`//${window.location.host}/`)) {\n return true;\n }\n\n // It's a relative url like /api/Products\n if (/^\\/[^\\/].*/.test(req.url)) {\n return true;\n }\n\n // It's an absolute or protocol relative url that\n // doesn't have the same origin.\n return false;\n }\n\n // Checks if there is an access_token available in the authorize service\n // and adds it to the request in case it's targeted at the same origin as the\n\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n return this.processRequestWithToken(this.accessToken, req, next);\n }\n\n // single page application.\n private processRequestWithToken(token: string, req: HttpRequest<any>, next: HttpHandler) {\n if (!!token && (AuthorizeInterceptor.isSameOriginUrl(req) || this.isKnownServiceUri(req))) {\n req = req.clone({\n setHeaders: {\n Authorization: `Bearer ${token}`\n }\n });\n }\n\n return next.handle(req);\n }\n\n private isKnownServiceUri(req: any) {\n\n const serviceUris = this.authorize.getServiceUris();\n\n for (let i = 0; i < serviceUris.length; i++) {\n if (req.url.startsWith(`${serviceUris[i]}`)) {\n return true;\n }\n }\n\n // It's an absolute or protocol relative url that\n // doesn't have the same origin.\n return false;\n }\n}\n","/*\n * Public API Surface of shared-auth\n */\n\nexport * from './lib/authorize.service';\nexport * from './lib/login-menu/login-menu.component';\nexport * from './lib/shared-auth.module';\nexport * from './lib/authorize.interceptor';\nexport * from './lib/authorize.guard';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.AuthorizeService"],"mappings":";;;;;;;;;;MAUa,gBAAgB,CAAA;AAc5B,CAAA;MAGY,gBAAgB,CAAA;IAO3B,WAA8C,CAAA,gBAAkC,EAAU,YAA0B,EAAA;AAAtE,QAAA,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB,CAAkB;AAAU,QAAA,IAAY,CAAA,YAAA,GAAZ,YAAY,CAAc;QAN5G,IAAA,CAAA,eAAe,GAA6B,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;QACvE,IAAA,CAAA,OAAO,GAA6B,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;QAC/D,IAAA,CAAA,SAAS,GAA4B,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QAC/D,IAAA,CAAA,WAAW,GAA4B,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QACjE,IAAA,CAAA,IAAI,GAA2B,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;AAG/D,QAAA,OAAO,CAA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;QAEhC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;AAEpD,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC3C,YAAA,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAG,EAAA,WAAW,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC,EAAE;AAC3C,gBAAA,OAAO,IAAI,CAAC;AACb,aAAA;AACF,SAAA;;;AAID,QAAA,OAAO,KAAK,CAAC;KACd;;iHAjEU,oBAAoB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAAA,gBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;qHAApB,oBAAoB,EAAA,CAAA,CAAA;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC,UAAU;;;ACLX;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Inject, Component, NgModule } from '@angular/core';
|
|
3
|
+
import { BehaviorSubject } from 'rxjs';
|
|
4
|
+
import { filter, map, tap } from 'rxjs/operators';
|
|
5
|
+
import * as i1 from 'angular-oauth2-oidc';
|
|
6
|
+
import { OAuthModule } from 'angular-oauth2-oidc';
|
|
7
|
+
import * as i2 from '@angular/common';
|
|
8
|
+
import { CommonModule } from '@angular/common';
|
|
9
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
10
|
+
|
|
11
|
+
class AuthorizeOptions {
|
|
12
|
+
}
|
|
13
|
+
class AuthorizeService {
|
|
14
|
+
constructor(authorizeOptions, oauthService) {
|
|
15
|
+
this.authorizeOptions = authorizeOptions;
|
|
16
|
+
this.oauthService = oauthService;
|
|
17
|
+
this.isAuthenticated = new BehaviorSubject(false);
|
|
18
|
+
this.isAdmin = new BehaviorSubject(false);
|
|
19
|
+
this.authority = new BehaviorSubject(null);
|
|
20
|
+
this.accessToken = new BehaviorSubject(null);
|
|
21
|
+
this.user = new BehaviorSubject(null);
|
|
22
|
+
console.debug("AuthorizeService::created");
|
|
23
|
+
this.getUser().subscribe(s => {
|
|
24
|
+
this.isAuthenticated.next(!!s);
|
|
25
|
+
this.isAdmin.next(!!s && s.role === "Administrators");
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getServiceUris() {
|
|
29
|
+
return this.authorizeOptions.wellKnownServiceUris;
|
|
30
|
+
}
|
|
31
|
+
getAuthority() {
|
|
32
|
+
return this.authority;
|
|
33
|
+
}
|
|
34
|
+
getIsAuthenticated() {
|
|
35
|
+
return this.isAuthenticated;
|
|
36
|
+
}
|
|
37
|
+
getIsAdmin() {
|
|
38
|
+
return this.isAdmin;
|
|
39
|
+
}
|
|
40
|
+
getAccessToken() {
|
|
41
|
+
return this.accessToken;
|
|
42
|
+
}
|
|
43
|
+
getUser() {
|
|
44
|
+
return this.user;
|
|
45
|
+
}
|
|
46
|
+
login() {
|
|
47
|
+
this.oauthService.initImplicitFlow();
|
|
48
|
+
}
|
|
49
|
+
logout() {
|
|
50
|
+
this.oauthService.logOut(false);
|
|
51
|
+
}
|
|
52
|
+
initialize() {
|
|
53
|
+
console.debug("AuthorizeService::initialize::started");
|
|
54
|
+
const config = {
|
|
55
|
+
responseType: 'code',
|
|
56
|
+
issuer: this.authorizeOptions.issuer,
|
|
57
|
+
redirectUri: this.authorizeOptions.redirectUri,
|
|
58
|
+
postLogoutRedirectUri: this.authorizeOptions.postLogoutRedirectUri,
|
|
59
|
+
clientId: this.authorizeOptions.clientId,
|
|
60
|
+
scope: this.authorizeOptions.scope,
|
|
61
|
+
showDebugInformation: this.authorizeOptions.showDebugInformation,
|
|
62
|
+
sessionChecksEnabled: this.authorizeOptions.sessionChecksEnabled
|
|
63
|
+
};
|
|
64
|
+
this.oauthService.configure(config);
|
|
65
|
+
this.oauthService.setStorage(localStorage);
|
|
66
|
+
this.oauthService.loadDiscoveryDocumentAndTryLogin();
|
|
67
|
+
this.oauthService.setupAutomaticSilentRefresh();
|
|
68
|
+
this.oauthService.events.subscribe(e => {
|
|
69
|
+
// tslint:disable-next-line:no-console
|
|
70
|
+
console.debug('oauth/oidc event', e);
|
|
71
|
+
});
|
|
72
|
+
this.oauthService.events
|
|
73
|
+
.pipe(filter(e => e.type === 'session_terminated'))
|
|
74
|
+
.subscribe(e => {
|
|
75
|
+
// tslint:disable-next-line:no-console
|
|
76
|
+
console.debug('Your session has been terminated!');
|
|
77
|
+
});
|
|
78
|
+
this.oauthService.events
|
|
79
|
+
.pipe(filter(e => e.type === 'token_received'))
|
|
80
|
+
.subscribe(e => {
|
|
81
|
+
this.loadUser();
|
|
82
|
+
});
|
|
83
|
+
this.oauthService.events
|
|
84
|
+
.pipe(filter(e => e.type === 'logout'))
|
|
85
|
+
.subscribe(e => {
|
|
86
|
+
this.accessToken.next(null);
|
|
87
|
+
this.user.next(null);
|
|
88
|
+
});
|
|
89
|
+
if (this.oauthService.hasValidAccessToken()) {
|
|
90
|
+
this.loadUser();
|
|
91
|
+
}
|
|
92
|
+
this.authority.next(this.authorizeOptions.issuer);
|
|
93
|
+
console.debug("AuthorizeService::initialize::done");
|
|
94
|
+
}
|
|
95
|
+
loadUser() {
|
|
96
|
+
const claims = this.oauthService.getIdentityClaims();
|
|
97
|
+
if (!claims) {
|
|
98
|
+
console.error("claims where null when loading identity claims");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const user = claims;
|
|
102
|
+
const accessToken = this.oauthService.getAccessToken();
|
|
103
|
+
this.user.next(user);
|
|
104
|
+
this.accessToken.next(accessToken);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
AuthorizeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeService, deps: [{ token: AuthorizeOptions }, { token: i1.OAuthService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
108
|
+
AuthorizeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeService });
|
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeService, decorators: [{
|
|
110
|
+
type: Injectable
|
|
111
|
+
}], ctorParameters: function () { return [{ type: AuthorizeOptions, decorators: [{
|
|
112
|
+
type: Inject,
|
|
113
|
+
args: [AuthorizeOptions]
|
|
114
|
+
}] }, { type: i1.OAuthService }]; } });
|
|
115
|
+
|
|
116
|
+
class LoginMenuComponent {
|
|
117
|
+
constructor(authorizeService) {
|
|
118
|
+
this.authorizeService = authorizeService;
|
|
119
|
+
}
|
|
120
|
+
ngOnInit() {
|
|
121
|
+
const isIFrame = window.self !== window.top;
|
|
122
|
+
console.log("app-login-menu::created");
|
|
123
|
+
this.isAuthenticated = this.authorizeService.getIsAuthenticated();
|
|
124
|
+
this.userName = this.authorizeService.getUser().pipe(map(u => u && u.name));
|
|
125
|
+
this.isAdmin = this.authorizeService.getIsAdmin();
|
|
126
|
+
this.isAuthenticated.subscribe(x => {
|
|
127
|
+
console.log(`isAuthenticated changed to ${x} (iframe ${isIFrame})`);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
login() {
|
|
131
|
+
this.authorizeService.login();
|
|
132
|
+
}
|
|
133
|
+
logout() {
|
|
134
|
+
this.authorizeService.logout();
|
|
135
|
+
}
|
|
136
|
+
register() {
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
LoginMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: LoginMenuComponent, deps: [{ token: AuthorizeService }], target: i0.ɵɵFactoryTarget.Component });
|
|
140
|
+
LoginMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.2", type: LoginMenuComponent, selector: "app-login-menu", ngImport: i0, template: "<ul *ngIf=\"isAuthenticated | async\" class=\"navbar-nav\">\n <li class=\"nav-item dropdown\">\n <a aria-expanded=\"false\" aria-haspopup=\"true\" class=\"nav-link dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\"\n id=\"navbarDropdownLogin\" role=\"button\">\n {{ userName | async }} <b class=\"caret\"></b>\n </a>\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Grants\">Client Application Access</a>-->\n <!--<a class=\"dropdown-item\" [routerLink]='[\"/authentication/profile\"]' title=\"Manage\">Manage</a>-->\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Diagnostics\">Diagnostics</a>-->\n <div class=\"dropdown-divider\"></div>\n <a (click)='logout()' class=\"dropdown-item\" routerLink=\"\" title=\"Logout\">Logout</a>\n </div>\n </li>\n</ul>\n<ul *ngIf=\"!(isAuthenticated | async)\" class=\"navbar-nav\">\n <li class=\"nav-item\">\n <a (click)='register()' class=\"nav-link\" routerLink=\"\">Register</a>\n </li>\n <li class=\"nav-item\">\n <a (click)='login()' class=\"nav-link\" routerLink=\"\">Login</a>\n </li>\n</ul>\n", styles: [""], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }] });
|
|
141
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: LoginMenuComponent, decorators: [{
|
|
142
|
+
type: Component,
|
|
143
|
+
args: [{ selector: 'app-login-menu', template: "<ul *ngIf=\"isAuthenticated | async\" class=\"navbar-nav\">\n <li class=\"nav-item dropdown\">\n <a aria-expanded=\"false\" aria-haspopup=\"true\" class=\"nav-link dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\"\n id=\"navbarDropdownLogin\" role=\"button\">\n {{ userName | async }} <b class=\"caret\"></b>\n </a>\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Grants\">Client Application Access</a>-->\n <!--<a class=\"dropdown-item\" [routerLink]='[\"/authentication/profile\"]' title=\"Manage\">Manage</a>-->\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Diagnostics\">Diagnostics</a>-->\n <div class=\"dropdown-divider\"></div>\n <a (click)='logout()' class=\"dropdown-item\" routerLink=\"\" title=\"Logout\">Logout</a>\n </div>\n </li>\n</ul>\n<ul *ngIf=\"!(isAuthenticated | async)\" class=\"navbar-nav\">\n <li class=\"nav-item\">\n <a (click)='register()' class=\"nav-link\" routerLink=\"\">Register</a>\n </li>\n <li class=\"nav-item\">\n <a (click)='login()' class=\"nav-link\" routerLink=\"\">Login</a>\n </li>\n</ul>\n" }]
|
|
144
|
+
}], ctorParameters: function () { return [{ type: AuthorizeService }]; } });
|
|
145
|
+
|
|
146
|
+
class AuthorizeGuard {
|
|
147
|
+
constructor(authorize) {
|
|
148
|
+
this.authorize = authorize;
|
|
149
|
+
}
|
|
150
|
+
canActivate(_next, state) {
|
|
151
|
+
return this.authorize.getIsAuthenticated()
|
|
152
|
+
.pipe(tap(isAuthenticated => this.handleAuthorization(isAuthenticated)));
|
|
153
|
+
}
|
|
154
|
+
handleAuthorization(isAuthenticated) {
|
|
155
|
+
if (!isAuthenticated) {
|
|
156
|
+
this.authorize.login();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
AuthorizeGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeGuard, deps: [{ token: AuthorizeService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
161
|
+
AuthorizeGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeGuard });
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeGuard, decorators: [{
|
|
163
|
+
type: Injectable
|
|
164
|
+
}], ctorParameters: function () { return [{ type: AuthorizeService }]; } });
|
|
165
|
+
|
|
166
|
+
class SharedAuthModule {
|
|
167
|
+
static forRoot(authorizeOptions) {
|
|
168
|
+
return {
|
|
169
|
+
ngModule: SharedAuthModule,
|
|
170
|
+
providers: [
|
|
171
|
+
{
|
|
172
|
+
provide: AuthorizeOptions,
|
|
173
|
+
useValue: authorizeOptions
|
|
174
|
+
},
|
|
175
|
+
AuthorizeService,
|
|
176
|
+
AuthorizeGuard
|
|
177
|
+
]
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
SharedAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
182
|
+
SharedAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, declarations: [LoginMenuComponent], imports: [CommonModule,
|
|
183
|
+
HttpClientModule, i1.OAuthModule], exports: [LoginMenuComponent] });
|
|
184
|
+
SharedAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, imports: [CommonModule,
|
|
185
|
+
HttpClientModule,
|
|
186
|
+
OAuthModule.forRoot()] });
|
|
187
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, decorators: [{
|
|
188
|
+
type: NgModule,
|
|
189
|
+
args: [{
|
|
190
|
+
declarations: [LoginMenuComponent],
|
|
191
|
+
exports: [LoginMenuComponent],
|
|
192
|
+
providers: [],
|
|
193
|
+
imports: [
|
|
194
|
+
CommonModule,
|
|
195
|
+
HttpClientModule,
|
|
196
|
+
OAuthModule.forRoot()
|
|
197
|
+
]
|
|
198
|
+
}]
|
|
199
|
+
}] });
|
|
200
|
+
|
|
201
|
+
class AuthorizeInterceptor {
|
|
202
|
+
constructor(authorize) {
|
|
203
|
+
this.authorize = authorize;
|
|
204
|
+
authorize.getAccessToken().subscribe(value => this.accessToken = value);
|
|
205
|
+
}
|
|
206
|
+
static isSameOriginUrl(req) {
|
|
207
|
+
// It's an absolute url with the same origin.
|
|
208
|
+
if (req.url.startsWith(`${window.location.origin}/`)) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
// It's a protocol relative url with the same origin.
|
|
212
|
+
// For example: //www.example.com/api/Products
|
|
213
|
+
if (req.url.startsWith(`//${window.location.host}/`)) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
// It's a relative url like /api/Products
|
|
217
|
+
if (/^\/[^\/].*/.test(req.url)) {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
// It's an absolute or protocol relative url that
|
|
221
|
+
// doesn't have the same origin.
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
// Checks if there is an access_token available in the authorize service
|
|
225
|
+
// and adds it to the request in case it's targeted at the same origin as the
|
|
226
|
+
intercept(req, next) {
|
|
227
|
+
return this.processRequestWithToken(this.accessToken, req, next);
|
|
228
|
+
}
|
|
229
|
+
// single page application.
|
|
230
|
+
processRequestWithToken(token, req, next) {
|
|
231
|
+
if (!!token && (AuthorizeInterceptor.isSameOriginUrl(req) || this.isKnownServiceUri(req))) {
|
|
232
|
+
req = req.clone({
|
|
233
|
+
setHeaders: {
|
|
234
|
+
Authorization: `Bearer ${token}`
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return next.handle(req);
|
|
239
|
+
}
|
|
240
|
+
isKnownServiceUri(req) {
|
|
241
|
+
const serviceUris = this.authorize.getServiceUris();
|
|
242
|
+
for (let i = 0; i < serviceUris.length; i++) {
|
|
243
|
+
if (req.url.startsWith(`${serviceUris[i]}`)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// It's an absolute or protocol relative url that
|
|
248
|
+
// doesn't have the same origin.
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
AuthorizeInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeInterceptor, deps: [{ token: AuthorizeService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
253
|
+
AuthorizeInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeInterceptor });
|
|
254
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthorizeInterceptor, decorators: [{
|
|
255
|
+
type: Injectable
|
|
256
|
+
}], ctorParameters: function () { return [{ type: AuthorizeService }]; } });
|
|
257
|
+
|
|
258
|
+
/*
|
|
259
|
+
* Public API Surface of shared-auth
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Generated bundle index. Do not edit.
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
export { AuthorizeGuard, AuthorizeInterceptor, AuthorizeOptions, AuthorizeService, LoginMenuComponent, SharedAuthModule };
|
|
267
|
+
//# sourceMappingURL=meshmakers-shared-auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meshmakers-shared-auth.mjs","sources":["../../../../projects/meshmakers/shared-auth/src/lib/authorize.service.ts","../../../../projects/meshmakers/shared-auth/src/lib/login-menu/login-menu.component.ts","../../../../projects/meshmakers/shared-auth/src/lib/login-menu/login-menu.component.html","../../../../projects/meshmakers/shared-auth/src/lib/authorize.guard.ts","../../../../projects/meshmakers/shared-auth/src/lib/shared-auth.module.ts","../../../../projects/meshmakers/shared-auth/src/lib/authorize.interceptor.ts","../../../../projects/meshmakers/shared-auth/src/public-api.ts","../../../../projects/meshmakers/shared-auth/src/meshmakers-shared-auth.ts"],"sourcesContent":["import {Inject, Injectable} from '@angular/core';\nimport {BehaviorSubject} from 'rxjs';\nimport {filter} from 'rxjs/operators';\nimport {AuthConfig, OAuthService} from \"angular-oauth2-oidc\";\n\nexport interface IUser {\n name: string;\n role: string;\n}\n\nexport class AuthorizeOptions {\n wellKnownServiceUris: string[];\n // Url of the Identity Provider\n issuer: string;\n // URL of the SPA to redirect the user to after login\n redirectUri: string;\n postLogoutRedirectUri: string;\n // The SPA's id. The SPA is registered with this id at the auth-server\n clientId: string;\n // set the scope for the permissions the client should request\n // The first three are defined by OIDC. The 4th is a use case-specific one\n scope: string;\n showDebugInformation: boolean;\n sessionChecksEnabled: boolean;\n}\n\n@Injectable()\nexport class AuthorizeService {\n private isAuthenticated: BehaviorSubject<boolean> = new BehaviorSubject(false);\n private isAdmin: BehaviorSubject<boolean> = new BehaviorSubject(false);\n private authority: BehaviorSubject<string> = new BehaviorSubject(null);\n private accessToken: BehaviorSubject<string> = new BehaviorSubject(null);\n private user: BehaviorSubject<IUser> = new BehaviorSubject(null);\n\n constructor(@Inject(AuthorizeOptions) private authorizeOptions: AuthorizeOptions, private oauthService: OAuthService) {\n console.debug(\"AuthorizeService::created\");\n this.getUser().subscribe(s => {\n this.isAuthenticated.next(!!s);\n this.isAdmin.next(!!s && s.role === \"Administrators\");\n });\n }\n\n public getServiceUris(): Array<string> {\n return this.authorizeOptions.wellKnownServiceUris;\n }\n\n public getAuthority(): BehaviorSubject<string> {\n return this.authority;\n }\n\n public getIsAuthenticated(): BehaviorSubject<boolean> {\n return this.isAuthenticated;\n }\n\n public getIsAdmin(): BehaviorSubject<boolean> {\n return this.isAdmin;\n }\n\n public getAccessToken(): BehaviorSubject<string> {\n return this.accessToken;\n }\n\n public getUser(): BehaviorSubject<IUser> {\n return this.user;\n }\n\n public login() {\n this.oauthService.initImplicitFlow();\n }\n\n public logout() {\n this.oauthService.logOut(false);\n }\n\n\n public initialize() {\n\n console.debug(\"AuthorizeService::initialize::started\");\n\n const config: AuthConfig = {\n responseType: 'code',\n issuer: this.authorizeOptions.issuer,\n redirectUri: this.authorizeOptions.redirectUri,\n postLogoutRedirectUri: this.authorizeOptions.postLogoutRedirectUri,\n clientId: this.authorizeOptions.clientId,\n scope: this.authorizeOptions.scope,\n showDebugInformation: this.authorizeOptions.showDebugInformation,\n sessionChecksEnabled: this.authorizeOptions.sessionChecksEnabled\n };\n\n this.oauthService.configure(config);\n this.oauthService.setStorage(localStorage);\n this.oauthService.loadDiscoveryDocumentAndTryLogin();\n\n this.oauthService.setupAutomaticSilentRefresh();\n\n this.oauthService.events.subscribe(e => {\n // tslint:disable-next-line:no-console\n console.debug('oauth/oidc event', e);\n });\n\n this.oauthService.events\n .pipe(filter(e => e.type === 'session_terminated'))\n .subscribe(e => {\n // tslint:disable-next-line:no-console\n console.debug('Your session has been terminated!');\n });\n\n this.oauthService.events\n .pipe(filter(e => e.type === 'token_received'))\n .subscribe(e => {\n this.loadUser();\n });\n\n this.oauthService.events\n .pipe(filter(e => e.type === 'logout'))\n .subscribe(e => {\n this.accessToken.next(null);\n this.user.next(null);\n });\n\n if (this.oauthService.hasValidAccessToken()) {\n this.loadUser();\n }\n\n this.authority.next(this.authorizeOptions.issuer);\n\n console.debug(\"AuthorizeService::initialize::done\");\n\n }\n\n private loadUser() {\n const claims = this.oauthService.getIdentityClaims();\n if (!claims) {\n console.error(\"claims where null when loading identity claims\");\n return;\n }\n\n const user = <IUser>claims;\n const accessToken = this.oauthService.getAccessToken();\n this.user.next(user);\n this.accessToken.next(accessToken);\n }\n}\n","import {Component, OnInit} from '@angular/core';\nimport {AuthorizeService} from '../authorize.service';\nimport {BehaviorSubject, Observable} from 'rxjs';\nimport {map} from 'rxjs/operators';\n\n@Component({\n selector: 'app-login-menu',\n templateUrl: './login-menu.component.html',\n styleUrls: ['./login-menu.component.css']\n})\nexport class LoginMenuComponent implements OnInit {\n public isAuthenticated: BehaviorSubject<boolean>;\n public userName: Observable<string>;\n public isAdmin: Observable<boolean>;\n\n constructor(private authorizeService: AuthorizeService) {\n }\n\n ngOnInit() {\n const isIFrame = window.self !== window.top;\n\n console.log(\"app-login-menu::created\");\n\n this.isAuthenticated = this.authorizeService.getIsAuthenticated();\n this.userName = this.authorizeService.getUser().pipe(map(u => u && u.name));\n this.isAdmin = this.authorizeService.getIsAdmin();\n\n this.isAuthenticated.subscribe(x => {\n\n console.log(`isAuthenticated changed to ${x} (iframe ${isIFrame})`);\n });\n }\n\n public login() {\n this.authorizeService.login();\n }\n\n public logout() {\n this.authorizeService.logout();\n }\n\n public register() {\n\n }\n}\n","<ul *ngIf=\"isAuthenticated | async\" class=\"navbar-nav\">\n <li class=\"nav-item dropdown\">\n <a aria-expanded=\"false\" aria-haspopup=\"true\" class=\"nav-link dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\"\n id=\"navbarDropdownLogin\" role=\"button\">\n {{ userName | async }} <b class=\"caret\"></b>\n </a>\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Grants\">Client Application Access</a>-->\n <!--<a class=\"dropdown-item\" [routerLink]='[\"/authentication/profile\"]' title=\"Manage\">Manage</a>-->\n <!--<a class=\"dropdown-item\" asp-action=\"Index\" asp-area=\"Authentication\" asp-controller=\"Diagnostics\">Diagnostics</a>-->\n <div class=\"dropdown-divider\"></div>\n <a (click)='logout()' class=\"dropdown-item\" routerLink=\"\" title=\"Logout\">Logout</a>\n </div>\n </li>\n</ul>\n<ul *ngIf=\"!(isAuthenticated | async)\" class=\"navbar-nav\">\n <li class=\"nav-item\">\n <a (click)='register()' class=\"nav-link\" routerLink=\"\">Register</a>\n </li>\n <li class=\"nav-item\">\n <a (click)='login()' class=\"nav-link\" routerLink=\"\">Login</a>\n </li>\n</ul>\n","import {Injectable} from '@angular/core';\nimport {ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot} from '@angular/router';\nimport {AuthorizeService} from './authorize.service';\nimport {tap} from 'rxjs/operators';\n\n@Injectable()\nexport class AuthorizeGuard implements CanActivate {\n constructor(private authorize: AuthorizeService) {\n }\n\n canActivate(\n _next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot): any {\n return this.authorize.getIsAuthenticated()\n .pipe(tap(isAuthenticated => this.handleAuthorization(isAuthenticated)));\n }\n\n private handleAuthorization(isAuthenticated: boolean) {\n if (!isAuthenticated) {\n this.authorize.login();\n }\n }\n}\n","import {ModuleWithProviders, NgModule} from '@angular/core';\nimport {CommonModule} from \"@angular/common\";\nimport {HttpClientModule} from \"@angular/common/http\";\nimport {LoginMenuComponent} from \"./login-menu/login-menu.component\";\nimport {AuthorizeOptions, AuthorizeService} from \"./authorize.service\";\nimport {OAuthModule} from \"angular-oauth2-oidc\";\nimport {AuthorizeGuard} from \"./authorize.guard\";\n\n@NgModule({\n declarations: [LoginMenuComponent],\n exports: [LoginMenuComponent],\n providers: [],\n imports: [\n CommonModule,\n HttpClientModule,\n OAuthModule.forRoot()\n ]\n})\nexport class SharedAuthModule {\n static forRoot(authorizeOptions: AuthorizeOptions): ModuleWithProviders<SharedAuthModule> {\n return {\n ngModule: SharedAuthModule,\n providers: [\n {\n provide: AuthorizeOptions,\n useValue: authorizeOptions\n },\n AuthorizeService,\n AuthorizeGuard\n ]\n }\n }\n}\n","import {Injectable} from '@angular/core';\nimport {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {Observable} from 'rxjs';\nimport {AuthorizeService} from './authorize.service';\n\n@Injectable()\nexport class AuthorizeInterceptor implements HttpInterceptor {\n\n accessToken: string;\n\n constructor(private authorize: AuthorizeService) {\n\n authorize.getAccessToken().subscribe(value => this.accessToken = value);\n\n }\n\n private static isSameOriginUrl(req: any) {\n // It's an absolute url with the same origin.\n if (req.url.startsWith(`${window.location.origin}/`)) {\n return true;\n }\n\n // It's a protocol relative url with the same origin.\n // For example: //www.example.com/api/Products\n if (req.url.startsWith(`//${window.location.host}/`)) {\n return true;\n }\n\n // It's a relative url like /api/Products\n if (/^\\/[^\\/].*/.test(req.url)) {\n return true;\n }\n\n // It's an absolute or protocol relative url that\n // doesn't have the same origin.\n return false;\n }\n\n // Checks if there is an access_token available in the authorize service\n // and adds it to the request in case it's targeted at the same origin as the\n\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n return this.processRequestWithToken(this.accessToken, req, next);\n }\n\n // single page application.\n private processRequestWithToken(token: string, req: HttpRequest<any>, next: HttpHandler) {\n if (!!token && (AuthorizeInterceptor.isSameOriginUrl(req) || this.isKnownServiceUri(req))) {\n req = req.clone({\n setHeaders: {\n Authorization: `Bearer ${token}`\n }\n });\n }\n\n return next.handle(req);\n }\n\n private isKnownServiceUri(req: any) {\n\n const serviceUris = this.authorize.getServiceUris();\n\n for (let i = 0; i < serviceUris.length; i++) {\n if (req.url.startsWith(`${serviceUris[i]}`)) {\n return true;\n }\n }\n\n // It's an absolute or protocol relative url that\n // doesn't have the same origin.\n return false;\n }\n}\n","/*\n * Public API Surface of shared-auth\n */\n\nexport * from './lib/authorize.service';\nexport * from './lib/login-menu/login-menu.component';\nexport * from './lib/shared-auth.module';\nexport * from './lib/authorize.interceptor';\nexport * from './lib/authorize.guard';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.AuthorizeService"],"mappings":";;;;;;;;;;MAUa,gBAAgB,CAAA;AAc5B,CAAA;MAGY,gBAAgB,CAAA;IAO3B,WAA8C,CAAA,gBAAkC,EAAU,YAA0B,EAAA;QAAtE,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB,CAAkB;QAAU,IAAY,CAAA,YAAA,GAAZ,YAAY,CAAc;AAN5G,QAAA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C,eAAe,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE;AACzF,YAAA,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC;AACd,gBAAA,UAAU,EAAE;oBACV,aAAa,EAAE,CAAU,OAAA,EAAA,KAAK,CAAE,CAAA;AACjC,iBAAA;AACF,aAAA,CAAC,CAAC;AACJ,SAAA;AAED,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACzB;AAEO,IAAA,iBAAiB,CAAC,GAAQ,EAAA;QAEhC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;AAEpD,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC3C,YAAA,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAG,EAAA,WAAW,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC,EAAE;AAC3C,gBAAA,OAAO,IAAI,CAAC;AACb,aAAA;AACF,SAAA;;;AAID,QAAA,OAAO,KAAK,CAAC;KACd;;iHAjEU,oBAAoB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAAA,gBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;qHAApB,oBAAoB,EAAA,CAAA,CAAA;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC,UAAU;;;ACLX;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';
|
|
2
|
+
import { AuthorizeService } from './authorize.service';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class AuthorizeGuard implements CanActivate {
|
|
5
|
+
private authorize;
|
|
6
|
+
constructor(authorize: AuthorizeService);
|
|
7
|
+
canActivate(_next: ActivatedRouteSnapshot, state: RouterStateSnapshot): any;
|
|
8
|
+
private handleAuthorization;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthorizeGuard, never>;
|
|
10
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthorizeGuard>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { AuthorizeService } from './authorize.service';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class AuthorizeInterceptor implements HttpInterceptor {
|
|
6
|
+
private authorize;
|
|
7
|
+
accessToken: string;
|
|
8
|
+
constructor(authorize: AuthorizeService);
|
|
9
|
+
private static isSameOriginUrl;
|
|
10
|
+
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
|
|
11
|
+
private processRequestWithToken;
|
|
12
|
+
private isKnownServiceUri;
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthorizeInterceptor, never>;
|
|
14
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthorizeInterceptor>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { OAuthService } from "angular-oauth2-oidc";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export interface IUser {
|
|
5
|
+
name: string;
|
|
6
|
+
role: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class AuthorizeOptions {
|
|
9
|
+
wellKnownServiceUris: string[];
|
|
10
|
+
issuer: string;
|
|
11
|
+
redirectUri: string;
|
|
12
|
+
postLogoutRedirectUri: string;
|
|
13
|
+
clientId: string;
|
|
14
|
+
scope: string;
|
|
15
|
+
showDebugInformation: boolean;
|
|
16
|
+
sessionChecksEnabled: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class AuthorizeService {
|
|
19
|
+
private authorizeOptions;
|
|
20
|
+
private oauthService;
|
|
21
|
+
private isAuthenticated;
|
|
22
|
+
private isAdmin;
|
|
23
|
+
private authority;
|
|
24
|
+
private accessToken;
|
|
25
|
+
private user;
|
|
26
|
+
constructor(authorizeOptions: AuthorizeOptions, oauthService: OAuthService);
|
|
27
|
+
getServiceUris(): Array<string>;
|
|
28
|
+
getAuthority(): BehaviorSubject<string>;
|
|
29
|
+
getIsAuthenticated(): BehaviorSubject<boolean>;
|
|
30
|
+
getIsAdmin(): BehaviorSubject<boolean>;
|
|
31
|
+
getAccessToken(): BehaviorSubject<string>;
|
|
32
|
+
getUser(): BehaviorSubject<IUser>;
|
|
33
|
+
login(): void;
|
|
34
|
+
logout(): void;
|
|
35
|
+
initialize(): void;
|
|
36
|
+
private loadUser;
|
|
37
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthorizeService, never>;
|
|
38
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthorizeService>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OnInit } from '@angular/core';
|
|
2
|
+
import { AuthorizeService } from '../authorize.service';
|
|
3
|
+
import { BehaviorSubject, Observable } from 'rxjs';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class LoginMenuComponent implements OnInit {
|
|
6
|
+
private authorizeService;
|
|
7
|
+
isAuthenticated: BehaviorSubject<boolean>;
|
|
8
|
+
userName: Observable<string>;
|
|
9
|
+
isAdmin: Observable<boolean>;
|
|
10
|
+
constructor(authorizeService: AuthorizeService);
|
|
11
|
+
ngOnInit(): void;
|
|
12
|
+
login(): void;
|
|
13
|
+
logout(): void;
|
|
14
|
+
register(): void;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LoginMenuComponent, never>;
|
|
16
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<LoginMenuComponent, "app-login-menu", never, {}, {}, never, never, false>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { AuthorizeOptions } from "./authorize.service";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "./login-menu/login-menu.component";
|
|
5
|
+
import * as i2 from "@angular/common";
|
|
6
|
+
import * as i3 from "@angular/common/http";
|
|
7
|
+
import * as i4 from "angular-oauth2-oidc";
|
|
8
|
+
export declare class SharedAuthModule {
|
|
9
|
+
static forRoot(authorizeOptions: AuthorizeOptions): ModuleWithProviders<SharedAuthModule>;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SharedAuthModule, never>;
|
|
11
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<SharedAuthModule, [typeof i1.LoginMenuComponent], [typeof i2.CommonModule, typeof i3.HttpClientModule, typeof i4.OAuthModule], [typeof i1.LoginMenuComponent]>;
|
|
12
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<SharedAuthModule>;
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@meshmakers/shared-auth",
|
|
3
|
+
"version": "0.0.0-0",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"tslib": "^2.4.0"
|
|
6
|
+
},
|
|
7
|
+
"module": "fesm2015/meshmakers-shared-auth.mjs",
|
|
8
|
+
"es2020": "fesm2020/meshmakers-shared-auth.mjs",
|
|
9
|
+
"esm2020": "esm2020/meshmakers-shared-auth.mjs",
|
|
10
|
+
"fesm2020": "fesm2020/meshmakers-shared-auth.mjs",
|
|
11
|
+
"fesm2015": "fesm2015/meshmakers-shared-auth.mjs",
|
|
12
|
+
"typings": "index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": {
|
|
15
|
+
"default": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./index.d.ts",
|
|
19
|
+
"esm2020": "./esm2020/meshmakers-shared-auth.mjs",
|
|
20
|
+
"es2020": "./fesm2020/meshmakers-shared-auth.mjs",
|
|
21
|
+
"es2015": "./fesm2015/meshmakers-shared-auth.mjs",
|
|
22
|
+
"node": "./fesm2015/meshmakers-shared-auth.mjs",
|
|
23
|
+
"default": "./fesm2020/meshmakers-shared-auth.mjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false
|
|
27
|
+
}
|