@meshmakers/shared-auth 3.2.137-0 → 3.2.145-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/fesm2022/meshmakers-shared-auth.mjs +117 -85
- package/fesm2022/meshmakers-shared-auth.mjs.map +1 -1
- package/index.d.ts +20 -12
- package/package.json +3 -3
|
@@ -27,57 +27,69 @@ class AuthorizeOptions {
|
|
|
27
27
|
}
|
|
28
28
|
class AuthorizeService {
|
|
29
29
|
oauthService = inject(OAuthService);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
_isAuthenticated = new BehaviorSubject(false);
|
|
31
|
+
_issuer = new BehaviorSubject(null);
|
|
32
|
+
_accessToken = new BehaviorSubject(null);
|
|
33
|
+
_user = new BehaviorSubject(null);
|
|
34
|
+
_userInitials = new BehaviorSubject(null);
|
|
35
|
+
_isInitialized = new BehaviorSubject(false);
|
|
36
|
+
_isInitializing = new BehaviorSubject(false);
|
|
37
|
+
_sessionLoading = new BehaviorSubject(false);
|
|
36
38
|
authorizeOptions = null;
|
|
37
39
|
constructor() {
|
|
38
40
|
console.debug("AuthorizeService::created");
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
+
this.oauthService.discoveryDocumentLoaded$.subscribe((_) => {
|
|
42
|
+
console.debug("discoveryDocumentLoaded$");
|
|
41
43
|
});
|
|
42
44
|
this.oauthService.events.subscribe((e) => {
|
|
43
45
|
console.debug("oauth/oidc event", e);
|
|
44
46
|
});
|
|
45
47
|
this.oauthService.events.pipe(filter((e) => e.type === "session_terminated")).subscribe((_) => {
|
|
46
48
|
console.debug("Your session has been terminated!");
|
|
49
|
+
this._accessToken.next(null);
|
|
50
|
+
this._user.next(null);
|
|
51
|
+
this._isAuthenticated.next(false);
|
|
47
52
|
});
|
|
48
|
-
this.oauthService.events.pipe(filter((e) => e.type === "token_received")).subscribe((_) => {
|
|
49
|
-
this.
|
|
53
|
+
this.oauthService.events.pipe(filter((e) => e.type === "token_received")).subscribe(async (_) => {
|
|
54
|
+
await this.loadUserAsync();
|
|
50
55
|
});
|
|
51
|
-
this.oauthService.events.pipe(filter((e) => e.type === "session_unchanged")).subscribe((_) => {
|
|
52
|
-
if (this.
|
|
53
|
-
this.
|
|
56
|
+
this.oauthService.events.pipe(filter((e) => e.type === "session_unchanged")).subscribe(async (_) => {
|
|
57
|
+
if (this._user.value == null) {
|
|
58
|
+
await this.loadUserAsync();
|
|
54
59
|
}
|
|
55
60
|
});
|
|
56
61
|
this.oauthService.events.pipe(filter((e) => e.type === "logout")).subscribe((_) => {
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
62
|
+
this._accessToken.next(null);
|
|
63
|
+
this._user.next(null);
|
|
64
|
+
this._isAuthenticated.next(false);
|
|
59
65
|
});
|
|
60
66
|
}
|
|
61
67
|
isInRole(role) {
|
|
62
|
-
return this.
|
|
68
|
+
return this._user?.value?.role?.includes(role) ?? false;
|
|
63
69
|
}
|
|
64
70
|
getRoles() {
|
|
65
|
-
return this.
|
|
71
|
+
return this.user.pipe(map((u) => (u?.role != null ? u.role : new Array())));
|
|
66
72
|
}
|
|
67
73
|
getServiceUris() {
|
|
68
74
|
return this.authorizeOptions?.wellKnownServiceUris ?? null;
|
|
69
75
|
}
|
|
70
|
-
|
|
71
|
-
return this.
|
|
76
|
+
get issuer() {
|
|
77
|
+
return this._issuer;
|
|
72
78
|
}
|
|
73
|
-
|
|
74
|
-
return this.
|
|
79
|
+
get isAuthenticated() {
|
|
80
|
+
return this._isAuthenticated;
|
|
75
81
|
}
|
|
76
|
-
|
|
77
|
-
return this.
|
|
82
|
+
get sessionLoading() {
|
|
83
|
+
return this._sessionLoading;
|
|
78
84
|
}
|
|
79
|
-
|
|
80
|
-
return this.
|
|
85
|
+
get accessToken() {
|
|
86
|
+
return this._accessToken;
|
|
87
|
+
}
|
|
88
|
+
get user() {
|
|
89
|
+
return this._user;
|
|
90
|
+
}
|
|
91
|
+
get userInitials() {
|
|
92
|
+
return this._userInitials;
|
|
81
93
|
}
|
|
82
94
|
login() {
|
|
83
95
|
this.oauthService.initImplicitFlow();
|
|
@@ -88,14 +100,14 @@ class AuthorizeService {
|
|
|
88
100
|
async initialize(authorizeOptions) {
|
|
89
101
|
console.debug("AuthorizeService::initialize::started");
|
|
90
102
|
await this.uninitialize();
|
|
91
|
-
if (await firstValueFrom(this.
|
|
103
|
+
if (await firstValueFrom(this._isInitializing)) {
|
|
92
104
|
return;
|
|
93
105
|
}
|
|
94
|
-
if (await firstValueFrom(this.
|
|
106
|
+
if (await firstValueFrom(this._isInitialized)) {
|
|
95
107
|
console.debug("AuthorizeService::initialize::alreadyInitialized");
|
|
96
108
|
return;
|
|
97
109
|
}
|
|
98
|
-
this.
|
|
110
|
+
this._isInitializing.next(true);
|
|
99
111
|
try {
|
|
100
112
|
const config = {
|
|
101
113
|
responseType: "code",
|
|
@@ -106,65 +118,84 @@ class AuthorizeService {
|
|
|
106
118
|
scope: authorizeOptions.scope,
|
|
107
119
|
showDebugInformation: authorizeOptions.showDebugInformation,
|
|
108
120
|
sessionChecksEnabled: authorizeOptions.sessionChecksEnabled,
|
|
121
|
+
sessionCheckIntervall: 60 * 1000,
|
|
109
122
|
preserveRequestedRoute: true
|
|
110
123
|
};
|
|
111
124
|
this.authorizeOptions = authorizeOptions;
|
|
112
|
-
this.oauthService.configure(config);
|
|
113
125
|
this.oauthService.setStorage(localStorage);
|
|
126
|
+
this.oauthService.configure(config);
|
|
114
127
|
console.debug("AuthorizeService::initialize::loadingDiscoveryDocumentAndTryLogin");
|
|
115
128
|
await this.oauthService.loadDiscoveryDocumentAndTryLogin();
|
|
116
129
|
console.debug("AuthorizeService::initialize::setupAutomaticSilentRefresh");
|
|
117
130
|
this.oauthService.setupAutomaticSilentRefresh();
|
|
118
|
-
this.
|
|
119
|
-
this.
|
|
131
|
+
this._issuer.next(authorizeOptions.issuer ?? null);
|
|
132
|
+
if (this.oauthService.hasValidIdToken()) {
|
|
133
|
+
// if the idToken is still valid, we can use the session
|
|
134
|
+
console.debug("AuthorizeService::initialize::hasValidIdToken");
|
|
135
|
+
this._sessionLoading.next(true);
|
|
136
|
+
await this.oauthService.refreshToken();
|
|
137
|
+
}
|
|
138
|
+
this._isInitialized.next(true);
|
|
120
139
|
console.debug("AuthorizeService::initialize::done");
|
|
121
140
|
}
|
|
122
141
|
finally {
|
|
123
|
-
this.
|
|
142
|
+
this._isInitializing.next(false);
|
|
124
143
|
}
|
|
125
144
|
console.debug("AuthorizeService::initialize::completed");
|
|
126
145
|
}
|
|
127
146
|
async uninitialize() {
|
|
128
147
|
console.debug("AuthorizeService::uninitialize::started");
|
|
129
|
-
if (await firstValueFrom(this.
|
|
148
|
+
if (await firstValueFrom(this._isInitializing)) {
|
|
130
149
|
return;
|
|
131
150
|
}
|
|
132
|
-
if (!await firstValueFrom(this.
|
|
151
|
+
if (!await firstValueFrom(this._isInitialized)) {
|
|
133
152
|
console.debug("AuthorizeService::uninitialize::alreadyUninitialized");
|
|
134
153
|
return;
|
|
135
154
|
}
|
|
136
155
|
try {
|
|
137
|
-
this.
|
|
156
|
+
this._isInitializing.next(true);
|
|
138
157
|
this.oauthService.stopAutomaticRefresh();
|
|
139
158
|
this.authorizeOptions = null;
|
|
140
|
-
this.
|
|
159
|
+
this._isInitialized.next(false);
|
|
141
160
|
console.debug("AuthorizeService::uninitialize::done");
|
|
142
161
|
}
|
|
143
162
|
finally {
|
|
144
|
-
this.
|
|
163
|
+
this._isInitializing.next(false);
|
|
145
164
|
}
|
|
146
165
|
console.debug("AuthorizeService::uninitialize::completed");
|
|
147
166
|
}
|
|
148
|
-
|
|
167
|
+
async loadUserAsync() {
|
|
149
168
|
const claims = this.oauthService.getIdentityClaims();
|
|
150
169
|
if (!claims) {
|
|
151
170
|
console.error("claims where null when loading identity claims");
|
|
152
171
|
return;
|
|
153
172
|
}
|
|
154
173
|
const user = claims;
|
|
174
|
+
if (user.family_name && user.given_name) {
|
|
175
|
+
const initials = user.given_name.charAt(0) + user.family_name.charAt(0);
|
|
176
|
+
this._userInitials.next(initials);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
this._userInitials.next(user.name.charAt(0) + user.name.charAt(1));
|
|
180
|
+
}
|
|
155
181
|
const accessToken = this.oauthService.getAccessToken();
|
|
156
|
-
this.
|
|
157
|
-
this.
|
|
182
|
+
this._user.next(user);
|
|
183
|
+
this._accessToken.next(accessToken);
|
|
184
|
+
this._isAuthenticated.next(true);
|
|
185
|
+
this._sessionLoading.next(false);
|
|
186
|
+
console.debug("AuthorizeService::loadUserAsync::done");
|
|
158
187
|
}
|
|
159
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.
|
|
160
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.
|
|
188
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AuthorizeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
189
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AuthorizeService });
|
|
161
190
|
}
|
|
162
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.
|
|
191
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AuthorizeService, decorators: [{
|
|
163
192
|
type: Injectable
|
|
164
193
|
}], ctorParameters: () => [] });
|
|
165
194
|
|
|
166
195
|
var Roles;
|
|
167
196
|
(function (Roles) {
|
|
197
|
+
Roles["ReportingManagement"] = "ReportingManagement";
|
|
198
|
+
Roles["ReportingViewer"] = "ReportingViewer";
|
|
168
199
|
Roles["AdminPanelManagement"] = "AdminPanelManagement";
|
|
169
200
|
Roles["BotManagement"] = "BotManagement";
|
|
170
201
|
Roles["UserManagement"] = "UserManagement";
|
|
@@ -178,8 +209,8 @@ class LoginMenuComponent {
|
|
|
178
209
|
isAuthenticated;
|
|
179
210
|
userName;
|
|
180
211
|
constructor() {
|
|
181
|
-
this.isAuthenticated = this.authorizeService.
|
|
182
|
-
this.userName = this.authorizeService.
|
|
212
|
+
this.isAuthenticated = this.authorizeService.isAuthenticated;
|
|
213
|
+
this.userName = this.authorizeService.user.pipe(map((u) => u?.name ?? null));
|
|
183
214
|
}
|
|
184
215
|
ngOnInit() {
|
|
185
216
|
const isIFrame = window.self !== window.top;
|
|
@@ -195,10 +226,10 @@ class LoginMenuComponent {
|
|
|
195
226
|
this.authorizeService.logout();
|
|
196
227
|
}
|
|
197
228
|
register() { }
|
|
198
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.
|
|
199
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.2.
|
|
229
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: LoginMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
230
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.2.4", type: LoginMenuComponent, isStandalone: false, selector: "mm-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: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] });
|
|
200
231
|
}
|
|
201
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.
|
|
232
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: LoginMenuComponent, decorators: [{
|
|
202
233
|
type: Component,
|
|
203
234
|
args: [{ selector: 'mm-login-menu', standalone: false, 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" }]
|
|
204
235
|
}], ctorParameters: () => [] });
|
|
@@ -220,10 +251,10 @@ class AuthorizeGuard {
|
|
|
220
251
|
return true;
|
|
221
252
|
}
|
|
222
253
|
async handleAuthorization(route, _url) {
|
|
223
|
-
const isAuthenticated = await firstValueFrom(this.authorizeService.
|
|
254
|
+
const isAuthenticated = await firstValueFrom(this.authorizeService.isAuthenticated);
|
|
224
255
|
if (isAuthenticated) {
|
|
225
256
|
const userRoles = await firstValueFrom(this.authorizeService.getRoles());
|
|
226
|
-
if (route.data['roles'] && !route.data['roles'].
|
|
257
|
+
if (route.data['roles'] && !route.data['roles'].some((role) => userRoles.includes(role))) {
|
|
227
258
|
await this.router.navigate(['']);
|
|
228
259
|
return false;
|
|
229
260
|
}
|
|
@@ -234,48 +265,20 @@ class AuthorizeGuard {
|
|
|
234
265
|
}
|
|
235
266
|
return false;
|
|
236
267
|
}
|
|
237
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.
|
|
238
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.
|
|
268
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AuthorizeGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
269
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AuthorizeGuard });
|
|
239
270
|
}
|
|
240
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.
|
|
271
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AuthorizeGuard, decorators: [{
|
|
241
272
|
type: Injectable
|
|
242
273
|
}] });
|
|
243
274
|
|
|
244
|
-
class SharedAuthModule {
|
|
245
|
-
static forRoot(authorizeOptions) {
|
|
246
|
-
return {
|
|
247
|
-
ngModule: SharedAuthModule,
|
|
248
|
-
providers: [
|
|
249
|
-
{
|
|
250
|
-
provide: AuthorizeOptions,
|
|
251
|
-
useValue: authorizeOptions
|
|
252
|
-
},
|
|
253
|
-
AuthorizeService,
|
|
254
|
-
AuthorizeGuard
|
|
255
|
-
]
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: SharedAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
259
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.2.3", ngImport: i0, type: SharedAuthModule, declarations: [LoginMenuComponent], imports: [CommonModule, HttpClientModule, i1$1.OAuthModule, RouterLink], exports: [LoginMenuComponent] });
|
|
260
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: SharedAuthModule, imports: [CommonModule, HttpClientModule, OAuthModule.forRoot()] });
|
|
261
|
-
}
|
|
262
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: SharedAuthModule, decorators: [{
|
|
263
|
-
type: NgModule,
|
|
264
|
-
args: [{
|
|
265
|
-
declarations: [LoginMenuComponent],
|
|
266
|
-
exports: [LoginMenuComponent],
|
|
267
|
-
providers: [],
|
|
268
|
-
imports: [CommonModule, HttpClientModule, OAuthModule.forRoot(), RouterLink]
|
|
269
|
-
}]
|
|
270
|
-
}] });
|
|
271
|
-
|
|
272
275
|
class AuthorizeInterceptor {
|
|
273
276
|
authorize = inject(AuthorizeService);
|
|
274
277
|
accessToken;
|
|
275
278
|
constructor() {
|
|
276
279
|
const authorize = this.authorize;
|
|
277
280
|
this.accessToken = null;
|
|
278
|
-
authorize.
|
|
281
|
+
authorize.accessToken.subscribe((value) => (this.accessToken = value));
|
|
279
282
|
}
|
|
280
283
|
static isSameOriginUrl(req) {
|
|
281
284
|
// It's an absolute url with the same origin.
|
|
@@ -324,13 +327,42 @@ class AuthorizeInterceptor {
|
|
|
324
327
|
// doesn't have the same origin.
|
|
325
328
|
return false;
|
|
326
329
|
}
|
|
327
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.
|
|
328
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.
|
|
330
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AuthorizeInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
331
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AuthorizeInterceptor });
|
|
329
332
|
}
|
|
330
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.
|
|
333
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AuthorizeInterceptor, decorators: [{
|
|
331
334
|
type: Injectable
|
|
332
335
|
}], ctorParameters: () => [] });
|
|
333
336
|
|
|
337
|
+
class SharedAuthModule {
|
|
338
|
+
static forRoot(authorizeOptions) {
|
|
339
|
+
return {
|
|
340
|
+
ngModule: SharedAuthModule,
|
|
341
|
+
providers: [
|
|
342
|
+
{
|
|
343
|
+
provide: AuthorizeOptions,
|
|
344
|
+
useValue: authorizeOptions
|
|
345
|
+
},
|
|
346
|
+
AuthorizeService,
|
|
347
|
+
AuthorizeInterceptor,
|
|
348
|
+
AuthorizeGuard
|
|
349
|
+
]
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: SharedAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
353
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.2.4", ngImport: i0, type: SharedAuthModule, declarations: [LoginMenuComponent], imports: [CommonModule, HttpClientModule, i1$1.OAuthModule, RouterLink], exports: [LoginMenuComponent] });
|
|
354
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: SharedAuthModule, imports: [CommonModule, HttpClientModule, OAuthModule.forRoot()] });
|
|
355
|
+
}
|
|
356
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: SharedAuthModule, decorators: [{
|
|
357
|
+
type: NgModule,
|
|
358
|
+
args: [{
|
|
359
|
+
declarations: [LoginMenuComponent],
|
|
360
|
+
exports: [LoginMenuComponent],
|
|
361
|
+
providers: [],
|
|
362
|
+
imports: [CommonModule, HttpClientModule, OAuthModule.forRoot(), RouterLink]
|
|
363
|
+
}]
|
|
364
|
+
}] });
|
|
365
|
+
|
|
334
366
|
/*
|
|
335
367
|
* Public API Surface of shared-auth
|
|
336
368
|
*/
|
|
@@ -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/roles.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 { Injectable, inject } from \"@angular/core\";\nimport { BehaviorSubject, firstValueFrom, Observable } from \"rxjs\";\nimport { filter, map } from \"rxjs/operators\";\nimport { AuthConfig, OAuthService } from \"angular-oauth2-oidc\";\nimport { Roles } from \"./roles\";\n\nexport interface IUser {\n name: string;\n role: string[];\n sub: string;\n idp: string;\n email: string | null;\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 readonly oauthService = inject(OAuthService);\n\n private readonly isAuthenticated = new BehaviorSubject<boolean>(false);\n private readonly authority: BehaviorSubject<string | null> = new BehaviorSubject<string | null>(null);\n\n private readonly accessToken: BehaviorSubject<string | null> = new BehaviorSubject<string | null>(null);\n\n private readonly user: BehaviorSubject<IUser | null> = new BehaviorSubject<IUser | null>(null);\n\n private readonly isInitialized = new BehaviorSubject<boolean>(false);\n private readonly isInitializing = new BehaviorSubject<boolean>(false);\n\n private authorizeOptions: AuthorizeOptions | null = null;\n\n constructor() {\n console.debug(\"AuthorizeService::created\");\n\n this.getUser().subscribe((s) => {\n this.isAuthenticated.next(!(s == null));\n });\n\n this.oauthService.events.subscribe((e) => {\n console.debug(\"oauth/oidc event\", e);\n });\n\n this.oauthService.events.pipe(filter((e) => e.type === \"session_terminated\")).subscribe((_) => {\n console.debug(\"Your session has been terminated!\");\n });\n\n this.oauthService.events.pipe(filter((e) => e.type === \"token_received\")).subscribe((_) => {\n this.loadUser();\n });\n\n this.oauthService.events.pipe(filter((e) => e.type === \"session_unchanged\")).subscribe((_) => {\n if (this.user.value == null) {\n this.loadUser();\n }\n });\n\n this.oauthService.events.pipe(filter((e) => e.type === \"logout\")).subscribe((_) => {\n this.accessToken.next(null);\n this.user.next(null);\n });\n }\n\n public isInRole(role: Roles): boolean {\n return this.user?.value?.role.includes(role) ?? false;\n }\n\n public getRoles(): Observable<string[]> {\n return this.getUser().pipe(map((u) => (u != null ? u.role : new Array<string>())));\n }\n\n public getServiceUris(): string[] | null {\n return this.authorizeOptions?.wellKnownServiceUris ?? null;\n }\n\n public getAuthority(): Observable<string | null> {\n return this.authority;\n }\n\n public getIsAuthenticated(): Observable<boolean> {\n return this.isAuthenticated;\n }\n\n public getAccessToken(): Observable<string | null> {\n return this.accessToken;\n }\n\n public getUser(): Observable<IUser | null> {\n return this.user;\n }\n\n public login(): void {\n this.oauthService.initImplicitFlow();\n }\n\n public logout(): void {\n this.oauthService.logOut(false);\n }\n\n public async initialize(authorizeOptions: AuthorizeOptions): Promise<void> {\n console.debug(\"AuthorizeService::initialize::started\");\n\n await this.uninitialize();\n\n if (await firstValueFrom(this.isInitializing)) {\n return;\n }\n if (await firstValueFrom(this.isInitialized)) {\n console.debug(\"AuthorizeService::initialize::alreadyInitialized\");\n return;\n }\n this.isInitializing.next(true);\n\n try {\n const config: AuthConfig = {\n responseType: \"code\",\n issuer: authorizeOptions.issuer,\n redirectUri: authorizeOptions.redirectUri,\n postLogoutRedirectUri: authorizeOptions.postLogoutRedirectUri,\n clientId: authorizeOptions.clientId,\n scope: authorizeOptions.scope,\n showDebugInformation: authorizeOptions.showDebugInformation,\n sessionChecksEnabled: authorizeOptions.sessionChecksEnabled,\n preserveRequestedRoute: true\n };\n\n this.authorizeOptions = authorizeOptions;\n\n this.oauthService.configure(config);\n this.oauthService.setStorage(localStorage);\n console.debug(\"AuthorizeService::initialize::loadingDiscoveryDocumentAndTryLogin\");\n await this.oauthService.loadDiscoveryDocumentAndTryLogin();\n\n console.debug(\"AuthorizeService::initialize::setupAutomaticSilentRefresh\");\n this.oauthService.setupAutomaticSilentRefresh();\n\n this.authority.next(authorizeOptions.issuer ?? null);\n\n\n this.isInitialized.next(true);\n console.debug(\"AuthorizeService::initialize::done\");\n }\n finally {\n this.isInitializing.next(false);\n }\n\n console.debug(\"AuthorizeService::initialize::completed\");\n }\n\n public async uninitialize(): Promise<void> {\n console.debug(\"AuthorizeService::uninitialize::started\");\n\n if (await firstValueFrom(this.isInitializing)) {\n return;\n }\n if (!await firstValueFrom(this.isInitialized)) {\n console.debug(\"AuthorizeService::uninitialize::alreadyUninitialized\");\n return;\n }\n\n try {\n this.isInitializing.next(true);\n\n this.oauthService.stopAutomaticRefresh();\n\n this.authorizeOptions = null;\n\n this.isInitialized.next(false);\n console.debug(\"AuthorizeService::uninitialize::done\");\n }\n finally {\n this.isInitializing.next(false);\n }\n\n console.debug(\"AuthorizeService::uninitialize::completed\");\n }\n\n private loadUser(): void {\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 = claims as IUser;\n const accessToken = this.oauthService.getAccessToken();\n this.user.next(user);\n this.accessToken.next(accessToken);\n }\n}\n","export enum Roles {\n AdminPanelManagement = 'AdminPanelManagement',\n BotManagement = 'BotManagement',\n UserManagement = 'UserManagement',\n CommunicationManagement = 'CommunicationManagement',\n TenantManagement = 'TenantManagement',\n Development = 'Development'\n}\n","import { Component, OnInit, inject } from '@angular/core';\nimport { AuthorizeService } from '../authorize.service';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n@Component({\n selector: 'mm-login-menu',\n standalone: false,\n templateUrl: './login-menu.component.html',\n styleUrls: ['./login-menu.component.css']\n})\nexport class LoginMenuComponent implements OnInit {\n private readonly authorizeService = inject(AuthorizeService);\n\n public isAuthenticated: Observable<boolean>;\n public userName: Observable<string | null>;\n\n constructor() {\n this.isAuthenticated = this.authorizeService.getIsAuthenticated();\n this.userName = this.authorizeService.getUser().pipe(map((u) => u?.name ?? null));\n }\n\n ngOnInit(): void {\n const isIFrame = window.self !== window.top;\n\n console.log('app-login-menu::created');\n\n this.isAuthenticated.subscribe((x) => {\n console.log(`isAuthenticated changed to ${x} (iframe ${isIFrame})`);\n });\n }\n\n public login(): void {\n this.authorizeService.login();\n }\n\n public logout(): void {\n this.authorizeService.logout();\n }\n\n public register(): void {}\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, inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, Route, Router, RouterStateSnapshot, UrlSegment, UrlTree } from '@angular/router';\nimport { AuthorizeService } from './authorize.service';\nimport { firstValueFrom, Observable } from 'rxjs';\n\n@Injectable()\nexport class AuthorizeGuard {\n private readonly authorizeService = inject(AuthorizeService);\n private readonly router = inject(Router);\n\n\n canActivate(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot\n ): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {\n const url: string = state.url;\n return this.handleAuthorization(next, url);\n }\n\n canActivateChild(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot\n ): 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\n ): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {\n return true;\n }\n\n canLoad(_route: Route, _segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {\n return true;\n }\n\n private async handleAuthorization(route: ActivatedRouteSnapshot, _url: any): Promise<boolean> {\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 await 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';\nimport { RouterLink } from '@angular/router';\n\n@NgModule({\n declarations: [LoginMenuComponent],\n exports: [LoginMenuComponent],\n providers: [],\n imports: [CommonModule, HttpClientModule, OAuthModule.forRoot(), RouterLink]\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, inject } 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 private readonly authorize = inject(AuthorizeService);\n\n accessToken: string | null;\n\n constructor() {\n const authorize = this.authorize;\n\n this.accessToken = null;\n authorize.getAccessToken().subscribe((value) => (this.accessToken = value));\n }\n\n private static isSameOriginUrl(req: HttpRequest<any>): boolean {\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): Observable<HttpEvent<any>> {\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): boolean {\n const serviceUris = this.authorize.getServiceUris();\n\n if (serviceUris != null) {\n for (const serviceUri of serviceUris) {\n if (req.url.startsWith(`${serviceUri}`)) {\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/roles';\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"],"mappings":";;;;;;;;;;;;MAca,gBAAgB,CAAA;AAC3B,IAAA,oBAAoB;;AAEpB,IAAA,MAAM;;AAEN,IAAA,WAAW;AACX,IAAA,qBAAqB;;AAErB,IAAA,QAAQ;;;AAGR,IAAA,KAAK;AACL,IAAA,oBAAoB;AACpB,IAAA,oBAAoB;AACrB;MAGY,gBAAgB,CAAA;AACV,IAAA,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AAEnC,IAAA,eAAe,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC;AACrD,IAAA,SAAS,GAAmC,IAAI,eAAe,CAAgB,IAAI,CAAC;AAEpF,IAAA,WAAW,GAAmC,IAAI,eAAe,CAAgB,IAAI,CAAC;AAEtF,IAAA,IAAI,GAAkC,IAAI,eAAe,CAAe,IAAI,CAAC;AAE7E,IAAA,aAAa,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC;AACnD,IAAA,cAAc,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC;IAE7D,gBAAgB,GAA4B,IAAI;AAExD,IAAA,WAAA,GAAA;AACE,QAAA,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC;QAE1C,IAAI,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,KAAI;AAC7B,YAAA,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC;AACzC,QAAA,CAAC,CAAC;QAEF,IAAI,CAAC,YAAY,CAA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,UAAU,CAAA,CAAE,CAAC,EAAE;AACvC,oBAAA,OAAO,IAAI;gBACb;YACF;QACF;;;AAIA,QAAA,OAAO,KAAK;IACd;uGApEW,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAApB,oBAAoB,EAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC;;;ACLD;;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/roles.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/authorize.interceptor.ts","../../../../projects/meshmakers/shared-auth/src/lib/shared-auth.module.ts","../../../../projects/meshmakers/shared-auth/src/public-api.ts","../../../../projects/meshmakers/shared-auth/src/meshmakers-shared-auth.ts"],"sourcesContent":["import { Injectable, inject } from \"@angular/core\";\nimport { BehaviorSubject, firstValueFrom, Observable } from \"rxjs\";\nimport { filter, map } from \"rxjs/operators\";\nimport { AuthConfig, OAuthService } from \"angular-oauth2-oidc\";\nimport { Roles } from \"./roles\";\n\nexport interface IUser {\n family_name: string | null;\n given_name: string | null;\n name: string;\n role: string[] | null;\n sub: string;\n idp: string;\n email: string | null;\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 readonly oauthService = inject(OAuthService);\n\n private readonly _isAuthenticated = new BehaviorSubject<boolean>(false);\n private readonly _issuer: BehaviorSubject<string | null> = new BehaviorSubject<string | null>(null);\n\n private readonly _accessToken: BehaviorSubject<string | null> = new BehaviorSubject<string | null>(null);\n\n private readonly _user: BehaviorSubject<IUser | null> = new BehaviorSubject<IUser | null>(null);\n private readonly _userInitials: BehaviorSubject<string | null> = new BehaviorSubject<string | null>(null);\n\n private readonly _isInitialized = new BehaviorSubject<boolean>(false);\n private readonly _isInitializing = new BehaviorSubject<boolean>(false);\n\n private readonly _sessionLoading = new BehaviorSubject<boolean>(false);\n\n private authorizeOptions: AuthorizeOptions | null = null;\n\n constructor() {\n console.debug(\"AuthorizeService::created\");\n\n this.oauthService.discoveryDocumentLoaded$.subscribe((_) => {\n console.debug(\"discoveryDocumentLoaded$\");\n\n });\n\n this.oauthService.events.subscribe((e) => {\n console.debug(\"oauth/oidc event\", e);\n });\n\n this.oauthService.events.pipe(filter((e) => e.type === \"session_terminated\")).subscribe((_) => {\n console.debug(\"Your session has been terminated!\");\n this._accessToken.next(null);\n this._user.next(null);\n this._isAuthenticated.next(false);\n });\n\n this.oauthService.events.pipe(filter((e) => e.type === \"token_received\")).subscribe(async (_) => {\n await this.loadUserAsync();\n });\n\n this.oauthService.events.pipe(filter((e) => e.type === \"session_unchanged\")).subscribe(async (_) => {\n if (this._user.value == null) {\n await this.loadUserAsync();\n }\n });\n\n this.oauthService.events.pipe(filter((e) => e.type === \"logout\")).subscribe((_) => {\n this._accessToken.next(null);\n this._user.next(null);\n this._isAuthenticated.next(false);\n });\n }\n\n public isInRole(role: Roles): boolean {\n return this._user?.value?.role?.includes(role) ?? false;\n }\n\n public getRoles(): Observable<string[]> {\n return this.user.pipe(map((u) => (u?.role != null ? u.role : new Array<string>())));\n }\n\n public getServiceUris(): string[] | null {\n return this.authorizeOptions?.wellKnownServiceUris ?? null;\n }\n\n public get issuer(): Observable<string | null> {\n return this._issuer;\n }\n\n public get isAuthenticated(): Observable<boolean> {\n return this._isAuthenticated;\n }\n\n public get sessionLoading(): Observable<boolean> {\n return this._sessionLoading;\n }\n\n public get accessToken(): Observable<string | null> {\n return this._accessToken;\n }\n\n public get user(): Observable<IUser | null> {\n return this._user;\n }\n\n public get userInitials(): Observable<string | null> {\n return this._userInitials;\n }\n\n public login(): void {\n this.oauthService.initImplicitFlow();\n }\n\n public logout(): void {\n this.oauthService.logOut(false);\n }\n\n public async initialize(authorizeOptions: AuthorizeOptions): Promise<void> {\n console.debug(\"AuthorizeService::initialize::started\");\n\n await this.uninitialize();\n\n if (await firstValueFrom(this._isInitializing)) {\n return;\n }\n if (await firstValueFrom(this._isInitialized)) {\n console.debug(\"AuthorizeService::initialize::alreadyInitialized\");\n return;\n }\n this._isInitializing.next(true);\n\n try {\n const config: AuthConfig = {\n responseType: \"code\",\n issuer: authorizeOptions.issuer,\n redirectUri: authorizeOptions.redirectUri,\n postLogoutRedirectUri: authorizeOptions.postLogoutRedirectUri,\n clientId: authorizeOptions.clientId,\n scope: authorizeOptions.scope,\n showDebugInformation: authorizeOptions.showDebugInformation,\n sessionChecksEnabled: authorizeOptions.sessionChecksEnabled,\n sessionCheckIntervall: 60 * 1000,\n preserveRequestedRoute: true\n };\n\n this.authorizeOptions = authorizeOptions;\n\n this.oauthService.setStorage(localStorage);\n this.oauthService.configure(config);\n console.debug(\"AuthorizeService::initialize::loadingDiscoveryDocumentAndTryLogin\");\n await this.oauthService.loadDiscoveryDocumentAndTryLogin();\n\n console.debug(\"AuthorizeService::initialize::setupAutomaticSilentRefresh\");\n this.oauthService.setupAutomaticSilentRefresh();\n\n this._issuer.next(authorizeOptions.issuer ?? null);\n\n if (this.oauthService.hasValidIdToken()) {\n // if the idToken is still valid, we can use the session\n console.debug(\"AuthorizeService::initialize::hasValidIdToken\");\n this._sessionLoading.next(true);\n await this.oauthService.refreshToken();\n }\n\n this._isInitialized.next(true);\n console.debug(\"AuthorizeService::initialize::done\");\n } finally {\n this._isInitializing.next(false);\n }\n\n console.debug(\"AuthorizeService::initialize::completed\");\n }\n\n public async uninitialize(): Promise<void> {\n console.debug(\"AuthorizeService::uninitialize::started\");\n\n if (await firstValueFrom(this._isInitializing)) {\n return;\n }\n if (!await firstValueFrom(this._isInitialized)) {\n console.debug(\"AuthorizeService::uninitialize::alreadyUninitialized\");\n return;\n }\n\n try {\n this._isInitializing.next(true);\n\n this.oauthService.stopAutomaticRefresh();\n\n this.authorizeOptions = null;\n\n this._isInitialized.next(false);\n console.debug(\"AuthorizeService::uninitialize::done\");\n } finally {\n this._isInitializing.next(false);\n }\n\n console.debug(\"AuthorizeService::uninitialize::completed\");\n }\n\n private async loadUserAsync(): Promise<void> {\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 = claims as IUser;\n if (user.family_name && user.given_name){\n const initials = user.given_name.charAt(0) + user.family_name.charAt(0);\n this._userInitials.next(initials);\n }\n else {\n this._userInitials.next(user.name.charAt(0) + user.name.charAt(1));\n }\n\n const accessToken = this.oauthService.getAccessToken();\n this._user.next(user);\n this._accessToken.next(accessToken);\n this._isAuthenticated.next(true);\n this._sessionLoading.next(false);\n console.debug(\"AuthorizeService::loadUserAsync::done\");\n }\n}\n","export enum Roles {\n ReportingManagement = 'ReportingManagement',\n ReportingViewer = 'ReportingViewer',\n AdminPanelManagement = 'AdminPanelManagement',\n BotManagement = 'BotManagement',\n UserManagement = 'UserManagement',\n CommunicationManagement = 'CommunicationManagement',\n TenantManagement = 'TenantManagement',\n Development = 'Development'\n}\n","import { Component, OnInit, inject } from '@angular/core';\nimport { AuthorizeService } from '../authorize.service';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n@Component({\n selector: 'mm-login-menu',\n standalone: false,\n templateUrl: './login-menu.component.html',\n styleUrls: ['./login-menu.component.css']\n})\nexport class LoginMenuComponent implements OnInit {\n private readonly authorizeService = inject(AuthorizeService);\n\n public isAuthenticated: Observable<boolean>;\n public userName: Observable<string | null>;\n\n constructor() {\n this.isAuthenticated = this.authorizeService.isAuthenticated;\n this.userName = this.authorizeService.user.pipe(map((u) => u?.name ?? null));\n }\n\n ngOnInit(): void {\n const isIFrame = window.self !== window.top;\n\n console.log('app-login-menu::created');\n\n this.isAuthenticated.subscribe((x) => {\n console.log(`isAuthenticated changed to ${x} (iframe ${isIFrame})`);\n });\n }\n\n public login(): void {\n this.authorizeService.login();\n }\n\n public logout(): void {\n this.authorizeService.logout();\n }\n\n public register(): void {}\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, inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, Route, Router, RouterStateSnapshot, UrlSegment, UrlTree } from '@angular/router';\nimport { AuthorizeService } from './authorize.service';\nimport { firstValueFrom, Observable } from 'rxjs';\n\n@Injectable()\nexport class AuthorizeGuard {\n private readonly authorizeService = inject(AuthorizeService);\n private readonly router = inject(Router);\n\n canActivate(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot\n ): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {\n const url: string = state.url;\n return this.handleAuthorization(next, url);\n }\n\n canActivateChild(\n next: ActivatedRouteSnapshot,\n state: RouterStateSnapshot\n ): 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\n ): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {\n return true;\n }\n\n canLoad(_route: Route, _segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {\n return true;\n }\n\n private async handleAuthorization(route: ActivatedRouteSnapshot, _url: any): Promise<boolean> {\n const isAuthenticated = await firstValueFrom(this.authorizeService.isAuthenticated);\n if (isAuthenticated) {\n const userRoles = await firstValueFrom(this.authorizeService.getRoles());\n if (route.data['roles'] && !route.data['roles'].some((role: string) => userRoles.includes(role))) {\n await 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 { Injectable, inject } 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 private readonly authorize = inject(AuthorizeService);\n\n accessToken: string | null;\n\n constructor() {\n const authorize = this.authorize;\n\n this.accessToken = null;\n authorize.accessToken.subscribe((value) => (this.accessToken = value));\n }\n\n private static isSameOriginUrl(req: HttpRequest<any>): boolean {\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): Observable<HttpEvent<any>> {\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): boolean {\n const serviceUris = this.authorize.getServiceUris();\n\n if (serviceUris != null) {\n for (const serviceUri of serviceUris) {\n if (req.url.startsWith(`${serviceUri}`)) {\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","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';\nimport { RouterLink } from '@angular/router';\nimport { AuthorizeInterceptor } from \"./authorize.interceptor\";\n\n@NgModule({\n declarations: [LoginMenuComponent],\n exports: [LoginMenuComponent],\n providers: [],\n imports: [CommonModule, HttpClientModule, OAuthModule.forRoot(), RouterLink]\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 AuthorizeInterceptor,\n AuthorizeGuard\n ]\n };\n }\n}\n","/*\n * Public API Surface of shared-auth\n */\n\nexport * from './lib/authorize.service';\nexport * from './lib/roles';\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"],"mappings":";;;;;;;;;;;;MAgBa,gBAAgB,CAAA;AAC3B,IAAA,oBAAoB;;AAEpB,IAAA,MAAM;;AAEN,IAAA,WAAW;AACX,IAAA,qBAAqB;;AAErB,IAAA,QAAQ;;;AAGR,IAAA,KAAK;AACL,IAAA,oBAAoB;AACpB,IAAA,oBAAoB;AACrB;MAGY,gBAAgB,CAAA;AACV,IAAA,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AAEnC,IAAA,gBAAgB,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC;AACtD,IAAA,OAAO,GAAmC,IAAI,eAAe,CAAgB,IAAI,CAAC;AAElF,IAAA,YAAY,GAAmC,IAAI,eAAe,CAAgB,IAAI,CAAC;AAEvF,IAAA,KAAK,GAAkC,IAAI,eAAe,CAAe,IAAI,CAAC;AAC9E,IAAA,aAAa,GAAmC,IAAI,eAAe,CAAgB,IAAI,CAAC;AAExF,IAAA,cAAc,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC;AACpD,IAAA,eAAe,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC;AAErD,IAAA,eAAe,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC;IAE9D,gBAAgB,GAA4B,IAAI;AAExD,IAAA,WAAA,GAAA;AACE,QAAA,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC;QAE1C,IAAI,CAAC,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,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAhB,gBAAgB,EAAA,YAAA,EAAA,CALZ,kBAAkB,CAAA,EAAA,OAAA,EAAA,CAGvB,YAAY,EAAE,gBAAgB,EAAAA,IAAA,CAAA,WAAA,EAAyB,UAAU,CAAA,EAAA,OAAA,EAAA,CAFjE,kBAAkB,CAAA,EAAA,CAAA;wGAIjB,gBAAgB,EAAA,OAAA,EAAA,CAFjB,YAAY,EAAE,gBAAgB,EAAE,WAAW,CAAC,OAAO,EAAE,CAAA,EAAA,CAAA;;2FAEpD,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAN5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,YAAY,EAAE,CAAC,kBAAkB,CAAC;oBAClC,OAAO,EAAE,CAAC,kBAAkB,CAAC;AAC7B,oBAAA,SAAS,EAAE,EAAE;AACb,oBAAA,OAAO,EAAE,CAAC,YAAY,EAAE,gBAAgB,EAAE,WAAW,CAAC,OAAO,EAAE,EAAE,UAAU;AAC5E,iBAAA;;;ACfD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import * as i5 from '@angular/router';
|
|
|
9
9
|
import { ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Route, UrlSegment } from '@angular/router';
|
|
10
10
|
|
|
11
11
|
declare enum Roles {
|
|
12
|
+
ReportingManagement = "ReportingManagement",
|
|
13
|
+
ReportingViewer = "ReportingViewer",
|
|
12
14
|
AdminPanelManagement = "AdminPanelManagement",
|
|
13
15
|
BotManagement = "BotManagement",
|
|
14
16
|
UserManagement = "UserManagement",
|
|
@@ -18,8 +20,10 @@ declare enum Roles {
|
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
interface IUser {
|
|
23
|
+
family_name: string | null;
|
|
24
|
+
given_name: string | null;
|
|
21
25
|
name: string;
|
|
22
|
-
role: string[];
|
|
26
|
+
role: string[] | null;
|
|
23
27
|
sub: string;
|
|
24
28
|
idp: string;
|
|
25
29
|
email: string | null;
|
|
@@ -36,26 +40,30 @@ declare class AuthorizeOptions {
|
|
|
36
40
|
}
|
|
37
41
|
declare class AuthorizeService {
|
|
38
42
|
private readonly oauthService;
|
|
39
|
-
private readonly
|
|
40
|
-
private readonly
|
|
41
|
-
private readonly
|
|
42
|
-
private readonly
|
|
43
|
-
private readonly
|
|
44
|
-
private readonly
|
|
43
|
+
private readonly _isAuthenticated;
|
|
44
|
+
private readonly _issuer;
|
|
45
|
+
private readonly _accessToken;
|
|
46
|
+
private readonly _user;
|
|
47
|
+
private readonly _userInitials;
|
|
48
|
+
private readonly _isInitialized;
|
|
49
|
+
private readonly _isInitializing;
|
|
50
|
+
private readonly _sessionLoading;
|
|
45
51
|
private authorizeOptions;
|
|
46
52
|
constructor();
|
|
47
53
|
isInRole(role: Roles): boolean;
|
|
48
54
|
getRoles(): Observable<string[]>;
|
|
49
55
|
getServiceUris(): string[] | null;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
get issuer(): Observable<string | null>;
|
|
57
|
+
get isAuthenticated(): Observable<boolean>;
|
|
58
|
+
get sessionLoading(): Observable<boolean>;
|
|
59
|
+
get accessToken(): Observable<string | null>;
|
|
60
|
+
get user(): Observable<IUser | null>;
|
|
61
|
+
get userInitials(): Observable<string | null>;
|
|
54
62
|
login(): void;
|
|
55
63
|
logout(): void;
|
|
56
64
|
initialize(authorizeOptions: AuthorizeOptions): Promise<void>;
|
|
57
65
|
uninitialize(): Promise<void>;
|
|
58
|
-
private
|
|
66
|
+
private loadUserAsync;
|
|
59
67
|
static ɵfac: i0.ɵɵFactoryDeclaration<AuthorizeService, never>;
|
|
60
68
|
static ɵprov: i0.ɵɵInjectableDeclaration<AuthorizeService>;
|
|
61
69
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshmakers/shared-auth",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.145-0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@angular/common": "^20.
|
|
6
|
-
"@angular/core": "^20.
|
|
5
|
+
"@angular/common": "^20.2.3",
|
|
6
|
+
"@angular/core": "^20.2.3",
|
|
7
7
|
"angular-oauth2-oidc": "^20.0.2"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|