@igo2/auth 16.0.0-rc.1 → 16.0.0-rc.2
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/esm2022/lib/auth-form/auth-facebook.component.mjs +2 -2
- package/esm2022/lib/auth-form/auth-form.component.mjs +4 -4
- package/esm2022/lib/auth-form/auth-google.component.mjs +2 -2
- package/esm2022/lib/auth-form/auth-intern.component.mjs +4 -4
- package/esm2022/lib/auth-form/auth-microsoft.component.mjs +6 -6
- package/esm2022/lib/auth-form/auth-microsoftb2c.component.mjs +6 -6
- package/esm2022/lib/auth-routing.module.mjs +1 -1
- package/esm2022/lib/auth.module.mjs +10 -10
- package/esm2022/lib/environment/environment.interface.mjs +2 -0
- package/esm2022/lib/environment/index.mjs +2 -0
- package/esm2022/lib/shared/admin.guard.mjs +2 -2
- package/esm2022/lib/shared/auth-microsoft.provider.mjs +3 -3
- package/esm2022/lib/shared/auth-msalBroadcastServiceb2c.service.mjs +2 -2
- package/esm2022/lib/shared/auth-msalServiceb2c.service..mjs +3 -3
- package/esm2022/lib/shared/auth.guard.mjs +2 -2
- package/esm2022/lib/shared/auth.interceptor.mjs +9 -8
- package/esm2022/lib/shared/auth.interface.mjs +1 -1
- package/esm2022/lib/shared/auth.service.mjs +17 -18
- package/esm2022/lib/shared/index.mjs +13 -0
- package/esm2022/lib/shared/logged.guard.mjs +2 -2
- package/esm2022/lib/shared/profils.guard.mjs +3 -3
- package/esm2022/lib/shared/protected.directive.mjs +1 -1
- package/esm2022/lib/shared/storage.interface.mjs +1 -1
- package/esm2022/lib/shared/storage.service.mjs +3 -3
- package/esm2022/lib/shared/token.service.mjs +2 -2
- package/esm2022/public_api.mjs +2 -1
- package/fesm2022/igo2-auth.mjs +24 -24
- package/fesm2022/igo2-auth.mjs.map +1 -1
- package/lib/auth-form/auth-form.component.d.ts +1 -1
- package/lib/auth-form/auth-intern.component.d.ts +2 -2
- package/lib/auth-form/auth-microsoft.component.d.ts +1 -1
- package/lib/auth-form/auth-microsoftb2c.component.d.ts +1 -1
- package/lib/environment/environment.interface.d.ts +5 -0
- package/lib/environment/index.d.ts +1 -0
- package/lib/shared/admin.guard.d.ts +1 -1
- package/lib/shared/auth-microsoft.provider.d.ts +2 -2
- package/lib/shared/auth-msalBroadcastServiceb2c.service.d.ts +1 -1
- package/lib/shared/auth-msalServiceb2c.service..d.ts +2 -2
- package/lib/shared/auth.guard.d.ts +1 -1
- package/lib/shared/auth.interceptor.d.ts +3 -2
- package/lib/shared/auth.interface.d.ts +3 -6
- package/lib/shared/auth.service.d.ts +3 -2
- package/lib/shared/index.d.ts +12 -0
- package/lib/shared/logged.guard.d.ts +1 -1
- package/lib/shared/profils.guard.d.ts +1 -1
- package/lib/shared/storage.service.d.ts +2 -2
- package/package.json +3 -3
- package/public_api.d.ts +1 -0
package/fesm2022/igo2-auth.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { Injectable, Optional, EventEmitter, Component, ChangeDetectionStrategy, Output, Input, Inject, Directive, NgModule } from '@angular/core';
|
|
3
3
|
import * as i3 from '@angular/router';
|
|
4
4
|
import { NavigationStart, RouterModule } from '@angular/router';
|
|
5
|
-
import { tap, catchError, filter, takeUntil, map } from 'rxjs/operators';
|
|
6
5
|
import * as i2 from '@igo2/core';
|
|
7
6
|
import { ConfigService, BaseStorage, StorageScope, StorageService, IgoLanguageModule } from '@igo2/core';
|
|
7
|
+
import { tap, catchError, filter, takeUntil, map } from 'rxjs/operators';
|
|
8
8
|
import * as i1 from '@angular/common/http';
|
|
9
9
|
import { HttpHeaders, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
10
|
+
import { Base64 } from '@igo2/utils';
|
|
10
11
|
import { BehaviorSubject, of, Subject, from } from 'rxjs';
|
|
11
12
|
import { globalCacheBusterNotifier } from 'ts-cacheable';
|
|
12
|
-
import { Base64 } from '@igo2/utils';
|
|
13
13
|
import jwtDecode from 'jwt-decode';
|
|
14
14
|
import * as i1$1 from '@angular/common';
|
|
15
15
|
import { CommonModule } from '@angular/common';
|
|
@@ -85,8 +85,9 @@ class AuthService {
|
|
|
85
85
|
redirectUrl;
|
|
86
86
|
languageForce = false;
|
|
87
87
|
anonymous = false;
|
|
88
|
+
authOptions;
|
|
88
89
|
get hasAuthService() {
|
|
89
|
-
return this.
|
|
90
|
+
return this.authOptions?.url !== undefined;
|
|
90
91
|
}
|
|
91
92
|
constructor(http, tokenService, config, languageService, messageService, router) {
|
|
92
93
|
this.http = http;
|
|
@@ -95,6 +96,7 @@ class AuthService {
|
|
|
95
96
|
this.languageService = languageService;
|
|
96
97
|
this.messageService = messageService;
|
|
97
98
|
this.router = router;
|
|
99
|
+
this.authOptions = this.config.getConfig('auth');
|
|
98
100
|
this.authenticate$.next(this.authenticated);
|
|
99
101
|
this.authenticate$.subscribe((authenticated) => {
|
|
100
102
|
this.logged$.next(authenticated);
|
|
@@ -124,8 +126,7 @@ class AuthService {
|
|
|
124
126
|
return of(true);
|
|
125
127
|
}
|
|
126
128
|
refresh() {
|
|
127
|
-
|
|
128
|
-
return this.http.post(`${url}/refresh`, {}).pipe(tap((data) => {
|
|
129
|
+
return this.http.post(`${this.authOptions?.url}/refresh`, {}).pipe(tap((data) => {
|
|
129
130
|
this.tokenService.set(data.token);
|
|
130
131
|
}), catchError((err) => {
|
|
131
132
|
err.error.caught = true;
|
|
@@ -155,9 +156,8 @@ class AuthService {
|
|
|
155
156
|
return;
|
|
156
157
|
}
|
|
157
158
|
const redirectUrl = this.redirectUrl || this.router.url;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const homeRoute = options.homeRoute || '/';
|
|
159
|
+
if (redirectUrl === this.authOptions.loginRoute) {
|
|
160
|
+
const homeRoute = this.authOptions.homeRoute || '/';
|
|
161
161
|
this.router.navigateByUrl(homeRoute);
|
|
162
162
|
}
|
|
163
163
|
else if (redirectUrl) {
|
|
@@ -165,16 +165,14 @@ class AuthService {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
getUserInfo() {
|
|
168
|
-
const url = this.
|
|
168
|
+
const url = this.authOptions?.url + '/info';
|
|
169
169
|
return this.http.get(url);
|
|
170
170
|
}
|
|
171
171
|
getProfils() {
|
|
172
|
-
|
|
173
|
-
return this.http.get(`${url}/profils`);
|
|
172
|
+
return this.http.get(`${this.authOptions?.url}/profils`);
|
|
174
173
|
}
|
|
175
174
|
updateUser(user) {
|
|
176
|
-
|
|
177
|
-
return this.http.patch(url, user);
|
|
175
|
+
return this.http.patch(this.authOptions?.url, user);
|
|
178
176
|
}
|
|
179
177
|
encodePassword(password) {
|
|
180
178
|
return Base64.encode(password);
|
|
@@ -197,8 +195,9 @@ class AuthService {
|
|
|
197
195
|
return false;
|
|
198
196
|
}
|
|
199
197
|
loginCall(body, headers) {
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
return this.http
|
|
199
|
+
.post(`${this.authOptions?.url}/login`, body, { headers })
|
|
200
|
+
.pipe(tap((data) => {
|
|
202
201
|
this.tokenService.set(data.token);
|
|
203
202
|
const tokenDecoded = this.decodeToken();
|
|
204
203
|
if (tokenDecoded && tokenDecoded.user) {
|
|
@@ -1095,7 +1094,7 @@ class LoggedGuard {
|
|
|
1095
1094
|
}
|
|
1096
1095
|
this.authService.redirectUrl = state.url;
|
|
1097
1096
|
const authConfig = this.config.getConfig('auth');
|
|
1098
|
-
if (authConfig
|
|
1097
|
+
if (authConfig?.loginRoute) {
|
|
1099
1098
|
this.router.navigateByUrl(authConfig.loginRoute);
|
|
1100
1099
|
}
|
|
1101
1100
|
return false;
|
|
@@ -1125,7 +1124,7 @@ class AuthGuard {
|
|
|
1125
1124
|
}
|
|
1126
1125
|
this.authService.redirectUrl = state.url;
|
|
1127
1126
|
const authConfig = this.config.getConfig('auth');
|
|
1128
|
-
if (authConfig
|
|
1127
|
+
if (authConfig?.loginRoute) {
|
|
1129
1128
|
this.router.navigateByUrl(authConfig.loginRoute);
|
|
1130
1129
|
}
|
|
1131
1130
|
return false;
|
|
@@ -1156,7 +1155,7 @@ class AdminGuard {
|
|
|
1156
1155
|
}
|
|
1157
1156
|
this.authService.redirectUrl = state.url;
|
|
1158
1157
|
const authConfig = this.config.getConfig('auth');
|
|
1159
|
-
if (authConfig
|
|
1158
|
+
if (authConfig?.loginRoute) {
|
|
1160
1159
|
this.router.navigateByUrl(authConfig.loginRoute);
|
|
1161
1160
|
}
|
|
1162
1161
|
return false;
|
|
@@ -1189,7 +1188,7 @@ class ProfilsGuard {
|
|
|
1189
1188
|
return true;
|
|
1190
1189
|
}
|
|
1191
1190
|
this.authService.redirectUrl = state.url;
|
|
1192
|
-
if (authConfig
|
|
1191
|
+
if (authConfig?.loginRoute) {
|
|
1193
1192
|
this.router.navigateByUrl(authConfig.loginRoute);
|
|
1194
1193
|
}
|
|
1195
1194
|
return false;
|
|
@@ -1209,6 +1208,7 @@ class AuthInterceptor {
|
|
|
1209
1208
|
config;
|
|
1210
1209
|
tokenService;
|
|
1211
1210
|
http;
|
|
1211
|
+
authOptions;
|
|
1212
1212
|
refreshInProgress = false;
|
|
1213
1213
|
trustHosts;
|
|
1214
1214
|
hostsWithCredentials;
|
|
@@ -1217,11 +1217,11 @@ class AuthInterceptor {
|
|
|
1217
1217
|
this.config = config;
|
|
1218
1218
|
this.tokenService = tokenService;
|
|
1219
1219
|
this.http = http;
|
|
1220
|
-
this.
|
|
1220
|
+
this.authOptions = this.config.getConfig('auth');
|
|
1221
|
+
this.trustHosts = this.authOptions?.trustHosts || [];
|
|
1221
1222
|
this.trustHosts.push(window.location.hostname);
|
|
1222
|
-
this.hostsWithCredentials =
|
|
1223
|
-
|
|
1224
|
-
this.hostsWithAuthByKey = this.config.getConfig('auth.hostsByKey') || [];
|
|
1223
|
+
this.hostsWithCredentials = this.authOptions?.hostsWithCredentials || [];
|
|
1224
|
+
this.hostsWithAuthByKey = this.authOptions?.hostsByKey || [];
|
|
1225
1225
|
}
|
|
1226
1226
|
intercept(originalReq, next) {
|
|
1227
1227
|
const withCredentials = this.handleHostsWithCredentials(originalReq.url);
|
|
@@ -1340,7 +1340,7 @@ class AuthInterceptor {
|
|
|
1340
1340
|
currentTime < jwt.exp &&
|
|
1341
1341
|
currentTime > jwt.exp - 1800) {
|
|
1342
1342
|
this.refreshInProgress = true;
|
|
1343
|
-
const url = this.
|
|
1343
|
+
const url = this.authOptions?.url;
|
|
1344
1344
|
return this.http.post(`${url}/refresh`, {}).subscribe((data) => {
|
|
1345
1345
|
this.tokenService.set(data.token);
|
|
1346
1346
|
this.refreshInProgress = false;
|