@meshmakers/shared-auth 0.0.0-0 → 0.0.2304-23001

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.
@@ -1,12 +1,14 @@
1
+ import { __awaiter } from 'tslib';
1
2
  import * as i0 from '@angular/core';
2
3
  import { Injectable, Inject, Component, NgModule } from '@angular/core';
3
- import { BehaviorSubject } from 'rxjs';
4
- import { filter, map, tap } from 'rxjs/operators';
4
+ import { BehaviorSubject, firstValueFrom } from 'rxjs';
5
+ import { filter, map } from 'rxjs/operators';
5
6
  import * as i1 from 'angular-oauth2-oidc';
6
7
  import { OAuthModule } from 'angular-oauth2-oidc';
7
8
  import * as i2 from '@angular/common';
8
9
  import { CommonModule } from '@angular/common';
9
10
  import { HttpClientModule } from '@angular/common/http';
11
+ import * as i2$1 from '@angular/router';
10
12
 
11
13
  class AuthorizeOptions {
12
14
  }
@@ -16,17 +18,48 @@ class AuthorizeService {
16
18
  this.oauthService = oauthService;
17
19
  this.isAuthenticated = new BehaviorSubject(false);
18
20
  this.isAdmin = new BehaviorSubject(false);
21
+ this.isDeveloper = new BehaviorSubject(false);
22
+ this.isManager = new BehaviorSubject(false);
19
23
  this.authority = new BehaviorSubject(null);
20
24
  this.accessToken = new BehaviorSubject(null);
21
25
  this.user = new BehaviorSubject(null);
26
+ this.isInitialized = new BehaviorSubject(false);
27
+ this.isInitializing = new BehaviorSubject(false);
22
28
  console.debug("AuthorizeService::created");
23
29
  this.getUser().subscribe(s => {
24
30
  this.isAuthenticated.next(!!s);
25
- this.isAdmin.next(!!s && s.role === "Administrators");
31
+ this.isAdmin.next(!!s && (s.role.includes("Administrators")));
32
+ this.isDeveloper.next(!!s && (s.role.includes("Developers")));
33
+ this.isManager.next(!!s && s.role.includes("Managers"));
26
34
  });
35
+ this.oauthService.events.subscribe(e => {
36
+ // tslint:disable-next-line:no-console
37
+ console.debug('oauth/oidc event', e);
38
+ });
39
+ this.oauthService.events
40
+ .pipe(filter(e => e.type === 'session_terminated'))
41
+ .subscribe(_ => {
42
+ // tslint:disable-next-line:no-console
43
+ console.debug('Your session has been terminated!');
44
+ });
45
+ this.oauthService.events
46
+ .pipe(filter(e => e.type === 'token_received'))
47
+ .subscribe(_ => {
48
+ this.loadUser();
49
+ });
50
+ this.oauthService.events
51
+ .pipe(filter(e => e.type === 'logout'))
52
+ .subscribe(_ => {
53
+ this.accessToken.next(null);
54
+ this.user.next(null);
55
+ });
56
+ }
57
+ getRoles() {
58
+ return this.getUser().pipe(map(u => u != null ? u.role : new Array()));
27
59
  }
28
60
  getServiceUris() {
29
- return this.authorizeOptions.wellKnownServiceUris;
61
+ var _a;
62
+ return (_a = this.authorizeOptions.wellKnownServiceUris) !== null && _a !== void 0 ? _a : null;
30
63
  }
31
64
  getAuthority() {
32
65
  return this.authority;
@@ -37,6 +70,12 @@ class AuthorizeService {
37
70
  getIsAdmin() {
38
71
  return this.isAdmin;
39
72
  }
73
+ getIsDeveloper() {
74
+ return this.isDeveloper;
75
+ }
76
+ getIsManager() {
77
+ return this.isManager;
78
+ }
40
79
  getAccessToken() {
41
80
  return this.accessToken;
42
81
  }
@@ -50,47 +89,38 @@ class AuthorizeService {
50
89
  this.oauthService.logOut(false);
51
90
  }
52
91
  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);
92
+ var _a;
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ console.debug("AuthorizeService::initialize::started");
95
+ if (yield firstValueFrom(this.isInitializing)) {
96
+ return;
97
+ }
98
+ if (yield firstValueFrom(this.isInitialized)) {
99
+ return;
100
+ }
101
+ this.isInitializing.next(true);
102
+ const config = {
103
+ responseType: 'code',
104
+ issuer: this.authorizeOptions.issuer,
105
+ redirectUri: this.authorizeOptions.redirectUri,
106
+ postLogoutRedirectUri: this.authorizeOptions.postLogoutRedirectUri,
107
+ clientId: this.authorizeOptions.clientId,
108
+ scope: this.authorizeOptions.scope,
109
+ showDebugInformation: this.authorizeOptions.showDebugInformation,
110
+ sessionChecksEnabled: this.authorizeOptions.sessionChecksEnabled
111
+ };
112
+ this.oauthService.configure(config);
113
+ this.oauthService.setStorage(localStorage);
114
+ yield this.oauthService.loadDiscoveryDocumentAndTryLogin();
115
+ this.oauthService.setupAutomaticSilentRefresh();
116
+ if (this.oauthService.hasValidAccessToken()) {
117
+ this.loadUser();
118
+ }
119
+ this.authority.next((_a = this.authorizeOptions.issuer) !== null && _a !== void 0 ? _a : null);
120
+ this.isInitializing.next(false);
121
+ this.isInitialized.next(true);
122
+ console.debug("AuthorizeService::initialize::done");
88
123
  });
89
- if (this.oauthService.hasValidAccessToken()) {
90
- this.loadUser();
91
- }
92
- this.authority.next(this.authorizeOptions.issuer);
93
- console.debug("AuthorizeService::initialize::done");
94
124
  }
95
125
  loadUser() {
96
126
  const claims = this.oauthService.getIdentityClaims();
@@ -104,9 +134,9 @@ class AuthorizeService {
104
134
  this.accessToken.next(accessToken);
105
135
  }
106
136
  }
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: [{
137
+ AuthorizeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AuthorizeService, deps: [{ token: AuthorizeOptions }, { token: i1.OAuthService }], target: i0.ɵɵFactoryTarget.Injectable });
138
+ AuthorizeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AuthorizeService });
139
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AuthorizeService, decorators: [{
110
140
  type: Injectable
111
141
  }], ctorParameters: function () {
112
142
  return [{ type: AuthorizeOptions, decorators: [{
@@ -118,13 +148,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
118
148
  class LoginMenuComponent {
119
149
  constructor(authorizeService) {
120
150
  this.authorizeService = authorizeService;
151
+ this.isAuthenticated = this.authorizeService.getIsAuthenticated();
152
+ this.userName = this.authorizeService.getUser().pipe(map(u => u && u.name));
153
+ this.isAdmin = this.authorizeService.getIsAdmin();
121
154
  }
122
155
  ngOnInit() {
123
156
  const isIFrame = window.self !== window.top;
124
157
  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
158
  this.isAuthenticated.subscribe(x => {
129
159
  console.log(`isAuthenticated changed to ${x} (iframe ${isIFrame})`);
130
160
  });
@@ -138,32 +168,55 @@ class LoginMenuComponent {
138
168
  register() {
139
169
  }
140
170
  }
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: [{
171
+ LoginMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: LoginMenuComponent, deps: [{ token: AuthorizeService }], target: i0.ɵɵFactoryTarget.Component });
172
+ LoginMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.8", 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" }] });
173
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: LoginMenuComponent, decorators: [{
144
174
  type: Component,
145
175
  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
176
  }], ctorParameters: function () { return [{ type: AuthorizeService }]; } });
147
177
 
148
178
  class AuthorizeGuard {
149
- constructor(authorize) {
150
- this.authorize = authorize;
179
+ constructor(authorizeService, router) {
180
+ this.authorizeService = authorizeService;
181
+ this.router = router;
151
182
  }
152
- canActivate(_next, state) {
153
- return this.authorize.getIsAuthenticated()
154
- .pipe(tap(isAuthenticated => this.handleAuthorization(isAuthenticated)));
183
+ canActivate(next, state) {
184
+ let url = state.url;
185
+ return this.handleAuthorization(next, url);
155
186
  }
156
- handleAuthorization(isAuthenticated) {
157
- if (!isAuthenticated) {
158
- this.authorize.login();
159
- }
187
+ canActivateChild(next, state) {
188
+ return this.canActivate(next, state);
189
+ }
190
+ canDeactivate(component, currentRoute, currentState, nextState) {
191
+ return true;
192
+ }
193
+ canLoad(route, segments) {
194
+ return true;
195
+ }
196
+ handleAuthorization(route, url) {
197
+ return __awaiter(this, void 0, void 0, function* () {
198
+ yield this.authorizeService.initialize();
199
+ const isAuthenticated = yield firstValueFrom(this.authorizeService.getIsAuthenticated());
200
+ if (isAuthenticated) {
201
+ const userRoles = yield firstValueFrom(this.authorizeService.getRoles());
202
+ if (route.data['roles'] && !route.data['roles'].filter((value) => userRoles.includes(value))) {
203
+ this.router.navigate(['']);
204
+ return false;
205
+ }
206
+ return true;
207
+ }
208
+ else {
209
+ this.authorizeService.login();
210
+ }
211
+ return false;
212
+ });
160
213
  }
161
214
  }
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: [{
215
+ AuthorizeGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AuthorizeGuard, deps: [{ token: AuthorizeService }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
216
+ AuthorizeGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AuthorizeGuard });
217
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AuthorizeGuard, decorators: [{
165
218
  type: Injectable
166
- }], ctorParameters: function () { return [{ type: AuthorizeService }]; } });
219
+ }], ctorParameters: function () { return [{ type: AuthorizeService }, { type: i2$1.Router }]; } });
167
220
 
168
221
  class SharedAuthModule {
169
222
  static forRoot(authorizeOptions) {
@@ -180,13 +233,13 @@ class SharedAuthModule {
180
233
  };
181
234
  }
182
235
  }
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,
236
+ SharedAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SharedAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
237
+ SharedAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SharedAuthModule, declarations: [LoginMenuComponent], imports: [CommonModule,
185
238
  HttpClientModule, i1.OAuthModule], exports: [LoginMenuComponent] });
186
- SharedAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, imports: [CommonModule,
239
+ SharedAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SharedAuthModule, imports: [CommonModule,
187
240
  HttpClientModule,
188
241
  OAuthModule.forRoot()] });
189
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: SharedAuthModule, decorators: [{
242
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SharedAuthModule, decorators: [{
190
243
  type: NgModule,
191
244
  args: [{
192
245
  declarations: [LoginMenuComponent],
@@ -203,6 +256,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
203
256
  class AuthorizeInterceptor {
204
257
  constructor(authorize) {
205
258
  this.authorize = authorize;
259
+ this.accessToken = null;
206
260
  authorize.getAccessToken().subscribe(value => this.accessToken = value);
207
261
  }
208
262
  static isSameOriginUrl(req) {
@@ -241,9 +295,11 @@ class AuthorizeInterceptor {
241
295
  }
242
296
  isKnownServiceUri(req) {
243
297
  const serviceUris = this.authorize.getServiceUris();
244
- for (let i = 0; i < serviceUris.length; i++) {
245
- if (req.url.startsWith(`${serviceUris[i]}`)) {
246
- return true;
298
+ if (serviceUris) {
299
+ for (let i = 0; i < serviceUris.length; i++) {
300
+ if (req.url.startsWith(`${serviceUris[i]}`)) {
301
+ return true;
302
+ }
247
303
  }
248
304
  }
249
305
  // It's an absolute or protocol relative url that
@@ -251,9 +307,9 @@ class AuthorizeInterceptor {
251
307
  return false;
252
308
  }
253
309
  }
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: [{
310
+ AuthorizeInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AuthorizeInterceptor, deps: [{ token: AuthorizeService }], target: i0.ɵɵFactoryTarget.Injectable });
311
+ AuthorizeInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AuthorizeInterceptor });
312
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AuthorizeInterceptor, decorators: [{
257
313
  type: Injectable
258
314
  }], ctorParameters: function () { return [{ type: AuthorizeService }]; } });
259
315
 
@@ -1 +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,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,IAAG;YAC3B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B,YAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC;AACxD,SAAC,CAAC,CAAC;KACJ;IAEM,cAAc,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,C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AAoB,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;;;;"}
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, firstValueFrom, Observable} from 'rxjs';\nimport {filter, map} 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 isDeveloper: BehaviorSubject<boolean> = new BehaviorSubject(false);\n private isManager: BehaviorSubject<boolean> = new BehaviorSubject(false);\n private authority: BehaviorSubject<string | null> = new BehaviorSubject<string | null>(null);\n private accessToken: BehaviorSubject<string | null> = new BehaviorSubject<string | null>(null);\n private user: BehaviorSubject<IUser | null> = new BehaviorSubject<IUser | null>(null);\n private isInitialized : BehaviorSubject<boolean> = new BehaviorSubject(false);\n private isInitializing : BehaviorSubject<boolean> = new BehaviorSubject(false);\n\n constructor(@Inject(AuthorizeOptions) private authorizeOptions: AuthorizeOptions, private oauthService: OAuthService) {\n console.debug(\"AuthorizeService::created\");\n\n this.getUser().subscribe(s => {\n this.isAuthenticated.next(!!s);\n this.isAdmin.next(!!s && (s.role.includes(\"Administrators\")));\n this.isDeveloper.next(!!s && (s.role.includes(\"Developers\")));\n this.isManager.next(!!s && s.role.includes(\"Managers\"));\n });\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(_ => {\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(_ => {\n this.loadUser();\n });\n\n this.oauthService.events\n .pipe(filter(e => e.type === 'logout'))\n .subscribe(_ => {\n this.accessToken.next(null);\n this.user.next(null);\n });\n\n }\n\n public getRoles(): Observable<Array<string>>{\n return this.getUser().pipe(\n map(u=> u != null ? u.role : new Array<string>())\n );\n }\n\n public getServiceUris(): Array<string> | null {\n return this.authorizeOptions.wellKnownServiceUris ?? null;\n }\n\n public getAuthority(): BehaviorSubject<string | null> {\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 getIsDeveloper(): BehaviorSubject<boolean> {\n return this.isDeveloper;\n }\n\n public getIsManager(): BehaviorSubject<boolean> {\n return this.isManager;\n }\n\n public getAccessToken(): BehaviorSubject<string | null> {\n return this.accessToken;\n }\n\n public getUser(): BehaviorSubject<IUser | null> {\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 async initialize() {\n\n console.debug(\"AuthorizeService::initialize::started\");\n\n if (await firstValueFrom(this.isInitializing)) {\n return\n }\n if (await firstValueFrom(this.isInitialized)) {\n return;\n }\n this.isInitializing.next(true);\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 await this.oauthService.loadDiscoveryDocumentAndTryLogin();\n\n this.oauthService.setupAutomaticSilentRefresh();\n\n if (this.oauthService.hasValidAccessToken()) {\n this.loadUser();\n }\n\n this.authority.next(this.authorizeOptions.issuer ?? null);\n this.isInitializing.next(false);\n this.isInitialized.next(true);\n\n console.debug(\"AuthorizeService::initialize::done\");\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 | null>;\n public isAdmin: Observable<boolean>;\n\n constructor(private authorizeService: AuthorizeService) {\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\n ngOnInit() {\n const isIFrame = window.self !== window.top;\n\n console.log(\"app-login-menu::created\");\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 {\n ActivatedRouteSnapshot,\n CanActivate,\n CanActivateChild,\n CanDeactivate,\n CanLoad, Route,\n Router,\n RouterStateSnapshot, UrlSegment,\n UrlTree\n} from '@angular/router';\nimport {AuthorizeService} from './authorize.service';\nimport {firstValueFrom, lastValueFrom, Observable} from \"rxjs\";\n\n@Injectable()\nexport class AuthorizeGuard implements CanActivate, CanActivateChild, CanDeactivate<unknown>, CanLoad {\n constructor(private authorizeService: AuthorizeService, private router: Router) {\n }\n\n canActivate(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {\n let url: string = state.url;\n return this.handleAuthorization(next, url);\n }\n\n canActivateChild(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {\n return this.canActivate(next, state);\n }\n\n canDeactivate(\n component: unknown,\n currentRoute: ActivatedRouteSnapshot,\n currentState: RouterStateSnapshot,\n nextState?: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {\n return true;\n }\n\n canLoad(\n route: Route,\n segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {\n return true;\n }\n\n private async handleAuthorization(route: ActivatedRouteSnapshot, url: any): Promise<boolean> {\n\n await this.authorizeService.initialize()\n\n const isAuthenticated = await firstValueFrom(this.authorizeService.getIsAuthenticated());\n if (isAuthenticated) {\n const userRoles = await firstValueFrom(this.authorizeService.getRoles());\n if (route.data['roles'] && !route.data['roles'].filter((value: string) => userRoles.includes(value))) {\n this.router.navigate(['']);\n return false;\n }\n return true;\n } else {\n this.authorizeService.login();\n }\n\n return false;\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 | null;\n\n constructor(private authorize: AuthorizeService) {\n\n this.accessToken = null;\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 | null, 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 if (serviceUris) {\n for (let i = 0; i < serviceUris.length; i++) {\n if (req.url.startsWith(`${serviceUris[i]}`)) {\n return true;\n }\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.AuthorizeService","i2"],"mappings":";;;;;;;;;;;;MAUa,gBAAgB,CAAA;AAc5B,CAAA;MAGY,gBAAgB,CAAA;IAW3B,WAA8C,CAAA,gBAAkC,EAAU,YAA0B,EAAA;AAAtE,QAAA,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB,CAAkB;AAAU,QAAA,IAAY,CAAA,YAAA,GAAZ,YAAY,CAAc;QAV5G,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,WAAW,GAA6B,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;QACnE,IAAA,CAAA,SAAS,GAA6B,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;QACjE,IAAA,CAAA,SAAS,GAAmC,IAAI,eAAe,CAAgB,IAAI,CAAC,CAAC;QACrF,IAAA,CAAA,WAAW,GAAmC,IAAI,eAAe,CAAgB,IAAI,CAAC,CAAC;QACvF,IAAA,CAAA,IAAI,GAAkC,IAAI,eAAe,CAAe,IAAI,CAAC,CAAC;QAC9E,IAAA,CAAA,aAAa,GAA8B,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;QACtE,IAAA,CAAA,cAAc,GAA8B,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AAG7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