@igo2/auth 17.0.0-next.1 → 17.0.0-next.10
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/environment/environment.interface.d.ts +6 -0
- package/environment/index.d.ts +5 -0
- package/esm2022/environment/environment.interface.mjs +2 -0
- package/esm2022/environment/igo2-auth-environment.mjs +5 -0
- package/esm2022/environment/public_api.mjs +2 -0
- package/esm2022/facebook/auth-facebook/auth-facebook.component.mjs +65 -0
- package/esm2022/facebook/igo2-auth-facebook.mjs +5 -0
- package/esm2022/facebook/public_api.mjs +3 -0
- package/esm2022/facebook/shared/auth-facebook.interface.mjs +2 -0
- package/esm2022/facebook/shared/index.mjs +2 -0
- package/esm2022/form/auth-form/auth-form.component.mjs +166 -0
- package/esm2022/form/auth-form.module.mjs +73 -0
- package/esm2022/form/igo2-auth-form.mjs +5 -0
- package/esm2022/form/public_api.mjs +7 -0
- package/esm2022/form/shared/auth-form.interface.mjs +2 -0
- package/esm2022/form/shared/index.mjs +2 -0
- package/esm2022/google/auth-google/auth-google.component.mjs +108 -0
- package/esm2022/google/igo2-auth-google.mjs +5 -0
- package/esm2022/google/public_api.mjs +3 -0
- package/esm2022/google/shared/auth-google.interface.mjs +2 -0
- package/esm2022/google/shared/index.mjs +2 -0
- package/esm2022/internal/auth-intern/auth-intern.component.mjs +84 -0
- package/esm2022/internal/igo2-auth-internal.mjs +5 -0
- package/esm2022/internal/public_api.mjs +2 -0
- package/esm2022/lib/auth.provider.mjs +22 -0
- package/esm2022/lib/shared/admin.guard.mjs +4 -4
- package/esm2022/lib/shared/auth-storage.interface.mjs +1 -1
- package/esm2022/lib/shared/auth-storage.service.mjs +4 -4
- package/esm2022/lib/shared/auth.guard.mjs +4 -4
- package/esm2022/lib/shared/auth.interceptor.mjs +4 -4
- package/esm2022/lib/shared/auth.interface.mjs +5 -2
- package/esm2022/lib/shared/auth.service.mjs +4 -4
- package/esm2022/lib/shared/index.mjs +3 -5
- package/esm2022/lib/shared/logged.guard.mjs +4 -4
- package/esm2022/lib/shared/profils.guard.mjs +4 -4
- package/esm2022/lib/shared/token.service.mjs +4 -4
- package/esm2022/microsoft/auth-microsoft/auth-microsoft.component.mjs +100 -0
- package/esm2022/microsoft/auth-microsoft.provider.mjs +105 -0
- package/esm2022/microsoft/auth-microsoftb2c/auth-microsoftb2c.component.mjs +98 -0
- package/esm2022/microsoft/auth-microsoftb2c/auth-msalBroadcastServiceb2c.service.mjs +47 -0
- package/esm2022/microsoft/auth-microsoftb2c/auth-msalServiceb2c.service.mjs +85 -0
- package/esm2022/microsoft/igo2-auth-microsoft.mjs +5 -0
- package/esm2022/microsoft/public_api.mjs +5 -0
- package/esm2022/microsoft/shared/auth-microsoft.interface.mjs +2 -0
- package/esm2022/microsoft/shared/index.mjs +2 -0
- package/esm2022/monitoring/auth-monitoring/auth-monitoring.provider.mjs +24 -0
- package/esm2022/monitoring/auth-monitoring/auth-monitoring.service.mjs +54 -0
- package/esm2022/monitoring/igo2-auth-monitoring.mjs +5 -0
- package/esm2022/monitoring/public_api.mjs +3 -0
- package/esm2022/public_api.mjs +3 -19
- package/{lib/auth-form → facebook/auth-facebook}/auth-facebook.component.d.ts +1 -1
- package/facebook/index.d.ts +5 -0
- package/facebook/public_api.d.ts +2 -0
- package/facebook/shared/auth-facebook.interface.d.ts +4 -0
- package/facebook/shared/index.d.ts +1 -0
- package/fesm2022/igo2-auth-environment.mjs +4 -0
- package/fesm2022/igo2-auth-environment.mjs.map +1 -0
- package/fesm2022/igo2-auth-facebook.mjs +70 -0
- package/fesm2022/igo2-auth-facebook.mjs.map +1 -0
- package/fesm2022/igo2-auth-form.mjs +238 -0
- package/fesm2022/igo2-auth-form.mjs.map +1 -0
- package/fesm2022/igo2-auth-google.mjs +112 -0
- package/fesm2022/igo2-auth-google.mjs.map +1 -0
- package/fesm2022/igo2-auth-internal.mjs +89 -0
- package/fesm2022/igo2-auth-internal.mjs.map +1 -0
- package/fesm2022/igo2-auth-microsoft.mjs +404 -0
- package/fesm2022/igo2-auth-microsoft.mjs.map +1 -0
- package/fesm2022/igo2-auth-monitoring.mjs +81 -0
- package/fesm2022/igo2-auth-monitoring.mjs.map +1 -0
- package/fesm2022/igo2-auth.mjs +241 -1145
- package/fesm2022/igo2-auth.mjs.map +1 -1
- package/{lib → form}/auth-form/auth-form.component.d.ts +3 -4
- package/form/auth-form.module.d.ts +20 -0
- package/form/index.d.ts +5 -0
- package/form/public_api.d.ts +3 -0
- package/form/shared/auth-form.interface.d.ts +9 -0
- package/form/shared/index.d.ts +1 -0
- package/{src/lib → form/src}/auth-form/auth-intern.theme.scss +19 -19
- package/form/src/auth-form.theme.scss +9 -0
- package/{lib/auth-form → google/auth-google}/auth-google.component.d.ts +1 -1
- package/google/index.d.ts +5 -0
- package/google/public_api.d.ts +2 -0
- package/google/shared/auth-google.interface.d.ts +5 -0
- package/google/shared/index.d.ts +1 -0
- package/{lib/auth-form → internal/auth-intern}/auth-intern.component.d.ts +1 -1
- package/internal/index.d.ts +5 -0
- package/internal/public_api.d.ts +1 -0
- package/lib/auth.provider.d.ts +3 -0
- package/lib/shared/auth.interface.d.ts +20 -69
- package/lib/shared/index.d.ts +2 -4
- package/locale/en.auth.json +29 -29
- package/locale/fr.auth.json +33 -33
- package/{lib/auth-form → microsoft/auth-microsoft}/auth-microsoft.component.d.ts +4 -2
- package/microsoft/auth-microsoft.provider.d.ts +12 -0
- package/{lib/auth-form → microsoft/auth-microsoftb2c}/auth-microsoftb2c.component.d.ts +5 -3
- package/{lib/shared → microsoft/auth-microsoftb2c}/auth-msalBroadcastServiceb2c.service.d.ts +1 -1
- package/microsoft/index.d.ts +5 -0
- package/microsoft/public_api.d.ts +4 -0
- package/microsoft/shared/auth-microsoft.interface.d.ts +32 -0
- package/microsoft/shared/index.d.ts +1 -0
- package/{lib → monitoring}/auth-monitoring/auth-monitoring.service.d.ts +1 -1
- package/monitoring/index.d.ts +5 -0
- package/monitoring/public_api.d.ts +2 -0
- package/package.json +46 -3
- package/public_api.d.ts +2 -18
- package/src/auth.theme.scss +9 -9
- package/esm2022/lib/auth-form/auth-facebook.component.mjs +0 -65
- package/esm2022/lib/auth-form/auth-form.component.mjs +0 -170
- package/esm2022/lib/auth-form/auth-google.component.mjs +0 -108
- package/esm2022/lib/auth-form/auth-intern.component.mjs +0 -84
- package/esm2022/lib/auth-form/auth-microsoft.component.mjs +0 -100
- package/esm2022/lib/auth-form/auth-microsoftb2c.component.mjs +0 -98
- package/esm2022/lib/auth-form/index.mjs +0 -19
- package/esm2022/lib/auth-monitoring/auth-monitoring.provider.mjs +0 -24
- package/esm2022/lib/auth-monitoring/auth-monitoring.service.mjs +0 -54
- package/esm2022/lib/auth.module.mjs +0 -98
- package/esm2022/lib/environment/environment.interface.mjs +0 -2
- package/esm2022/lib/environment/index.mjs +0 -2
- package/esm2022/lib/shared/auth-microsoft.provider.mjs +0 -86
- package/esm2022/lib/shared/auth-msalBroadcastServiceb2c.service.mjs +0 -47
- package/esm2022/lib/shared/auth-msalServiceb2c.service..mjs +0 -85
- package/esm2022/lib/shared/protected.directive.mjs +0 -21
- package/lib/auth-form/index.d.ts +0 -11
- package/lib/auth.module.d.ts +0 -24
- package/lib/environment/environment.interface.d.ts +0 -5
- package/lib/shared/auth-microsoft.provider.d.ts +0 -30
- package/lib/shared/protected.directive.d.ts +0 -8
- /package/{lib/environment/index.d.ts → environment/public_api.d.ts} +0 -0
- /package/{lib/shared/auth-msalServiceb2c.service..d.ts → microsoft/auth-microsoftb2c/auth-msalServiceb2c.service.d.ts} +0 -0
- /package/{lib → monitoring}/auth-monitoring/auth-monitoring.provider.d.ts +0 -0
package/fesm2022/igo2-auth.mjs
CHANGED
|
@@ -1,40 +1,19 @@
|
|
|
1
|
+
import * as i1 from '@angular/common/http';
|
|
2
|
+
import { HttpHeaders, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
1
3
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Optional,
|
|
4
|
+
import { Injectable, Optional, makeEnvironmentProviders } from '@angular/core';
|
|
5
|
+
import { BaseStorage, StorageScope, StorageService } from '@igo2/core/storage';
|
|
3
6
|
import * as i2 from '@igo2/core/config';
|
|
4
7
|
import { ConfigService } from '@igo2/core/config';
|
|
5
|
-
import
|
|
6
|
-
import { HttpHeaders, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
8
|
+
import { jwtDecode } from 'jwt-decode';
|
|
7
9
|
import * as i3 from '@angular/router';
|
|
8
|
-
import { NavigationStart } from '@angular/router';
|
|
9
10
|
import * as i4 from '@igo2/core/language';
|
|
10
|
-
import { IgoLanguageModule } from '@igo2/core/language';
|
|
11
11
|
import * as i5 from '@igo2/core/message';
|
|
12
12
|
import { Base64 } from '@igo2/utils';
|
|
13
|
-
import { BehaviorSubject, of
|
|
14
|
-
import { tap, catchError,
|
|
13
|
+
import { BehaviorSubject, of } from 'rxjs';
|
|
14
|
+
import { tap, catchError, map } from 'rxjs/operators';
|
|
15
15
|
import { globalCacheBusterNotifier } from 'ts-cacheable';
|
|
16
|
-
import { jwtDecode } from 'jwt-decode';
|
|
17
|
-
import * as i1$1 from '@angular/common';
|
|
18
|
-
import { NgIf, CommonModule } from '@angular/common';
|
|
19
|
-
import * as i4$2 from '@angular/material/button';
|
|
20
|
-
import { MatButtonModule } from '@angular/material/button';
|
|
21
|
-
import * as i6 from '@ngx-translate/core';
|
|
22
|
-
import { TranslateModule } from '@ngx-translate/core';
|
|
23
|
-
import * as i3$1 from '@angular/forms';
|
|
24
|
-
import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
25
|
-
import * as i4$1 from '@angular/material/form-field';
|
|
26
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
27
|
-
import * as i5$1 from '@angular/material/input';
|
|
28
|
-
import { MatInputModule } from '@angular/material/input';
|
|
29
|
-
import { MatProgressSpinner, MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
30
|
-
import * as i5$2 from '@angular/material/icon';
|
|
31
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
32
|
-
import * as i3$2 from '@azure/msal-angular';
|
|
33
|
-
import { MsalBroadcastService, MSAL_GUARD_CONFIG, MSAL_INSTANCE, MsalService, MsalModule } from '@azure/msal-angular';
|
|
34
|
-
import { PublicClientApplication, InteractionStatus, InteractionRequiredAuthError, WrapperSKU, EventMessageUtils, InteractionType } from '@azure/msal-browser';
|
|
35
16
|
import { Md5 } from 'ts-md5';
|
|
36
|
-
import { BaseStorage, StorageScope, StorageService } from '@igo2/core/storage';
|
|
37
|
-
import { identifySentryUser, MONITORING_OPTIONS } from '@igo2/core/monitoring';
|
|
38
17
|
|
|
39
18
|
class TokenService {
|
|
40
19
|
injector;
|
|
@@ -70,10 +49,10 @@ class TokenService {
|
|
|
70
49
|
}
|
|
71
50
|
return true;
|
|
72
51
|
}
|
|
73
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
74
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
52
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: TokenService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
53
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: TokenService, providedIn: 'root' });
|
|
75
54
|
}
|
|
76
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
55
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: TokenService, decorators: [{
|
|
77
56
|
type: Injectable,
|
|
78
57
|
args: [{
|
|
79
58
|
providedIn: 'root'
|
|
@@ -225,10 +204,10 @@ class AuthService {
|
|
|
225
204
|
throw err;
|
|
226
205
|
}));
|
|
227
206
|
}
|
|
228
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
229
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
207
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: TokenService }, { token: i2.ConfigService }, { token: i4.LanguageService }, { token: i5.MessageService }, { token: i3.Router, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
208
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
230
209
|
}
|
|
231
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
210
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthService, decorators: [{
|
|
232
211
|
type: Injectable,
|
|
233
212
|
args: [{
|
|
234
213
|
providedIn: 'root'
|
|
@@ -237,670 +216,252 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
237
216
|
type: Optional
|
|
238
217
|
}] }] });
|
|
239
218
|
|
|
240
|
-
class
|
|
219
|
+
class AuthStorageService extends BaseStorage {
|
|
220
|
+
http;
|
|
241
221
|
authService;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
constructor(authService, config, appRef) {
|
|
222
|
+
tokenService;
|
|
223
|
+
constructor(config, http, authService, tokenService) {
|
|
224
|
+
super(config);
|
|
225
|
+
this.http = http;
|
|
247
226
|
this.authService = authService;
|
|
248
|
-
this.
|
|
249
|
-
this.
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
227
|
+
this.tokenService = tokenService;
|
|
228
|
+
this.authService.authenticate$.subscribe((isAuthenticated) => {
|
|
229
|
+
if (isAuthenticated && this.options.url) {
|
|
230
|
+
this.http
|
|
231
|
+
.get(this.options.url)
|
|
232
|
+
.subscribe((userIgo) => {
|
|
233
|
+
if (userIgo && userIgo.preference) {
|
|
234
|
+
for (const key of Object.keys(userIgo.preference)) {
|
|
235
|
+
const value = userIgo.preference[key];
|
|
236
|
+
super.set(key, value);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
261
241
|
});
|
|
262
242
|
}
|
|
263
|
-
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
-
this.
|
|
243
|
+
set(key, value, scope = StorageScope.LOCAL) {
|
|
244
|
+
if (scope === StorageScope.LOCAL &&
|
|
245
|
+
this.authService.authenticated &&
|
|
246
|
+
this.options.url) {
|
|
247
|
+
const preference = {};
|
|
248
|
+
preference[key] = value;
|
|
249
|
+
this.http.patch(this.options.url, { preference }).subscribe();
|
|
267
250
|
}
|
|
251
|
+
super.set(key, value, scope);
|
|
268
252
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
this.
|
|
272
|
-
this.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (document.getElementById('facebook-jssdk')) {
|
|
277
|
-
return;
|
|
253
|
+
remove(key, scope = StorageScope.LOCAL) {
|
|
254
|
+
if (scope === StorageScope.LOCAL &&
|
|
255
|
+
this.authService.authenticated &&
|
|
256
|
+
this.options.url) {
|
|
257
|
+
const preference = {};
|
|
258
|
+
preference[key] = undefined;
|
|
259
|
+
this.http.patch(this.options.url, { preference }).subscribe();
|
|
278
260
|
}
|
|
279
|
-
|
|
280
|
-
const fjs = document.getElementsByTagName('script')[0];
|
|
281
|
-
const js = document.createElement('script');
|
|
282
|
-
js.id = 'facebook-jssdk';
|
|
283
|
-
js.src = `${urlSDK}&appId=${this.options?.appId}`;
|
|
284
|
-
js.onload = () => {
|
|
285
|
-
this.subscribeEvents();
|
|
286
|
-
};
|
|
287
|
-
fjs.parentNode.insertBefore(js, fjs);
|
|
261
|
+
super.remove(key, scope);
|
|
288
262
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
authService;
|
|
301
|
-
config;
|
|
302
|
-
languageService;
|
|
303
|
-
appRef;
|
|
304
|
-
options;
|
|
305
|
-
login = new EventEmitter();
|
|
306
|
-
constructor(authService, config, languageService, appRef) {
|
|
307
|
-
this.authService = authService;
|
|
308
|
-
this.config = config;
|
|
309
|
-
this.languageService = languageService;
|
|
310
|
-
this.appRef = appRef;
|
|
311
|
-
this.options = this.config.getConfig('auth.google');
|
|
312
|
-
if (this.options?.apiKey && this.options?.clientId) {
|
|
313
|
-
this.loadSDKGoogle();
|
|
314
|
-
this.loadPlatform();
|
|
263
|
+
clear(scope = StorageScope.LOCAL) {
|
|
264
|
+
if (scope === StorageScope.LOCAL &&
|
|
265
|
+
this.authService.authenticated &&
|
|
266
|
+
this.options.url) {
|
|
267
|
+
this.http
|
|
268
|
+
.patch(this.options.url, { preference: {} }, {
|
|
269
|
+
params: {
|
|
270
|
+
mergePreference: 'false'
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
.subscribe();
|
|
315
274
|
}
|
|
316
|
-
|
|
317
|
-
|
|
275
|
+
let token;
|
|
276
|
+
if (scope === StorageScope.LOCAL) {
|
|
277
|
+
token = this.tokenService.get();
|
|
318
278
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
handleSignOutClick() {
|
|
324
|
-
window.gapi.auth2.getAuthInstance().signOut();
|
|
325
|
-
}
|
|
326
|
-
handleClientLoad() {
|
|
327
|
-
window.gapi.load('client:auth2', () => this.initClient());
|
|
328
|
-
}
|
|
329
|
-
initClient() {
|
|
330
|
-
window.gapi.client
|
|
331
|
-
.init({
|
|
332
|
-
apiKey: this.options?.apiKey,
|
|
333
|
-
clientId: this.options?.clientId,
|
|
334
|
-
discoveryDocs: [
|
|
335
|
-
'https://people.googleapis.com/$discovery/rest?version=v1'
|
|
336
|
-
],
|
|
337
|
-
scope: 'profile'
|
|
338
|
-
})
|
|
339
|
-
.then(() => {
|
|
340
|
-
this.handleSignOutClick();
|
|
341
|
-
this.updateTextButton();
|
|
342
|
-
window.gapi.auth2
|
|
343
|
-
.getAuthInstance()
|
|
344
|
-
.isSignedIn.listen((rep) => {
|
|
345
|
-
this.updateSigninStatus(rep);
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
updateSigninStatus(isSignedIn) {
|
|
350
|
-
this.updateTextButton();
|
|
351
|
-
if (isSignedIn) {
|
|
352
|
-
this.loginGoogle(window.gapi.client.getToken().access_token);
|
|
279
|
+
super.clear(scope);
|
|
280
|
+
if (token) {
|
|
281
|
+
this.tokenService.set(token);
|
|
353
282
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
283
|
+
if (scope === StorageScope.LOCAL &&
|
|
284
|
+
this.authService.authenticated &&
|
|
285
|
+
this.options.url) {
|
|
286
|
+
this.http
|
|
287
|
+
.get(this.options.url)
|
|
288
|
+
.subscribe((userIgo) => {
|
|
289
|
+
if (userIgo && userIgo.preference) {
|
|
290
|
+
for (const key of Object.keys(userIgo.preference)) {
|
|
291
|
+
const value = userIgo.preference[key];
|
|
292
|
+
super.set(key, value);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
});
|
|
364
296
|
}
|
|
365
297
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
this.appRef.tick();
|
|
369
|
-
this.login.emit(true);
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
loadSDKGoogle() {
|
|
373
|
-
const fjs = document.getElementsByTagName('script')[0];
|
|
374
|
-
const js = document.createElement('script');
|
|
375
|
-
js.id = 'google-jssdk';
|
|
376
|
-
js.src = 'https://apis.google.com/js/api.js';
|
|
377
|
-
js.onload = () => {
|
|
378
|
-
this.handleClientLoad();
|
|
379
|
-
};
|
|
380
|
-
fjs.parentNode.insertBefore(js, fjs);
|
|
381
|
-
}
|
|
382
|
-
loadPlatform() {
|
|
383
|
-
const fjs = document.getElementsByTagName('script')[0];
|
|
384
|
-
const js = document.createElement('script');
|
|
385
|
-
js.id = 'google-platform';
|
|
386
|
-
js.src = 'https://apis.google.com/js/platform.js';
|
|
387
|
-
fjs.parentNode.insertBefore(js, fjs);
|
|
388
|
-
}
|
|
389
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthGoogleComponent, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i4.LanguageService }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
390
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: AuthGoogleComponent, isStandalone: true, selector: "igo-auth-google", outputs: { login: "login" }, ngImport: i0, template: "<div\r\n class=\"g-signin2 google-login-button\"\r\n data-height=\"40\"\r\n data-width=\"265\"\r\n data-longtitle=\"true\"\r\n></div>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block}.google-login-button ::ng-deep .abcRioButton{color:#000000de}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
298
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthStorageService, deps: [{ token: i2.ConfigService }, { token: i1.HttpClient }, { token: AuthService }, { token: TokenService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
299
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthStorageService, providedIn: 'root' });
|
|
391
300
|
}
|
|
392
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
393
|
-
type:
|
|
394
|
-
args: [{
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
301
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthStorageService, decorators: [{
|
|
302
|
+
type: Injectable,
|
|
303
|
+
args: [{
|
|
304
|
+
providedIn: 'root'
|
|
305
|
+
}]
|
|
306
|
+
}], ctorParameters: () => [{ type: i2.ConfigService }, { type: i1.HttpClient }, { type: AuthService }, { type: TokenService }] });
|
|
398
307
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
return this._allowAnonymous;
|
|
404
|
-
}
|
|
405
|
-
set allowAnonymous(value) {
|
|
406
|
-
this._allowAnonymous = value;
|
|
407
|
-
}
|
|
408
|
-
_allowAnonymous = true;
|
|
409
|
-
error = '';
|
|
410
|
-
form;
|
|
411
|
-
loading = false;
|
|
412
|
-
login = new EventEmitter();
|
|
413
|
-
constructor(auth, languageService, fb) {
|
|
414
|
-
this.auth = auth;
|
|
415
|
-
this.languageService = languageService;
|
|
416
|
-
this.form = fb.group({
|
|
417
|
-
username: ['', Validators.required],
|
|
418
|
-
password: ['', Validators.required]
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
loginUser(values) {
|
|
422
|
-
this.loading = true;
|
|
423
|
-
this.auth.login(values.username, values.password).subscribe(() => {
|
|
424
|
-
this.login.emit(true);
|
|
425
|
-
this.loading = false;
|
|
426
|
-
}, (error) => {
|
|
427
|
-
try {
|
|
428
|
-
this.languageService.translate
|
|
429
|
-
.get('igo.auth.error.' + error.error.message)
|
|
430
|
-
.subscribe((errorMsg) => (this.error = errorMsg));
|
|
431
|
-
}
|
|
432
|
-
catch (e) {
|
|
433
|
-
this.error = error.error.message;
|
|
434
|
-
}
|
|
435
|
-
this.loading = false;
|
|
436
|
-
});
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
loginAnonymous() {
|
|
440
|
-
this.auth.loginAnonymous().subscribe(() => {
|
|
441
|
-
this.login.emit(true);
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthInternComponent, deps: [{ token: AuthService }, { token: i4.LanguageService }, { token: i3$1.UntypedFormBuilder }], target: i0.ɵɵFactoryTarget.Component });
|
|
445
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: AuthInternComponent, isStandalone: true, selector: "igo-auth-intern", inputs: { allowAnonymous: "allowAnonymous" }, outputs: { login: "login" }, ngImport: i0, template: "<form [formGroup]=\"form\" role=\"form\" (ngSubmit)=\"loginUser(form.value)\">\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <mat-label>{{ 'igo.auth.user' | translate }}</mat-label>\r\n <input\r\n matInput\r\n required\r\n placeholder=\"{{ 'igo.auth.user' | translate }}\"\r\n formControlName=\"username\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <mat-label>{{ 'igo.auth.password' | translate }}</mat-label>\r\n <input\r\n matInput\r\n required\r\n type=\"password\"\r\n placeholder=\"{{ 'igo.auth.password' | translate }}\"\r\n formControlName=\"password\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <button mat-raised-button type=\"submit\">\r\n {{ 'igo.auth.login' | translate }}\r\n </button>\r\n <button\r\n *ngIf=\"allowAnonymous\"\r\n mat-raised-button\r\n class=\"anonymous\"\r\n type=\"button\"\r\n (click)=\"loginAnonymous()\"\r\n >\r\n {{ 'igo.auth.accessAnonymous' | translate }}\r\n </button>\r\n <div *ngIf=\"error\">\r\n <br />\r\n <font size=\"3\" color=\"red\">{{ error }}</font>\r\n </div>\r\n</form>\r\n\r\n<div *ngIf=\"loading\" class=\"loading-container\">\r\n <mat-spinner [diameter]=\"40\"></mat-spinner>\r\n</div>\r\n", styles: [".full-width{width:100%}.anonymous{margin-left:10px}.loading-container{position:absolute;width:100%;height:100%;display:flex;justify-content:center;align-items:center;z-index:1000;top:0;left:0;padding:24px;box-sizing:border-box}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i3$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i3$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3$1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i4$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4$1.MatLabel, selector: "mat-label" }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i5$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i4$2.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Default });
|
|
446
|
-
}
|
|
447
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthInternComponent, decorators: [{
|
|
448
|
-
type: Component,
|
|
449
|
-
args: [{ selector: 'igo-auth-intern', changeDetection: ChangeDetectionStrategy.Default, standalone: true, imports: [
|
|
450
|
-
FormsModule,
|
|
451
|
-
ReactiveFormsModule,
|
|
452
|
-
MatFormFieldModule,
|
|
453
|
-
MatInputModule,
|
|
454
|
-
MatButtonModule,
|
|
455
|
-
MatProgressSpinner,
|
|
456
|
-
NgIf,
|
|
457
|
-
TranslateModule
|
|
458
|
-
], template: "<form [formGroup]=\"form\" role=\"form\" (ngSubmit)=\"loginUser(form.value)\">\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <mat-label>{{ 'igo.auth.user' | translate }}</mat-label>\r\n <input\r\n matInput\r\n required\r\n placeholder=\"{{ 'igo.auth.user' | translate }}\"\r\n formControlName=\"username\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <mat-label>{{ 'igo.auth.password' | translate }}</mat-label>\r\n <input\r\n matInput\r\n required\r\n type=\"password\"\r\n placeholder=\"{{ 'igo.auth.password' | translate }}\"\r\n formControlName=\"password\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <button mat-raised-button type=\"submit\">\r\n {{ 'igo.auth.login' | translate }}\r\n </button>\r\n <button\r\n *ngIf=\"allowAnonymous\"\r\n mat-raised-button\r\n class=\"anonymous\"\r\n type=\"button\"\r\n (click)=\"loginAnonymous()\"\r\n >\r\n {{ 'igo.auth.accessAnonymous' | translate }}\r\n </button>\r\n <div *ngIf=\"error\">\r\n <br />\r\n <font size=\"3\" color=\"red\">{{ error }}</font>\r\n </div>\r\n</form>\r\n\r\n<div *ngIf=\"loading\" class=\"loading-container\">\r\n <mat-spinner [diameter]=\"40\"></mat-spinner>\r\n</div>\r\n", styles: [".full-width{width:100%}.anonymous{margin-left:10px}.loading-container{position:absolute;width:100%;height:100%;display:flex;justify-content:center;align-items:center;z-index:1000;top:0;left:0;padding:24px;box-sizing:border-box}\n"] }]
|
|
459
|
-
}], ctorParameters: () => [{ type: AuthService }, { type: i4.LanguageService }, { type: i3$1.UntypedFormBuilder }], propDecorators: { allowAnonymous: [{
|
|
460
|
-
type: Input
|
|
461
|
-
}], login: [{
|
|
462
|
-
type: Output
|
|
463
|
-
}] } });
|
|
308
|
+
var AuthFeatureKind;
|
|
309
|
+
(function (AuthFeatureKind) {
|
|
310
|
+
AuthFeatureKind[AuthFeatureKind["Microsoft"] = 0] = "Microsoft";
|
|
311
|
+
})(AuthFeatureKind || (AuthFeatureKind = {}));
|
|
464
312
|
|
|
465
|
-
class
|
|
466
|
-
authService;
|
|
313
|
+
class AuthInterceptor {
|
|
467
314
|
config;
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
constructor(
|
|
476
|
-
this.authService = authService;
|
|
315
|
+
tokenService;
|
|
316
|
+
http;
|
|
317
|
+
authOptions;
|
|
318
|
+
refreshInProgress = false;
|
|
319
|
+
trustHosts;
|
|
320
|
+
hostsWithCredentials;
|
|
321
|
+
hostsWithAuthByKey;
|
|
322
|
+
constructor(config, tokenService, http) {
|
|
477
323
|
this.config = config;
|
|
478
|
-
this.
|
|
479
|
-
this.
|
|
480
|
-
this.
|
|
481
|
-
this.
|
|
482
|
-
this.
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
cacheLocation: 'sessionStorage'
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
this.broadcastService = new MsalBroadcastService(this.msalService.instance, this.msalService);
|
|
489
|
-
if (this.options?.clientId) {
|
|
490
|
-
this.broadcastService.inProgress$
|
|
491
|
-
.pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
|
|
492
|
-
.subscribe(() => {
|
|
493
|
-
this.checkAccount();
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
console.warn('Microsoft authentification needs "clientId" option');
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
loginMicrosoft() {
|
|
501
|
-
this.msalService
|
|
502
|
-
.loginPopup({ ...this.getConf().authRequest })
|
|
503
|
-
.subscribe((response) => {
|
|
504
|
-
this.msalService.instance.setActiveAccount(response.account);
|
|
505
|
-
this.checkAccount();
|
|
506
|
-
});
|
|
324
|
+
this.tokenService = tokenService;
|
|
325
|
+
this.http = http;
|
|
326
|
+
this.authOptions = this.config.getConfig('auth');
|
|
327
|
+
this.trustHosts = this.authOptions?.trustHosts || [];
|
|
328
|
+
this.trustHosts.push(window.location.hostname);
|
|
329
|
+
this.hostsWithCredentials = this.authOptions?.hostsWithCredentials || [];
|
|
330
|
+
this.hostsWithAuthByKey = this.authOptions?.hostsByKey || [];
|
|
507
331
|
}
|
|
508
|
-
|
|
509
|
-
this.
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
.loginWithToken(tokenAccess, 'microsoft', { tokenId })
|
|
516
|
-
.subscribe(() => {
|
|
517
|
-
this.appRef.tick();
|
|
518
|
-
this.login.emit(true);
|
|
332
|
+
intercept(originalReq, next) {
|
|
333
|
+
const withCredentials = this.handleHostsWithCredentials(originalReq.url);
|
|
334
|
+
let req = originalReq.clone();
|
|
335
|
+
const hostWithKey = this.handleHostsAuthByKey(originalReq.url);
|
|
336
|
+
if (hostWithKey) {
|
|
337
|
+
req = req.clone({
|
|
338
|
+
params: req.params.set(hostWithKey.key, hostWithKey.value)
|
|
519
339
|
});
|
|
520
|
-
})
|
|
521
|
-
.catch(async (error) => {
|
|
522
|
-
if (error instanceof InteractionRequiredAuthError) {
|
|
523
|
-
// fallback to interaction when silent call fails
|
|
524
|
-
return this.msalService.acquireTokenPopup(this.getConf().authRequest);
|
|
525
|
-
}
|
|
526
|
-
console.log(error);
|
|
527
|
-
})
|
|
528
|
-
.catch((error) => {
|
|
529
|
-
console.log('Silent token fails');
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
getConf() {
|
|
533
|
-
return this.msalGuardConfig.filter((conf) => conf.type === 'add')[0];
|
|
534
|
-
}
|
|
535
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthMicrosoftComponent, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i0.ApplicationRef }, { token: i3$2.MsalService }, { token: MSAL_GUARD_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
|
|
536
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: AuthMicrosoftComponent, isStandalone: true, selector: "igo-auth-microsoft", outputs: { login: "login" }, ngImport: i0, template: "<button\r\n class=\"microsoft-login-button\"\r\n mat-raised-button\r\n (click)=\"loginMicrosoft()\"\r\n>\r\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\r\n {{ 'igo.auth.microsoft.login' | translate }}\r\n</button>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i4$2.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5$2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
537
|
-
}
|
|
538
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthMicrosoftComponent, decorators: [{
|
|
539
|
-
type: Component,
|
|
540
|
-
args: [{ selector: 'igo-auth-microsoft', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [MatButtonModule, MatIconModule, TranslateModule], template: "<button\r\n class=\"microsoft-login-button\"\r\n mat-raised-button\r\n (click)=\"loginMicrosoft()\"\r\n>\r\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\r\n {{ 'igo.auth.microsoft.login' | translate }}\r\n</button>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
|
|
541
|
-
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: i3$2.MsalService }, { type: undefined, decorators: [{
|
|
542
|
-
type: Inject,
|
|
543
|
-
args: [MSAL_GUARD_CONFIG]
|
|
544
|
-
}] }], propDecorators: { login: [{
|
|
545
|
-
type: Output
|
|
546
|
-
}] } });
|
|
547
|
-
|
|
548
|
-
/*
|
|
549
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
550
|
-
* Licensed under the MIT License.
|
|
551
|
-
*/
|
|
552
|
-
class MsalServiceb2c {
|
|
553
|
-
instance;
|
|
554
|
-
location;
|
|
555
|
-
redirectHash;
|
|
556
|
-
logger;
|
|
557
|
-
name = '@azure/msal-angular';
|
|
558
|
-
version = '2.0.0-beta.2';
|
|
559
|
-
constructor(instance, location) {
|
|
560
|
-
this.instance = instance;
|
|
561
|
-
this.location = location;
|
|
562
|
-
const hash = this.location.path(true).split('#').pop();
|
|
563
|
-
if (hash) {
|
|
564
|
-
this.redirectHash = `#${hash}`;
|
|
565
|
-
}
|
|
566
|
-
this.instance.initializeWrapperLibrary(WrapperSKU.Angular, this.version);
|
|
567
|
-
}
|
|
568
|
-
initialize() {
|
|
569
|
-
return from(this.instance.initialize());
|
|
570
|
-
}
|
|
571
|
-
acquireTokenPopup(request) {
|
|
572
|
-
return from(this.instance.acquireTokenPopup(request));
|
|
573
|
-
}
|
|
574
|
-
acquireTokenRedirect(request) {
|
|
575
|
-
return from(this.instance.acquireTokenRedirect(request));
|
|
576
|
-
}
|
|
577
|
-
acquireTokenSilent(silentRequest) {
|
|
578
|
-
return from(this.instance.acquireTokenSilent(silentRequest));
|
|
579
|
-
}
|
|
580
|
-
handleRedirectObservable(hash) {
|
|
581
|
-
return from(this.instance.handleRedirectPromise(hash || this.redirectHash));
|
|
582
|
-
}
|
|
583
|
-
loginPopup(request) {
|
|
584
|
-
return from(this.instance.loginPopup(request));
|
|
585
|
-
}
|
|
586
|
-
loginRedirect(request) {
|
|
587
|
-
return from(this.instance.loginRedirect(request));
|
|
588
|
-
}
|
|
589
|
-
logout(logoutRequest) {
|
|
590
|
-
return from(this.instance.logout(logoutRequest));
|
|
591
|
-
}
|
|
592
|
-
logoutRedirect(logoutRequest) {
|
|
593
|
-
return from(this.instance.logoutRedirect(logoutRequest));
|
|
594
|
-
}
|
|
595
|
-
logoutPopup(logoutRequest) {
|
|
596
|
-
return from(this.instance.logoutPopup(logoutRequest));
|
|
597
|
-
}
|
|
598
|
-
ssoSilent(request) {
|
|
599
|
-
return from(this.instance.ssoSilent(request));
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Gets logger for msal-angular.
|
|
603
|
-
* If no logger set, returns logger instance created with same options as msal-browser
|
|
604
|
-
*/
|
|
605
|
-
getLogger() {
|
|
606
|
-
if (!this.logger) {
|
|
607
|
-
this.logger = this.instance.getLogger().clone(this.name, this.version);
|
|
608
340
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
setLogger(logger) {
|
|
613
|
-
this.logger = logger.clone(this.name, this.version);
|
|
614
|
-
this.instance.setLogger(logger);
|
|
615
|
-
}
|
|
616
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MsalServiceb2c, deps: [{ token: MSAL_INSTANCE }, { token: i1$1.Location }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
617
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MsalServiceb2c });
|
|
618
|
-
}
|
|
619
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MsalServiceb2c, decorators: [{
|
|
620
|
-
type: Injectable
|
|
621
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
622
|
-
type: Inject,
|
|
623
|
-
args: [MSAL_INSTANCE]
|
|
624
|
-
}] }, { type: i1$1.Location }] });
|
|
625
|
-
|
|
626
|
-
/*
|
|
627
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
628
|
-
* Licensed under the MIT License.
|
|
629
|
-
*/
|
|
630
|
-
class MsalBroadcastServiceb2c {
|
|
631
|
-
msalInstance;
|
|
632
|
-
authService;
|
|
633
|
-
_msalSubject;
|
|
634
|
-
msalSubject$;
|
|
635
|
-
_inProgress;
|
|
636
|
-
inProgress$;
|
|
637
|
-
constructor(msalInstance, authService) {
|
|
638
|
-
this.msalInstance = msalInstance;
|
|
639
|
-
this.authService = authService;
|
|
640
|
-
this._msalSubject = new Subject();
|
|
641
|
-
this.msalSubject$ = this._msalSubject.asObservable();
|
|
642
|
-
// InProgress as BehaviorSubject so most recent inProgress state will be available upon subscription
|
|
643
|
-
this._inProgress = new BehaviorSubject(InteractionStatus.Startup);
|
|
644
|
-
this.inProgress$ = this._inProgress.asObservable();
|
|
645
|
-
this.msalInstance.addEventCallback((message) => {
|
|
646
|
-
this._msalSubject.next(message);
|
|
647
|
-
const status = EventMessageUtils.getInteractionStatusFromEvent(message);
|
|
648
|
-
if (status !== null) {
|
|
649
|
-
this.authService
|
|
650
|
-
.getLogger()
|
|
651
|
-
.verbose(`BroadcastService - ${message.eventType} results in setting inProgress to ${status}`);
|
|
652
|
-
this._inProgress.next(status);
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MsalBroadcastServiceb2c, deps: [{ token: MSAL_INSTANCE }, { token: MsalServiceb2c }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
657
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MsalBroadcastServiceb2c });
|
|
658
|
-
}
|
|
659
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MsalBroadcastServiceb2c, decorators: [{
|
|
660
|
-
type: Injectable
|
|
661
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
662
|
-
type: Inject,
|
|
663
|
-
args: [MSAL_INSTANCE]
|
|
664
|
-
}] }, { type: MsalServiceb2c }] });
|
|
665
|
-
|
|
666
|
-
class AuthMicrosoftb2cComponent {
|
|
667
|
-
authService;
|
|
668
|
-
config;
|
|
669
|
-
appRef;
|
|
670
|
-
msalService;
|
|
671
|
-
msalGuardConfig;
|
|
672
|
-
options;
|
|
673
|
-
_destroying$ = new Subject();
|
|
674
|
-
login = new EventEmitter();
|
|
675
|
-
broadcastService;
|
|
676
|
-
constructor(authService, config, appRef, msalService, msalGuardConfig) {
|
|
677
|
-
this.authService = authService;
|
|
678
|
-
this.config = config;
|
|
679
|
-
this.appRef = appRef;
|
|
680
|
-
this.msalService = msalService;
|
|
681
|
-
this.msalGuardConfig = msalGuardConfig;
|
|
682
|
-
this.options = this.config.getConfig('auth.microsoftb2c') || {};
|
|
683
|
-
this.msalService.instance = new PublicClientApplication({
|
|
684
|
-
auth: this.options.browserAuthOptions,
|
|
685
|
-
cache: {
|
|
686
|
-
cacheLocation: 'sessionStorage'
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
this.broadcastService = new MsalBroadcastServiceb2c(this.msalService.instance, this.msalService);
|
|
690
|
-
if (this.options.browserAuthOptions.clientId) {
|
|
691
|
-
this.broadcastService.inProgress$
|
|
692
|
-
.pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
|
|
693
|
-
.subscribe(() => {
|
|
694
|
-
this.checkAccount();
|
|
341
|
+
if (withCredentials) {
|
|
342
|
+
req = originalReq.clone({
|
|
343
|
+
withCredentials
|
|
695
344
|
});
|
|
345
|
+
return next.handle(req);
|
|
346
|
+
}
|
|
347
|
+
this.refreshToken();
|
|
348
|
+
const token = this.tokenService.get();
|
|
349
|
+
const element = document.createElement('a');
|
|
350
|
+
element.href = req.url;
|
|
351
|
+
if (element.host === '') {
|
|
352
|
+
element.href = element.href; // FIX IE11, DO NOT REMOVE
|
|
696
353
|
}
|
|
697
|
-
|
|
698
|
-
|
|
354
|
+
if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
|
|
355
|
+
return next.handle(req);
|
|
699
356
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
.loginPopup({ ...this.getConf().authRequest })
|
|
704
|
-
.subscribe((response) => {
|
|
705
|
-
this.msalService.instance.setActiveAccount(response.account);
|
|
706
|
-
this.checkAccount();
|
|
357
|
+
const authHeader = `Bearer ${token}`;
|
|
358
|
+
let authReq = req.clone({
|
|
359
|
+
headers: req.headers.set('Authorization', authHeader)
|
|
707
360
|
});
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
.
|
|
712
|
-
|
|
713
|
-
const token = response.idToken;
|
|
714
|
-
this.authService.loginWithToken(token, 'microsoftb2c').subscribe(() => {
|
|
715
|
-
this.appRef.tick();
|
|
716
|
-
this.login.emit(true);
|
|
361
|
+
const tokenDecoded = this.tokenService.decode();
|
|
362
|
+
if (authReq.params.get('_i') === 'true' && tokenDecoded?.user?.sourceId) {
|
|
363
|
+
const hashUser = Md5.hashStr(tokenDecoded.user.sourceId);
|
|
364
|
+
authReq = authReq.clone({
|
|
365
|
+
params: authReq.params.set('_i', hashUser)
|
|
717
366
|
});
|
|
718
|
-
})
|
|
719
|
-
.catch(async (error) => {
|
|
720
|
-
if (error instanceof InteractionRequiredAuthError) {
|
|
721
|
-
// fallback to interaction when silent call fails
|
|
722
|
-
return this.msalService.acquireTokenPopup(this.getConf().authRequest);
|
|
723
|
-
}
|
|
724
|
-
})
|
|
725
|
-
.catch((error) => {
|
|
726
|
-
console.log('Silent token fails');
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
getConf() {
|
|
730
|
-
return this.msalGuardConfig.filter((conf) => conf.type === 'b2c')[0];
|
|
731
|
-
}
|
|
732
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthMicrosoftb2cComponent, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i0.ApplicationRef }, { token: MsalServiceb2c }, { token: MSAL_GUARD_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
|
|
733
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: AuthMicrosoftb2cComponent, isStandalone: true, selector: "igo-auth-microsoftb2c", outputs: { login: "login" }, ngImport: i0, template: "<button\r\n class=\"microsoft-login-button\"\r\n mat-raised-button\r\n (click)=\"loginMicrosoftb2c()\"\r\n>\r\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\r\n {{ 'igo.auth.microsoftb2c.login' | translate }}\r\n</button>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i4$2.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5$2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
734
|
-
}
|
|
735
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthMicrosoftb2cComponent, decorators: [{
|
|
736
|
-
type: Component,
|
|
737
|
-
args: [{ selector: 'igo-auth-microsoftb2c', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [MatButtonModule, MatIconModule, TranslateModule], template: "<button\r\n class=\"microsoft-login-button\"\r\n mat-raised-button\r\n (click)=\"loginMicrosoftb2c()\"\r\n>\r\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\r\n {{ 'igo.auth.microsoftb2c.login' | translate }}\r\n</button>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
|
|
738
|
-
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: MsalServiceb2c }, { type: undefined, decorators: [{
|
|
739
|
-
type: Inject,
|
|
740
|
-
args: [MSAL_GUARD_CONFIG]
|
|
741
|
-
}] }], propDecorators: { login: [{
|
|
742
|
-
type: Output
|
|
743
|
-
}] } });
|
|
744
|
-
|
|
745
|
-
class AuthFormComponent {
|
|
746
|
-
auth;
|
|
747
|
-
config;
|
|
748
|
-
router;
|
|
749
|
-
get backgroundDisable() {
|
|
750
|
-
if (this.isLogoutRoute || this.isLogoutRoute) {
|
|
751
|
-
return false;
|
|
752
|
-
}
|
|
753
|
-
return this._backgroundDisable;
|
|
754
|
-
}
|
|
755
|
-
set backgroundDisable(value) {
|
|
756
|
-
this._backgroundDisable = value.toString() === 'true';
|
|
757
|
-
}
|
|
758
|
-
_backgroundDisable = true;
|
|
759
|
-
get hasAlreadyConnectedDiv() {
|
|
760
|
-
return this._hasAlreadyConnectedDiv;
|
|
761
|
-
}
|
|
762
|
-
set hasAlreadyConnectedDiv(value) {
|
|
763
|
-
this._hasAlreadyConnectedDiv = value.toString() === 'true';
|
|
764
|
-
}
|
|
765
|
-
_hasAlreadyConnectedDiv = true;
|
|
766
|
-
get hasLogoutDiv() {
|
|
767
|
-
return this._hasLogoutDiv;
|
|
768
|
-
}
|
|
769
|
-
set hasLogoutDiv(value) {
|
|
770
|
-
this._hasLogoutDiv = value.toString() === 'true';
|
|
771
|
-
}
|
|
772
|
-
_hasLogoutDiv = true;
|
|
773
|
-
get showAlreadyConnectedDiv() {
|
|
774
|
-
if (this.isLogoutRoute) {
|
|
775
|
-
return this.hasAlreadyConnectedDiv;
|
|
776
367
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
_showAlreadyConnectedDiv = false;
|
|
783
|
-
get showLogoutDiv() {
|
|
784
|
-
if (this.isLogoutRoute) {
|
|
785
|
-
return this.hasLogoutDiv;
|
|
368
|
+
else if (authReq.params.get('_i') === 'true') {
|
|
369
|
+
authReq = authReq.clone({
|
|
370
|
+
params: authReq.params.delete('_i')
|
|
371
|
+
});
|
|
786
372
|
}
|
|
787
|
-
return
|
|
788
|
-
}
|
|
789
|
-
set showLogoutDiv(value) {
|
|
790
|
-
this._showLogoutDiv = value.toString() === 'true';
|
|
373
|
+
return next.handle(authReq);
|
|
791
374
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
if (
|
|
375
|
+
interceptXhr(xhr, url) {
|
|
376
|
+
const withCredentials = this.handleHostsWithCredentials(url);
|
|
377
|
+
if (withCredentials) {
|
|
378
|
+
xhr.withCredentials = withCredentials;
|
|
795
379
|
return true;
|
|
796
380
|
}
|
|
381
|
+
this.refreshToken();
|
|
382
|
+
const element = document.createElement('a');
|
|
383
|
+
element.href = url;
|
|
384
|
+
const token = this.tokenService.get();
|
|
385
|
+
if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
|
|
389
|
+
return true;
|
|
797
390
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
this.options = this.config.getConfig('auth');
|
|
809
|
-
this.visible = Object.getOwnPropertyNames(this.options).length !== 0;
|
|
810
|
-
}
|
|
811
|
-
ngOnInit() {
|
|
812
|
-
this.analyzeRoute();
|
|
813
|
-
this.getName();
|
|
814
|
-
}
|
|
815
|
-
onLogin() {
|
|
816
|
-
this.auth.goToRedirectUrl();
|
|
817
|
-
this.getName();
|
|
818
|
-
this.login.emit(true);
|
|
819
|
-
}
|
|
820
|
-
logout() {
|
|
821
|
-
this.auth.logout().subscribe(() => {
|
|
822
|
-
this.user = undefined;
|
|
823
|
-
if (this.router) {
|
|
824
|
-
if (this.options?.logoutRoute) {
|
|
825
|
-
this.router.navigate([this.options?.logoutRoute]);
|
|
826
|
-
}
|
|
827
|
-
else if (this.options?.homeRoute) {
|
|
828
|
-
this.router.navigate([this.options?.homeRoute]);
|
|
829
|
-
}
|
|
391
|
+
alterUrlWithKeyAuth(url) {
|
|
392
|
+
const hostWithKey = this.handleHostsAuthByKey(url);
|
|
393
|
+
let interceptedUrl = url;
|
|
394
|
+
if (hostWithKey) {
|
|
395
|
+
const urlDecomposed = interceptedUrl.split(/[?&]/);
|
|
396
|
+
let urlWithKeyAdded = urlDecomposed.shift();
|
|
397
|
+
const paramsToKeep = urlDecomposed.filter((p) => p.length !== 0);
|
|
398
|
+
paramsToKeep.push(`${hostWithKey.key}=${hostWithKey.value}`);
|
|
399
|
+
if (paramsToKeep.length) {
|
|
400
|
+
urlWithKeyAdded += '?' + paramsToKeep.join('&');
|
|
830
401
|
}
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
home() {
|
|
834
|
-
if (this.router && this.options?.homeRoute) {
|
|
835
|
-
this.router.navigate([this.options?.homeRoute]);
|
|
402
|
+
return urlWithKeyAdded;
|
|
836
403
|
}
|
|
404
|
+
return;
|
|
837
405
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
406
|
+
handleHostsWithCredentials(reqUrl) {
|
|
407
|
+
let withCredentials = false;
|
|
408
|
+
for (const hostWithCredentials of this.hostsWithCredentials) {
|
|
409
|
+
const domainRegex = new RegExp(hostWithCredentials.domainRegFilters);
|
|
410
|
+
if (domainRegex.test(reqUrl)) {
|
|
411
|
+
withCredentials =
|
|
412
|
+
hostWithCredentials.withCredentials !== undefined
|
|
413
|
+
? hostWithCredentials.withCredentials
|
|
414
|
+
: undefined;
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
844
417
|
}
|
|
418
|
+
return withCredentials;
|
|
845
419
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
if (this.isLogoutRoute) {
|
|
860
|
-
this.auth.logout();
|
|
420
|
+
handleHostsAuthByKey(reqUrl) {
|
|
421
|
+
let hostWithKey;
|
|
422
|
+
for (const hostWithAuthByKey of this.hostsWithAuthByKey) {
|
|
423
|
+
const domainRegex = new RegExp(hostWithAuthByKey.domainRegFilters);
|
|
424
|
+
if (domainRegex.test(reqUrl)) {
|
|
425
|
+
var replace = `${hostWithAuthByKey.keyProperty}=${hostWithAuthByKey.keyValue}`;
|
|
426
|
+
var keyAdded = new RegExp(replace, 'gm');
|
|
427
|
+
if (!keyAdded.test(reqUrl)) {
|
|
428
|
+
hostWithKey = {
|
|
429
|
+
key: hostWithAuthByKey.keyProperty,
|
|
430
|
+
value: hostWithAuthByKey.keyValue
|
|
431
|
+
};
|
|
432
|
+
break;
|
|
861
433
|
}
|
|
862
434
|
}
|
|
863
|
-
}
|
|
435
|
+
}
|
|
436
|
+
return hostWithKey;
|
|
437
|
+
}
|
|
438
|
+
refreshToken() {
|
|
439
|
+
const jwt = this.tokenService.decode();
|
|
440
|
+
const currentTime = new Date().getTime() / 1000;
|
|
441
|
+
if (!this.refreshInProgress &&
|
|
442
|
+
jwt &&
|
|
443
|
+
currentTime < jwt.exp &&
|
|
444
|
+
currentTime > jwt.exp - 1800) {
|
|
445
|
+
this.refreshInProgress = true;
|
|
446
|
+
const url = this.authOptions?.url;
|
|
447
|
+
return this.http.post(`${url}/refresh`, {}).subscribe((data) => {
|
|
448
|
+
this.tokenService.set(data.token);
|
|
449
|
+
this.refreshInProgress = false;
|
|
450
|
+
}, (err) => {
|
|
451
|
+
err.error.caught = true;
|
|
452
|
+
return err;
|
|
453
|
+
});
|
|
454
|
+
}
|
|
864
455
|
}
|
|
865
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
866
|
-
static
|
|
456
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthInterceptor, deps: [{ token: i2.ConfigService }, { token: TokenService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
457
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthInterceptor, providedIn: 'root' });
|
|
867
458
|
}
|
|
868
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
869
|
-
type:
|
|
870
|
-
args: [{
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
AuthMicrosoftb2cComponent,
|
|
875
|
-
AuthFacebookComponent,
|
|
876
|
-
AuthInternComponent,
|
|
877
|
-
MatButtonModule,
|
|
878
|
-
TranslateModule
|
|
879
|
-
], template: "<div *ngIf=\"visible\">\r\n <div\r\n *ngIf=\"!auth.logged && backgroundDisable\"\r\n class=\"backgroundDisable\"\r\n ></div>\r\n\r\n <div *ngIf=\"!auth.logged && showLoginDiv\" class=\"login center-block\">\r\n <h1>{{ 'igo.auth.connection' | translate }}</h1>\r\n\r\n <igo-auth-google\r\n *ngIf=\"options.google && options.google.enabled !== false\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-google>\r\n <igo-auth-microsoft\r\n *ngIf=\"options.microsoft && options.microsoft.enabled !== false\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-microsoft>\r\n <igo-auth-microsoftb2c\r\n *ngIf=\"options.microsoftb2c && options.microsoftb2c.enabled !== false\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-microsoftb2c>\r\n <igo-auth-facebook\r\n *ngIf=\"options.facebook && options.facebook.enabled !== false\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-facebook>\r\n <igo-auth-intern\r\n *ngIf=\"!options.intern || options.intern.enabled !== false\"\r\n [allowAnonymous]=\"options.allowAnonymous\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-intern>\r\n </div>\r\n\r\n <div\r\n *ngIf=\"auth.logged && showAlreadyConnectedDiv\"\r\n class=\"login center-block\"\r\n >\r\n <p>{{ 'igo.auth.welcome' | translate: user }}</p>\r\n <button mat-raised-button type=\"button\" (click)=\"logout()\">\r\n {{ 'igo.auth.signOut' | translate }}\r\n </button>\r\n </div>\r\n\r\n <div *ngIf=\"showLogoutDiv\" class=\"login center-block\">\r\n <p>{{ 'igo.auth.deconnection' | translate }}</p>\r\n <button\r\n *ngIf=\"options.homeRoute\"\r\n mat-raised-button\r\n type=\"button\"\r\n (click)=\"home()\"\r\n >\r\n {{ 'igo.auth.home' | translate }}\r\n </button>\r\n </div>\r\n</div>\r\n", styles: [":host{z-index:999}div.login{z-index:200;width:90%;min-width:360px;max-width:600px;padding:25px 50px;border:1px solid;background-color:#fff;border-color:#888}.center-block{position:fixed;top:20%;left:50%;transform:translate(-50%)}.backgroundDisable{position:fixed;top:0;left:0;background:#000;opacity:.8;z-index:100;height:100%;width:100%}\n"] }]
|
|
880
|
-
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router, decorators: [{
|
|
881
|
-
type: Optional
|
|
882
|
-
}] }], propDecorators: { backgroundDisable: [{
|
|
883
|
-
type: Input
|
|
884
|
-
}], hasAlreadyConnectedDiv: [{
|
|
885
|
-
type: Input
|
|
886
|
-
}], hasLogoutDiv: [{
|
|
887
|
-
type: Input
|
|
888
|
-
}], showAlreadyConnectedDiv: [{
|
|
889
|
-
type: Input
|
|
890
|
-
}], showLogoutDiv: [{
|
|
891
|
-
type: Input
|
|
892
|
-
}], login: [{
|
|
893
|
-
type: Output
|
|
894
|
-
}] } });
|
|
895
|
-
|
|
896
|
-
const AUTH_FORM_DIRECTIVES = [
|
|
897
|
-
AuthFormComponent,
|
|
898
|
-
AuthGoogleComponent,
|
|
899
|
-
AuthInternComponent,
|
|
900
|
-
AuthFacebookComponent,
|
|
901
|
-
AuthMicrosoftComponent,
|
|
902
|
-
AuthMicrosoftb2cComponent
|
|
903
|
-
];
|
|
459
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthInterceptor, decorators: [{
|
|
460
|
+
type: Injectable,
|
|
461
|
+
args: [{
|
|
462
|
+
providedIn: 'root'
|
|
463
|
+
}]
|
|
464
|
+
}], ctorParameters: () => [{ type: i2.ConfigService }, { type: TokenService }, { type: i1.HttpClient }] });
|
|
904
465
|
|
|
905
466
|
class LoggedGuard {
|
|
906
467
|
authService;
|
|
@@ -922,10 +483,10 @@ class LoggedGuard {
|
|
|
922
483
|
}
|
|
923
484
|
return false;
|
|
924
485
|
}
|
|
925
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
926
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
486
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: LoggedGuard, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
487
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: LoggedGuard, providedIn: 'root' });
|
|
927
488
|
}
|
|
928
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
489
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: LoggedGuard, decorators: [{
|
|
929
490
|
type: Injectable,
|
|
930
491
|
args: [{
|
|
931
492
|
providedIn: 'root'
|
|
@@ -952,10 +513,10 @@ class AuthGuard {
|
|
|
952
513
|
}
|
|
953
514
|
return false;
|
|
954
515
|
}
|
|
955
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
956
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
516
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthGuard, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
517
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthGuard, providedIn: 'root' });
|
|
957
518
|
}
|
|
958
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
519
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AuthGuard, decorators: [{
|
|
959
520
|
type: Injectable,
|
|
960
521
|
args: [{
|
|
961
522
|
providedIn: 'root'
|
|
@@ -982,10 +543,10 @@ class AdminGuard {
|
|
|
982
543
|
}
|
|
983
544
|
return false;
|
|
984
545
|
}
|
|
985
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
986
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
546
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AdminGuard, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
547
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AdminGuard, providedIn: 'root' });
|
|
987
548
|
}
|
|
988
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
549
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: AdminGuard, decorators: [{
|
|
989
550
|
type: Injectable,
|
|
990
551
|
args: [{
|
|
991
552
|
providedIn: 'root'
|
|
@@ -1016,498 +577,33 @@ class ProfilsGuard {
|
|
|
1016
577
|
return false;
|
|
1017
578
|
}));
|
|
1018
579
|
}
|
|
1019
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
1020
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
580
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: ProfilsGuard, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
581
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: ProfilsGuard, providedIn: 'root' });
|
|
1021
582
|
}
|
|
1022
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
583
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: ProfilsGuard, decorators: [{
|
|
1023
584
|
type: Injectable,
|
|
1024
585
|
args: [{
|
|
1025
586
|
providedIn: 'root'
|
|
1026
587
|
}]
|
|
1027
588
|
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }] });
|
|
1028
589
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
tokenService;
|
|
1032
|
-
http;
|
|
1033
|
-
authOptions;
|
|
1034
|
-
refreshInProgress = false;
|
|
1035
|
-
trustHosts;
|
|
1036
|
-
hostsWithCredentials;
|
|
1037
|
-
hostsWithAuthByKey;
|
|
1038
|
-
constructor(config, tokenService, http) {
|
|
1039
|
-
this.config = config;
|
|
1040
|
-
this.tokenService = tokenService;
|
|
1041
|
-
this.http = http;
|
|
1042
|
-
this.authOptions = this.config.getConfig('auth');
|
|
1043
|
-
this.trustHosts = this.authOptions?.trustHosts || [];
|
|
1044
|
-
this.trustHosts.push(window.location.hostname);
|
|
1045
|
-
this.hostsWithCredentials = this.authOptions?.hostsWithCredentials || [];
|
|
1046
|
-
this.hostsWithAuthByKey = this.authOptions?.hostsByKey || [];
|
|
1047
|
-
}
|
|
1048
|
-
intercept(originalReq, next) {
|
|
1049
|
-
const withCredentials = this.handleHostsWithCredentials(originalReq.url);
|
|
1050
|
-
let req = originalReq.clone();
|
|
1051
|
-
const hostWithKey = this.handleHostsAuthByKey(originalReq.url);
|
|
1052
|
-
if (hostWithKey) {
|
|
1053
|
-
req = req.clone({
|
|
1054
|
-
params: req.params.set(hostWithKey.key, hostWithKey.value)
|
|
1055
|
-
});
|
|
1056
|
-
}
|
|
1057
|
-
if (withCredentials) {
|
|
1058
|
-
req = originalReq.clone({
|
|
1059
|
-
withCredentials
|
|
1060
|
-
});
|
|
1061
|
-
return next.handle(req);
|
|
1062
|
-
}
|
|
1063
|
-
this.refreshToken();
|
|
1064
|
-
const token = this.tokenService.get();
|
|
1065
|
-
const element = document.createElement('a');
|
|
1066
|
-
element.href = req.url;
|
|
1067
|
-
if (element.host === '') {
|
|
1068
|
-
element.href = element.href; // FIX IE11, DO NOT REMOVE
|
|
1069
|
-
}
|
|
1070
|
-
if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
|
|
1071
|
-
return next.handle(req);
|
|
1072
|
-
}
|
|
1073
|
-
const authHeader = `Bearer ${token}`;
|
|
1074
|
-
let authReq = req.clone({
|
|
1075
|
-
headers: req.headers.set('Authorization', authHeader)
|
|
1076
|
-
});
|
|
1077
|
-
const tokenDecoded = this.tokenService.decode();
|
|
1078
|
-
if (authReq.params.get('_i') === 'true' && tokenDecoded?.user?.sourceId) {
|
|
1079
|
-
const hashUser = Md5.hashStr(tokenDecoded.user.sourceId);
|
|
1080
|
-
authReq = authReq.clone({
|
|
1081
|
-
params: authReq.params.set('_i', hashUser)
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
else if (authReq.params.get('_i') === 'true') {
|
|
1085
|
-
authReq = authReq.clone({
|
|
1086
|
-
params: authReq.params.delete('_i')
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
return next.handle(authReq);
|
|
1090
|
-
}
|
|
1091
|
-
interceptXhr(xhr, url) {
|
|
1092
|
-
const withCredentials = this.handleHostsWithCredentials(url);
|
|
1093
|
-
if (withCredentials) {
|
|
1094
|
-
xhr.withCredentials = withCredentials;
|
|
1095
|
-
return true;
|
|
1096
|
-
}
|
|
1097
|
-
this.refreshToken();
|
|
1098
|
-
const element = document.createElement('a');
|
|
1099
|
-
element.href = url;
|
|
1100
|
-
const token = this.tokenService.get();
|
|
1101
|
-
if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
|
|
1102
|
-
return false;
|
|
1103
|
-
}
|
|
1104
|
-
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
|
|
1105
|
-
return true;
|
|
1106
|
-
}
|
|
1107
|
-
alterUrlWithKeyAuth(url) {
|
|
1108
|
-
const hostWithKey = this.handleHostsAuthByKey(url);
|
|
1109
|
-
let interceptedUrl = url;
|
|
1110
|
-
if (hostWithKey) {
|
|
1111
|
-
const urlDecomposed = interceptedUrl.split(/[?&]/);
|
|
1112
|
-
let urlWithKeyAdded = urlDecomposed.shift();
|
|
1113
|
-
const paramsToKeep = urlDecomposed.filter((p) => p.length !== 0);
|
|
1114
|
-
paramsToKeep.push(`${hostWithKey.key}=${hostWithKey.value}`);
|
|
1115
|
-
if (paramsToKeep.length) {
|
|
1116
|
-
urlWithKeyAdded += '?' + paramsToKeep.join('&');
|
|
1117
|
-
}
|
|
1118
|
-
return urlWithKeyAdded;
|
|
1119
|
-
}
|
|
1120
|
-
return;
|
|
1121
|
-
}
|
|
1122
|
-
handleHostsWithCredentials(reqUrl) {
|
|
1123
|
-
let withCredentials = false;
|
|
1124
|
-
for (const hostWithCredentials of this.hostsWithCredentials) {
|
|
1125
|
-
const domainRegex = new RegExp(hostWithCredentials.domainRegFilters);
|
|
1126
|
-
if (domainRegex.test(reqUrl)) {
|
|
1127
|
-
withCredentials =
|
|
1128
|
-
hostWithCredentials.withCredentials !== undefined
|
|
1129
|
-
? hostWithCredentials.withCredentials
|
|
1130
|
-
: undefined;
|
|
1131
|
-
break;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
return withCredentials;
|
|
1135
|
-
}
|
|
1136
|
-
handleHostsAuthByKey(reqUrl) {
|
|
1137
|
-
let hostWithKey;
|
|
1138
|
-
for (const hostWithAuthByKey of this.hostsWithAuthByKey) {
|
|
1139
|
-
const domainRegex = new RegExp(hostWithAuthByKey.domainRegFilters);
|
|
1140
|
-
if (domainRegex.test(reqUrl)) {
|
|
1141
|
-
var replace = `${hostWithAuthByKey.keyProperty}=${hostWithAuthByKey.keyValue}`;
|
|
1142
|
-
var keyAdded = new RegExp(replace, 'gm');
|
|
1143
|
-
if (!keyAdded.test(reqUrl)) {
|
|
1144
|
-
hostWithKey = {
|
|
1145
|
-
key: hostWithAuthByKey.keyProperty,
|
|
1146
|
-
value: hostWithAuthByKey.keyValue
|
|
1147
|
-
};
|
|
1148
|
-
break;
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
return hostWithKey;
|
|
1153
|
-
}
|
|
1154
|
-
refreshToken() {
|
|
1155
|
-
const jwt = this.tokenService.decode();
|
|
1156
|
-
const currentTime = new Date().getTime() / 1000;
|
|
1157
|
-
if (!this.refreshInProgress &&
|
|
1158
|
-
jwt &&
|
|
1159
|
-
currentTime < jwt.exp &&
|
|
1160
|
-
currentTime > jwt.exp - 1800) {
|
|
1161
|
-
this.refreshInProgress = true;
|
|
1162
|
-
const url = this.authOptions?.url;
|
|
1163
|
-
return this.http.post(`${url}/refresh`, {}).subscribe((data) => {
|
|
1164
|
-
this.tokenService.set(data.token);
|
|
1165
|
-
this.refreshInProgress = false;
|
|
1166
|
-
}, (err) => {
|
|
1167
|
-
err.error.caught = true;
|
|
1168
|
-
return err;
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthInterceptor, deps: [{ token: i2.ConfigService }, { token: TokenService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1173
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthInterceptor, providedIn: 'root' });
|
|
1174
|
-
}
|
|
1175
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthInterceptor, decorators: [{
|
|
1176
|
-
type: Injectable,
|
|
1177
|
-
args: [{
|
|
1178
|
-
providedIn: 'root'
|
|
1179
|
-
}]
|
|
1180
|
-
}], ctorParameters: () => [{ type: i2.ConfigService }, { type: TokenService }, { type: i1.HttpClient }] });
|
|
1181
|
-
|
|
1182
|
-
function MSALConfigFactory(config) {
|
|
1183
|
-
const msConf = config.getConfig('auth.microsoft');
|
|
1184
|
-
msConf.redirectUri = msConf?.redirectUri || window.location.href;
|
|
1185
|
-
msConf.authority =
|
|
1186
|
-
msConf?.authority || 'https://login.microsoftonline.com/organizations';
|
|
1187
|
-
const myMsalObj = new PublicClientApplication({
|
|
1188
|
-
auth: msConf,
|
|
1189
|
-
cache: {
|
|
1190
|
-
cacheLocation: 'sessionStorage'
|
|
1191
|
-
}
|
|
1192
|
-
});
|
|
1193
|
-
return myMsalObj;
|
|
1194
|
-
}
|
|
1195
|
-
function MSALConfigFactoryb2c(config) {
|
|
1196
|
-
const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions');
|
|
1197
|
-
msConf.redirectUri = msConf?.redirectUri || window.location.href;
|
|
1198
|
-
msConf.authority =
|
|
1199
|
-
msConf?.authority || 'https://login.microsoftonline.com/organizations';
|
|
1200
|
-
const myMsalObj = new PublicClientApplication({
|
|
1201
|
-
auth: msConf,
|
|
1202
|
-
cache: {
|
|
1203
|
-
cacheLocation: 'sessionStorage'
|
|
1204
|
-
}
|
|
1205
|
-
});
|
|
1206
|
-
return myMsalObj;
|
|
1207
|
-
}
|
|
1208
|
-
function MSALAngularConfigFactory(config) {
|
|
1209
|
-
const msConf = config.getConfig('auth.microsoft');
|
|
1210
|
-
return {
|
|
1211
|
-
interactionType: InteractionType.Popup,
|
|
1212
|
-
authRequest: {
|
|
1213
|
-
scopes: ['user.read'],
|
|
1214
|
-
loginHint: 'todo'
|
|
1215
|
-
},
|
|
1216
|
-
type: 'add'
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
function MSALAngularConfigFactoryb2c(config) {
|
|
1220
|
-
const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions');
|
|
1221
|
-
return {
|
|
1222
|
-
interactionType: InteractionType.Popup,
|
|
1223
|
-
authRequest: {
|
|
1224
|
-
scopes: [msConf?.clientId]
|
|
1225
|
-
},
|
|
1226
|
-
type: 'b2c'
|
|
1227
|
-
};
|
|
1228
|
-
}
|
|
1229
|
-
function provideAuthMicrosoft(type) {
|
|
1230
|
-
if (type === 'b2c') {
|
|
1231
|
-
return [
|
|
1232
|
-
{
|
|
1233
|
-
provide: MSAL_INSTANCE,
|
|
1234
|
-
useFactory: MSALConfigFactoryb2c,
|
|
1235
|
-
deps: [ConfigService]
|
|
1236
|
-
},
|
|
1237
|
-
{
|
|
1238
|
-
provide: MSAL_GUARD_CONFIG,
|
|
1239
|
-
useFactory: MSALAngularConfigFactoryb2c,
|
|
1240
|
-
deps: [ConfigService],
|
|
1241
|
-
multi: true
|
|
1242
|
-
},
|
|
1243
|
-
MsalServiceb2c
|
|
1244
|
-
];
|
|
1245
|
-
}
|
|
1246
|
-
else {
|
|
1247
|
-
return [
|
|
1248
|
-
{
|
|
1249
|
-
provide: MSAL_INSTANCE,
|
|
1250
|
-
useFactory: MSALConfigFactory,
|
|
1251
|
-
deps: [ConfigService]
|
|
1252
|
-
},
|
|
1253
|
-
{
|
|
1254
|
-
provide: MSAL_GUARD_CONFIG,
|
|
1255
|
-
useFactory: MSALAngularConfigFactory,
|
|
1256
|
-
deps: [ConfigService],
|
|
1257
|
-
multi: true
|
|
1258
|
-
},
|
|
1259
|
-
MsalService
|
|
1260
|
-
];
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
class ProtectedDirective {
|
|
1265
|
-
constructor(authentication, el) {
|
|
1266
|
-
if (!authentication.isAuthenticated()) {
|
|
1267
|
-
el.nativeElement.parentNode.removeChild(el.nativeElement);
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ProtectedDirective, deps: [{ token: AuthService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1271
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: ProtectedDirective, isStandalone: true, selector: "[igoProtected]", ngImport: i0 });
|
|
1272
|
-
}
|
|
1273
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ProtectedDirective, decorators: [{
|
|
1274
|
-
type: Directive,
|
|
1275
|
-
args: [{
|
|
1276
|
-
selector: '[igoProtected]',
|
|
1277
|
-
standalone: true
|
|
1278
|
-
}]
|
|
1279
|
-
}], ctorParameters: () => [{ type: AuthService }, { type: i0.ElementRef }] });
|
|
1280
|
-
|
|
1281
|
-
class AuthStorageService extends BaseStorage {
|
|
1282
|
-
http;
|
|
1283
|
-
authService;
|
|
1284
|
-
tokenService;
|
|
1285
|
-
constructor(config, http, authService, tokenService) {
|
|
1286
|
-
super(config);
|
|
1287
|
-
this.http = http;
|
|
1288
|
-
this.authService = authService;
|
|
1289
|
-
this.tokenService = tokenService;
|
|
1290
|
-
this.authService.authenticate$.subscribe((isAuthenticated) => {
|
|
1291
|
-
if (isAuthenticated && this.options.url) {
|
|
1292
|
-
this.http
|
|
1293
|
-
.get(this.options.url)
|
|
1294
|
-
.subscribe((userIgo) => {
|
|
1295
|
-
if (userIgo && userIgo.preference) {
|
|
1296
|
-
for (const key of Object.keys(userIgo.preference)) {
|
|
1297
|
-
const value = userIgo.preference[key];
|
|
1298
|
-
super.set(key, value);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
});
|
|
1302
|
-
}
|
|
1303
|
-
});
|
|
1304
|
-
}
|
|
1305
|
-
set(key, value, scope = StorageScope.LOCAL) {
|
|
1306
|
-
if (scope === StorageScope.LOCAL &&
|
|
1307
|
-
this.authService.authenticated &&
|
|
1308
|
-
this.options.url) {
|
|
1309
|
-
const preference = {};
|
|
1310
|
-
preference[key] = value;
|
|
1311
|
-
this.http.patch(this.options.url, { preference }).subscribe();
|
|
1312
|
-
}
|
|
1313
|
-
super.set(key, value, scope);
|
|
1314
|
-
}
|
|
1315
|
-
remove(key, scope = StorageScope.LOCAL) {
|
|
1316
|
-
if (scope === StorageScope.LOCAL &&
|
|
1317
|
-
this.authService.authenticated &&
|
|
1318
|
-
this.options.url) {
|
|
1319
|
-
const preference = {};
|
|
1320
|
-
preference[key] = undefined;
|
|
1321
|
-
this.http.patch(this.options.url, { preference }).subscribe();
|
|
1322
|
-
}
|
|
1323
|
-
super.remove(key, scope);
|
|
1324
|
-
}
|
|
1325
|
-
clear(scope = StorageScope.LOCAL) {
|
|
1326
|
-
if (scope === StorageScope.LOCAL &&
|
|
1327
|
-
this.authService.authenticated &&
|
|
1328
|
-
this.options.url) {
|
|
1329
|
-
this.http
|
|
1330
|
-
.patch(this.options.url, { preference: {} }, {
|
|
1331
|
-
params: {
|
|
1332
|
-
mergePreference: 'false'
|
|
1333
|
-
}
|
|
1334
|
-
})
|
|
1335
|
-
.subscribe();
|
|
1336
|
-
}
|
|
1337
|
-
let token;
|
|
1338
|
-
if (scope === StorageScope.LOCAL) {
|
|
1339
|
-
token = this.tokenService.get();
|
|
1340
|
-
}
|
|
1341
|
-
super.clear(scope);
|
|
1342
|
-
if (token) {
|
|
1343
|
-
this.tokenService.set(token);
|
|
1344
|
-
}
|
|
1345
|
-
if (scope === StorageScope.LOCAL &&
|
|
1346
|
-
this.authService.authenticated &&
|
|
1347
|
-
this.options.url) {
|
|
1348
|
-
this.http
|
|
1349
|
-
.get(this.options.url)
|
|
1350
|
-
.subscribe((userIgo) => {
|
|
1351
|
-
if (userIgo && userIgo.preference) {
|
|
1352
|
-
for (const key of Object.keys(userIgo.preference)) {
|
|
1353
|
-
const value = userIgo.preference[key];
|
|
1354
|
-
super.set(key, value);
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
});
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthStorageService, deps: [{ token: i2.ConfigService }, { token: i1.HttpClient }, { token: AuthService }, { token: TokenService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1361
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthStorageService, providedIn: 'root' });
|
|
1362
|
-
}
|
|
1363
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthStorageService, decorators: [{
|
|
1364
|
-
type: Injectable,
|
|
1365
|
-
args: [{
|
|
1366
|
-
providedIn: 'root'
|
|
1367
|
-
}]
|
|
1368
|
-
}], ctorParameters: () => [{ type: i2.ConfigService }, { type: i1.HttpClient }, { type: AuthService }, { type: TokenService }] });
|
|
1369
|
-
|
|
1370
|
-
class AuthMonitoringService {
|
|
1371
|
-
configService;
|
|
1372
|
-
monitoringOptions;
|
|
1373
|
-
injector;
|
|
1374
|
-
// The AuthService need to be lazy provided because this service is provided in the APP_INITIALIZER
|
|
1375
|
-
authService;
|
|
1376
|
-
constructor(configService, monitoringOptions, injector) {
|
|
1377
|
-
this.configService = configService;
|
|
1378
|
-
this.monitoringOptions = monitoringOptions;
|
|
1379
|
-
this.injector = injector;
|
|
1380
|
-
if (!this.monitoringOptions?.identifyUser) {
|
|
1381
|
-
return;
|
|
1382
|
-
}
|
|
1383
|
-
this.configService.isLoaded$
|
|
1384
|
-
.pipe(first((isLoaded) => isLoaded), switchMap(() => {
|
|
1385
|
-
this.authService = this.injector.get(AuthService);
|
|
1386
|
-
return this.authService?.authenticate$;
|
|
1387
|
-
}))
|
|
1388
|
-
.subscribe((isAuthenticated) => {
|
|
1389
|
-
const user = isAuthenticated ? this.authService.user : null;
|
|
1390
|
-
this._identifyUser(user);
|
|
1391
|
-
});
|
|
1392
|
-
}
|
|
1393
|
-
_identifyUser(user) {
|
|
1394
|
-
switch (this.monitoringOptions.provider) {
|
|
1395
|
-
case 'sentry':
|
|
1396
|
-
identifySentryUser(user);
|
|
1397
|
-
break;
|
|
1398
|
-
default:
|
|
1399
|
-
break;
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthMonitoringService, deps: [{ token: i2.ConfigService }, { token: MONITORING_OPTIONS, optional: true }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1403
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthMonitoringService, providedIn: 'root' });
|
|
1404
|
-
}
|
|
1405
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthMonitoringService, decorators: [{
|
|
1406
|
-
type: Injectable,
|
|
1407
|
-
args: [{
|
|
1408
|
-
providedIn: 'root'
|
|
1409
|
-
}]
|
|
1410
|
-
}], ctorParameters: () => [{ type: i2.ConfigService }, { type: undefined, decorators: [{
|
|
1411
|
-
type: Optional
|
|
1412
|
-
}, {
|
|
1413
|
-
type: Inject,
|
|
1414
|
-
args: [MONITORING_OPTIONS]
|
|
1415
|
-
}] }, { type: i0.Injector }] });
|
|
1416
|
-
|
|
1417
|
-
function provideAuthUserMonitoring(options) {
|
|
1418
|
-
if (!options) {
|
|
1419
|
-
return [];
|
|
1420
|
-
}
|
|
1421
|
-
return [
|
|
590
|
+
function provideAuthentification(...features) {
|
|
591
|
+
const providers = [
|
|
1422
592
|
{
|
|
1423
|
-
provide:
|
|
1424
|
-
useClass:
|
|
1425
|
-
|
|
593
|
+
provide: HTTP_INTERCEPTORS,
|
|
594
|
+
useClass: AuthInterceptor,
|
|
595
|
+
multi: true
|
|
1426
596
|
},
|
|
1427
|
-
// Force instantiate Tracing service to avoid require it in any constructor.
|
|
1428
597
|
{
|
|
1429
|
-
provide:
|
|
1430
|
-
|
|
1431
|
-
deps: [AuthMonitoringService],
|
|
1432
|
-
multi: true
|
|
598
|
+
provide: StorageService,
|
|
599
|
+
useClass: AuthStorageService
|
|
1433
600
|
}
|
|
1434
601
|
];
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
class IgoAuthModule {
|
|
1438
|
-
static forRoot() {
|
|
1439
|
-
return {
|
|
1440
|
-
ngModule: IgoAuthModule,
|
|
1441
|
-
providers: [
|
|
1442
|
-
{
|
|
1443
|
-
provide: HTTP_INTERCEPTORS,
|
|
1444
|
-
useClass: AuthInterceptor,
|
|
1445
|
-
multi: true
|
|
1446
|
-
},
|
|
1447
|
-
{
|
|
1448
|
-
provide: StorageService,
|
|
1449
|
-
useClass: AuthStorageService
|
|
1450
|
-
},
|
|
1451
|
-
...provideAuthMicrosoft('add'),
|
|
1452
|
-
...provideAuthMicrosoft('b2c')
|
|
1453
|
-
]
|
|
1454
|
-
};
|
|
602
|
+
for (const feature of features) {
|
|
603
|
+
providers.push(...feature.providers);
|
|
1455
604
|
}
|
|
1456
|
-
|
|
1457
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.2.4", ngImport: i0, type: IgoAuthModule, imports: [CommonModule,
|
|
1458
|
-
ReactiveFormsModule,
|
|
1459
|
-
MatFormFieldModule,
|
|
1460
|
-
MatInputModule,
|
|
1461
|
-
MatIconModule,
|
|
1462
|
-
MatProgressSpinnerModule,
|
|
1463
|
-
MatButtonModule,
|
|
1464
|
-
IgoLanguageModule,
|
|
1465
|
-
MsalModule,
|
|
1466
|
-
AuthFormComponent,
|
|
1467
|
-
AuthGoogleComponent,
|
|
1468
|
-
AuthInternComponent,
|
|
1469
|
-
AuthFacebookComponent,
|
|
1470
|
-
AuthMicrosoftComponent,
|
|
1471
|
-
AuthMicrosoftb2cComponent,
|
|
1472
|
-
ProtectedDirective], exports: [AuthFormComponent, ProtectedDirective] });
|
|
1473
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: IgoAuthModule, imports: [CommonModule,
|
|
1474
|
-
ReactiveFormsModule,
|
|
1475
|
-
MatFormFieldModule,
|
|
1476
|
-
MatInputModule,
|
|
1477
|
-
MatIconModule,
|
|
1478
|
-
MatProgressSpinnerModule,
|
|
1479
|
-
MatButtonModule,
|
|
1480
|
-
IgoLanguageModule,
|
|
1481
|
-
MsalModule,
|
|
1482
|
-
AuthFormComponent,
|
|
1483
|
-
AuthInternComponent,
|
|
1484
|
-
AuthMicrosoftComponent,
|
|
1485
|
-
AuthMicrosoftb2cComponent] });
|
|
605
|
+
return makeEnvironmentProviders(providers);
|
|
1486
606
|
}
|
|
1487
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: IgoAuthModule, decorators: [{
|
|
1488
|
-
type: NgModule,
|
|
1489
|
-
args: [{
|
|
1490
|
-
imports: [
|
|
1491
|
-
CommonModule,
|
|
1492
|
-
ReactiveFormsModule,
|
|
1493
|
-
MatFormFieldModule,
|
|
1494
|
-
MatInputModule,
|
|
1495
|
-
MatIconModule,
|
|
1496
|
-
MatProgressSpinnerModule,
|
|
1497
|
-
MatButtonModule,
|
|
1498
|
-
IgoLanguageModule,
|
|
1499
|
-
MsalModule,
|
|
1500
|
-
AuthFormComponent,
|
|
1501
|
-
AuthGoogleComponent,
|
|
1502
|
-
AuthInternComponent,
|
|
1503
|
-
AuthFacebookComponent,
|
|
1504
|
-
AuthMicrosoftComponent,
|
|
1505
|
-
AuthMicrosoftb2cComponent,
|
|
1506
|
-
ProtectedDirective
|
|
1507
|
-
],
|
|
1508
|
-
exports: [AuthFormComponent, ProtectedDirective]
|
|
1509
|
-
}]
|
|
1510
|
-
}] });
|
|
1511
607
|
|
|
1512
608
|
/*
|
|
1513
609
|
* Public API Surface of auth
|
|
@@ -1517,5 +613,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
1517
613
|
* Generated bundle index. Do not edit.
|
|
1518
614
|
*/
|
|
1519
615
|
|
|
1520
|
-
export { AdminGuard,
|
|
616
|
+
export { AdminGuard, AuthFeatureKind, AuthGuard, AuthInterceptor, AuthService, AuthStorageService, LoggedGuard, ProfilsGuard, TokenService, provideAuthentification };
|
|
1521
617
|
//# sourceMappingURL=igo2-auth.mjs.map
|