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