@huntsman-cancer-institute/authentication 12.5.0 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/authentication.component.d.ts +1 -1
  2. package/directlogin.component.d.ts +4 -4
  3. package/esm2020/authentication.component.mjs +131 -0
  4. package/esm2020/authentication.module.mjs +105 -0
  5. package/esm2020/authentication.provider.mjs +36 -0
  6. package/esm2020/authentication.service.mjs +393 -0
  7. package/esm2020/authorization.interceptor.mjs +79 -0
  8. package/esm2020/directlogin.component.mjs +96 -0
  9. package/esm2020/huntsman-cancer-institute-authentication.mjs +5 -0
  10. package/esm2020/index.mjs +13 -0
  11. package/esm2020/route-guard.service.mjs +52 -0
  12. package/esm2020/timeout-notification.component.mjs +148 -0
  13. package/fesm2015/huntsman-cancer-institute-authentication.mjs +1000 -0
  14. package/fesm2015/huntsman-cancer-institute-authentication.mjs.map +1 -0
  15. package/{fesm2015/huntsman-cancer-institute-authentication.js → fesm2020/huntsman-cancer-institute-authentication.mjs} +64 -189
  16. package/fesm2020/huntsman-cancer-institute-authentication.mjs.map +1 -0
  17. package/package.json +26 -18
  18. package/timeout-notification.component.d.ts +1 -1
  19. package/CHANGELOG.md +0 -4
  20. package/bundles/huntsman-cancer-institute-authentication.umd.js +0 -945
  21. package/bundles/huntsman-cancer-institute-authentication.umd.js.map +0 -1
  22. package/bundles/huntsman-cancer-institute-authentication.umd.min.js +0 -2
  23. package/bundles/huntsman-cancer-institute-authentication.umd.min.js.map +0 -1
  24. package/esm2015/authentication.component.js +0 -153
  25. package/esm2015/authentication.module.js +0 -107
  26. package/esm2015/authentication.provider.js +0 -36
  27. package/esm2015/authentication.service.js +0 -393
  28. package/esm2015/authorization.interceptor.js +0 -79
  29. package/esm2015/directlogin.component.js +0 -146
  30. package/esm2015/huntsman-cancer-institute-authentication.js +0 -5
  31. package/esm2015/index.js +0 -13
  32. package/esm2015/route-guard.service.js +0 -52
  33. package/esm2015/timeout-notification.component.js +0 -205
  34. package/esm5/authentication.component.js +0 -120
  35. package/esm5/authentication.module.js +0 -109
  36. package/esm5/authentication.provider.js +0 -47
  37. package/esm5/authentication.service.js +0 -411
  38. package/esm5/authorization.interceptor.js +0 -81
  39. package/esm5/directlogin.component.js +0 -53
  40. package/esm5/huntsman-cancer-institute-authentication.js +0 -5
  41. package/esm5/index.js +0 -13
  42. package/esm5/route-guard.service.js +0 -55
  43. package/esm5/timeout-notification.component.js +0 -125
  44. package/fesm2015/huntsman-cancer-institute-authentication.js.map +0 -1
  45. package/fesm5/huntsman-cancer-institute-authentication.js +0 -937
  46. package/fesm5/huntsman-cancer-institute-authentication.js.map +0 -1
  47. package/huntsman-cancer-institute-authentication.d.ts +0 -5
@@ -1,937 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, ɵɵngDeclareFactory, ɵɵFactoryTarget, ɵɵngDeclareInjectable, ɵɵngDeclareClassMetadata, Injectable, Inject, isDevMode, Optional, Renderer2, ɵɵngDeclareComponent, Component, ViewChild, Injector, ɵɵngDeclareNgModule, ɵɵngDeclareInjector, NgModule, SkipSelf } from '@angular/core';
3
- import { LocationStrategy, Location, NgIf, AsyncPipe, CommonModule } from '@angular/common';
4
- import { Validators, FormBuilder, ɵNgNoValidate, NgControlStatusGroup, FormGroupDirective, DefaultValueAccessor, NgControlStatus, FormControlName, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
- import { HttpHeaders, HttpClient, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
6
- import { Router, RouterModule } from '@angular/router';
7
- import { CoolLocalStorage, CoolStorageModule } from '@angular-cool/storage';
8
- import { JwtHelperService, JwtInterceptor, JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
9
- import { BehaviorSubject, interval, throwError, timer } from 'rxjs';
10
- import { map, catchError, first, takeWhile } from 'rxjs/operators';
11
- import { DomSanitizer } from '@angular/platform-browser';
12
- import { trigger, state, style, transition, animate } from '@angular/animations';
13
-
14
- var AUTHENTICATION_TOKEN_KEY = new InjectionToken("authentication_token_key");
15
- var AuthenticationProvider = /** @class */ (function () {
16
- function AuthenticationProvider(_localStorageService, _authenticationTokenKey) {
17
- var _this = this;
18
- this._localStorageService = _localStorageService;
19
- this._authenticationTokenKey = _authenticationTokenKey;
20
- this.whitelistedDomains = [
21
- "localhost",
22
- new RegExp(".*[.]utah[.]edu")
23
- ];
24
- this.tokenGetter = function () {
25
- return _this.authToken;
26
- };
27
- }
28
- Object.defineProperty(AuthenticationProvider.prototype, "authenticationTokenKey", {
29
- get: function () {
30
- return this._authenticationTokenKey;
31
- },
32
- set: function (_authenticationTokenKey) {
33
- this._authenticationTokenKey = _authenticationTokenKey;
34
- },
35
- enumerable: false,
36
- configurable: true
37
- });
38
- Object.defineProperty(AuthenticationProvider.prototype, "authToken", {
39
- get: function () {
40
- return this._localStorageService.getItem(this._authenticationTokenKey);
41
- },
42
- enumerable: false,
43
- configurable: true
44
- });
45
- AuthenticationProvider.ɵfac = ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationProvider, deps: [{ token: CoolLocalStorage }, { token: AUTHENTICATION_TOKEN_KEY }], target: ɵɵFactoryTarget.Injectable });
46
- AuthenticationProvider.ɵprov = ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationProvider });
47
- return AuthenticationProvider;
48
- }());
49
- ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationProvider, decorators: [{
50
- type: Injectable
51
- }], ctorParameters: function () { return [{ type: CoolLocalStorage }, { type: undefined, decorators: [{
52
- type: Inject,
53
- args: [AUTHENTICATION_TOKEN_KEY]
54
- }] }]; } });
55
-
56
- /*
57
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
58
- */
59
- /**
60
- * The token used for injection of the server side endpoint for the currently authenticated subject.
61
- *
62
- * @type {InjectionToken}
63
- */
64
- var AUTHENTICATION_SERVER_URL = new InjectionToken("authentication_server_rest_api");
65
- var AUTHENTICATION_LOGOUT_PATH = new InjectionToken("authentication_logout_path");
66
- var AUTHENTICATION_DIRECT_ENDPOINT = new InjectionToken("authentication_direct_endpoint");
67
- var AUTHENTICATION_TOKEN_ENDPOINT = new InjectionToken("authentication_token_endpoint");
68
- var AUTHENTICATION_ROUTE = new InjectionToken("authentication_route");
69
- var AUTHENTICATION_MAX_INACTIVITY_MINUTES = new InjectionToken("authentication_max_inactivity");
70
- var AUTHENTICATION_USER_COUNTDOWN_SECONDS = new InjectionToken("authentication_user_countdown_seconds");
71
- var AUTHENTICATION_IDP_INACTIVITY_MINUTES = new InjectionToken("authentication_idp_inactivity_minutes");
72
- /**
73
- * @since 1.0.0
74
- */
75
- var AuthenticationService = /** @class */ (function () {
76
- function AuthenticationService(_http, _router, _localStorageService, _jwtHelper, authenticationProvider, _authenticationRoute, _logoutPath, _tokenEndpoint, _serverUrl, _directEndpoint, _maxInactivity, _userCountdownSeconds, _idpInactivityMinutes, locationStrategy) {
77
- this._http = _http;
78
- this._router = _router;
79
- this._localStorageService = _localStorageService;
80
- this._jwtHelper = _jwtHelper;
81
- this.authenticationProvider = authenticationProvider;
82
- this._authenticationRoute = _authenticationRoute;
83
- this._logoutPath = _logoutPath;
84
- this._tokenEndpoint = _tokenEndpoint;
85
- this._serverUrl = _serverUrl;
86
- this._directEndpoint = _directEndpoint;
87
- this._maxInactivity = _maxInactivity;
88
- this._userCountdownSeconds = _userCountdownSeconds;
89
- this._idpInactivityMinutes = _idpInactivityMinutes;
90
- this.locationStrategy = locationStrategy;
91
- this.userCountdownSeconds = 60;
92
- this.idpInactivityMinutes = 5;
93
- this.contentType = "application/json";
94
- this.limitedContext = false;
95
- this.deidentifiedContext = false;
96
- this.maxViewPermission = new BehaviorSubject("viewident");
97
- this._isAuthenticatedSubject = new BehaviorSubject(false);
98
- this._userIsAboutToTimeOut = new BehaviorSubject(false);
99
- this._maxInactivityMinutes = 120;
100
- this.contextRoot = "";
101
- if (isDevMode()) {
102
- console.debug("window.location.href: " + window.location.href);
103
- }
104
- if (window.location) {
105
- var parts = window.location.href.split("/");
106
- this.baseUrl = parts[0] + "//" + parts[2];
107
- if (parts.length > 3) {
108
- this.contextRoot = parts[3];
109
- }
110
- }
111
- if (this._localStorageService.getItem("maxViewPermission")) {
112
- this.maxViewPermission.next(this._localStorageService.getItem("maxViewPermission"));
113
- }
114
- if (_maxInactivity) {
115
- this._maxInactivityMinutes = _maxInactivity;
116
- }
117
- if (_userCountdownSeconds) {
118
- this.userCountdownSeconds = _userCountdownSeconds;
119
- }
120
- if (_idpInactivityMinutes) {
121
- this.idpInactivityMinutes = _idpInactivityMinutes;
122
- }
123
- this.hasValidConfig();
124
- //There could be a non-expired token in local storage.
125
- var token = this.authenticationProvider.authToken;
126
- this.storeToken(token);
127
- }
128
- AuthenticationService.prototype.getBaseUrl = function () {
129
- return (this.baseUrl) ? this.baseUrl : "";
130
- };
131
- AuthenticationService.prototype.getContextRoot = function () {
132
- return this.contextRoot;
133
- };
134
- AuthenticationService.prototype.getHeaders = function (req) {
135
- var headers = req.headers;
136
- //Don't set content type if already set
137
- if (!req.headers.get(AuthenticationService.CONTENT_TYPE)) {
138
- headers = headers.set(AuthenticationService.CONTENT_TYPE, this.contentType.toString());
139
- }
140
- if (headers.get(AuthenticationService.SEC_GOV_CLASS_HEADER) === "") {
141
- headers = headers.delete(AuthenticationService.SEC_GOV_CLASS_HEADER);
142
- }
143
- else if (this.securityGovernorClass && !headers.get(AuthenticationService.SEC_GOV_CLASS_HEADER)) {
144
- headers = headers.set(AuthenticationService.SEC_GOV_CLASS_HEADER, this.securityGovernorClass);
145
- }
146
- if (headers.get(AuthenticationService.SEC_GOV_ID_HEADER) === "") {
147
- headers = headers.delete(AuthenticationService.SEC_GOV_ID_HEADER);
148
- }
149
- else if (this.securityGovernorId && !headers.get(AuthenticationService.SEC_GOV_ID_HEADER)) {
150
- headers = headers.set(AuthenticationService.SEC_GOV_ID_HEADER, this.securityGovernorId.toString());
151
- }
152
- headers = headers.set(AuthenticationService.DEIDENT_HEADER, this.deidentifiedContext.toString());
153
- headers = headers.set(AuthenticationService.LIMITED_HEADER, this.limitedContext.toString());
154
- return headers;
155
- };
156
- Object.defineProperty(AuthenticationService.prototype, "authenticationTokenKey", {
157
- get: function () {
158
- return this.authenticationProvider.authenticationTokenKey;
159
- },
160
- enumerable: false,
161
- configurable: true
162
- });
163
- Object.defineProperty(AuthenticationService.prototype, "authToken", {
164
- get: function () {
165
- return this.authenticationProvider.authToken;
166
- },
167
- enumerable: false,
168
- configurable: true
169
- });
170
- AuthenticationService.prototype.updateUserActivity = function () {
171
- if (this._isAuthenticatedSubject.value) {
172
- this._lastUserInteraction = new Date();
173
- this._userIsAboutToTimeOut.next(false);
174
- }
175
- };
176
- Object.defineProperty(AuthenticationService.prototype, "redirectUrl", {
177
- get: function () {
178
- return this._redirectUrl;
179
- },
180
- /**
181
- * A mutator for identifying the clients original request location. Setting this value will influence the end location
182
- * navigated to by {@link #navigateToPath}.
183
- *
184
- * @param redirectUrl location of the users request before authentication
185
- */
186
- set: function (redirectUrl) {
187
- this._redirectUrl = redirectUrl;
188
- },
189
- enumerable: false,
190
- configurable: true
191
- });
192
- AuthenticationService.prototype.requestAccessToken = function (redirectOnSuccess) {
193
- var _this = this;
194
- this._http.get(this.tokenLocation(), { withCredentials: true })
195
- .subscribe(function (response) {
196
- _this.storeToken(response.auth_token);
197
- if (redirectOnSuccess) {
198
- _this.proceedIfAuthenticated();
199
- }
200
- }, function (error) {
201
- //Token refresh failed.
202
- _this.logout(true);
203
- });
204
- };
205
- /**
206
- * Verifies whether or not a current user session exists.
207
- *
208
- * @returns {Observable<boolean>} evaluates to true if the user is authenticated, false otherwise.
209
- */
210
- AuthenticationService.prototype.isAuthenticated = function () {
211
- return this._isAuthenticatedSubject.asObservable();
212
- };
213
- AuthenticationService.prototype.isAboutToTimeOut = function () {
214
- return this._userIsAboutToTimeOut.asObservable();
215
- };
216
- AuthenticationService.prototype.getTimeoutStart = function () {
217
- if (this._lastUserInteraction) {
218
- return this._lastUserInteraction.valueOf() + (((this._maxInactivityMinutes * 60) - this.userCountdownSeconds) * 1000);
219
- }
220
- };
221
- AuthenticationService.prototype.tokenLocation = function () {
222
- if (this._serverUrl) {
223
- return this._serverUrl + this._tokenEndpoint;
224
- }
225
- else {
226
- return this._tokenEndpoint;
227
- }
228
- };
229
- AuthenticationService.prototype.directLoginLocation = function () {
230
- if (this._serverUrl) {
231
- return this._serverUrl + this._directEndpoint;
232
- }
233
- else {
234
- return this._directEndpoint;
235
- }
236
- };
237
- AuthenticationService.prototype.logoutLocation = function () {
238
- if (this._serverUrl) {
239
- return this._serverUrl + this._logoutPath;
240
- }
241
- else {
242
- return this._logoutPath;
243
- }
244
- };
245
- /**
246
- * A function to authenticated the user with the provided credentials. Failure results in an error that describes the
247
- * server response (status and status message) and should be actionable by the client application.
248
- *
249
- * @param username of the authenticating user to verify
250
- * @param password of the authenticating user to verify
251
- * @returns {Observable<R>} describing the result of the login action, true or an error
252
- */
253
- AuthenticationService.prototype.login = function (_username, _password) {
254
- return this._http.post(this.directLoginLocation(), { username: _username, password: _password }, { observe: "response" }).pipe(map(function (resp) {
255
- if (resp.status === 201) {
256
- return true;
257
- }
258
- else {
259
- throw new Error("Authentication failed. " + resp.status + ": " + resp.statusText);
260
- }
261
- }), catchError(this.handleError));
262
- };
263
- AuthenticationService.prototype.clearLogin = function () {
264
- //Front-end logout
265
- try {
266
- this._localStorageService.removeItem(this.authenticationProvider.authenticationTokenKey);
267
- this.unsubscribeFromTokenRefresh();
268
- this._isAuthenticatedSubject.next(false);
269
- this._userIsAboutToTimeOut.next(false);
270
- }
271
- catch (Error) {
272
- }
273
- //Back-end logout
274
- var headers = new HttpHeaders().set(AuthenticationService.CONTENT_TYPE, "text/plain");
275
- return this._http.get(this.logoutLocation(), { headers: headers });
276
- };
277
- /**
278
- * A function to signal the termination of the current session. Invoking this function will clean up any relevant state
279
- * related to the last active session.
280
- */
281
- AuthenticationService.prototype.logout = function (keepCurrentRoute) {
282
- var _this = this;
283
- if (keepCurrentRoute === void 0) { keepCurrentRoute = false; }
284
- //Prevent logout if already on authentication route. Doing otherwise screws up SAML
285
- if (!this._router.routerState || this._router.routerState.snapshot.url !== this._authenticationRoute) {
286
- this._redirectUrl = (keepCurrentRoute && this._router.routerState && this._router.routerState.snapshot) ? this._router.routerState.snapshot.url : "";
287
- if (this._redirectUrl.startsWith("/")) {
288
- this._redirectUrl = this._redirectUrl.substring(1);
289
- }
290
- this.clearLogin().subscribe(function (response) {
291
- window.location.replace(_this._redirectUrl);
292
- }, function (error) {
293
- window.location.replace(_this._redirectUrl);
294
- });
295
- }
296
- };
297
- AuthenticationService.prototype.storeToken = function (token) {
298
- var valid = this.validateToken(token);
299
- // unsubscribe from refesh before we decide wether to resubscribe
300
- this.unsubscribeFromTokenRefresh();
301
- if (valid) {
302
- this._localStorageService.setItem(this.authenticationProvider.authenticationTokenKey, token);
303
- this.subscribeToTokenRefresh(token);
304
- //Change the BehaviorSubject if the user was not previously authenticated.
305
- //Since other code may be subscribing to this observable, we don't want to cause new events to fire if just refreshing the JWT.
306
- if (!this._isAuthenticatedSubject.value) {
307
- this._isAuthenticatedSubject.next(true);
308
- }
309
- }
310
- else {
311
- this._localStorageService.removeItem(this.authenticationProvider.authenticationTokenKey);
312
- this._isAuthenticatedSubject.next(false);
313
- }
314
- };
315
- AuthenticationService.prototype.proceedIfAuthenticated = function () {
316
- if (isDevMode()) {
317
- console.debug("AuthenticationService.proceedIfAuthenticated: " + this._redirectUrl);
318
- }
319
- if (this._isAuthenticatedSubject.value) {
320
- //Login counts as user activity, too
321
- this.updateUserActivity();
322
- if (this._redirectUrl && this._redirectUrl && this._redirectUrl !== "") {
323
- this._router.navigateByUrl(this._redirectUrl);
324
- }
325
- else {
326
- this._router.navigate([""]);
327
- }
328
- return true;
329
- }
330
- else {
331
- return false;
332
- }
333
- };
334
- AuthenticationService.prototype.validateToken = function (token) {
335
- return (token && !this._jwtHelper.isTokenExpired(token));
336
- };
337
- AuthenticationService.prototype.subscribeToTokenRefresh = function (token) {
338
- var _this = this;
339
- var exp = this._jwtHelper.getTokenExpirationDate(token);
340
- // Use a timer to periodically check timeouts
341
- this._refreshSubscription = interval(1000)
342
- .subscribe(function () {
343
- // If a tab is inactive we can't know if our timer is accurate
344
- // so when the interval hits check against timestamps
345
- if (_this._isAuthenticatedSubject.value && Date.now() > _this.getTimeoutStart()) {
346
- //Don't update the subject more than once! Doing so initializes more than one countdown timer!
347
- if (_this._userIsAboutToTimeOut.getValue() !== true) {
348
- _this._userIsAboutToTimeOut.next(true);
349
- }
350
- }
351
- // check for refresh token
352
- var msToExpiry = (exp.valueOf() - new Date().valueOf());
353
- // Refresh 60 seconds before expiry
354
- if (msToExpiry <= 60000) {
355
- _this.refreshTokenIfUserIsActive();
356
- }
357
- });
358
- };
359
- AuthenticationService.prototype.unsubscribeFromTokenRefresh = function () {
360
- if (this._refreshSubscription && !this._refreshSubscription.closed) {
361
- this._refreshSubscription.unsubscribe();
362
- }
363
- };
364
- AuthenticationService.prototype.getMaxViewPermission = function () {
365
- return this.maxViewPermission.getValue();
366
- };
367
- AuthenticationService.prototype.getMaxViewPermissionSubject = function () {
368
- return this.maxViewPermission;
369
- };
370
- AuthenticationService.prototype.setMaxViewPermission = function (maxViewPermission) {
371
- this._localStorageService.setItem("maxViewPermission", maxViewPermission);
372
- this.maxViewPermission.next(maxViewPermission);
373
- };
374
- AuthenticationService.prototype.refreshTokenIfUserIsActive = function () {
375
- //Only refresh if the user has been active
376
- if (this._lastUserInteraction && ((new Date().valueOf() - this._lastUserInteraction.valueOf()) <= (this._maxInactivityMinutes * 60 * 1000))) {
377
- this.requestAccessToken(false);
378
- }
379
- };
380
- AuthenticationService.prototype.hasValidConfig = function () {
381
- if (this._tokenEndpoint == null && (this._serverUrl === null || this._logoutPath === null)) {
382
- throw new Error("BUG ALERT! Invalid AuthenticationService configuration. No valid configuration for authentication endpoint(s).");
383
- }
384
- if (this._localStorageService === null || this.authenticationProvider.authenticationTokenKey === null) {
385
- throw new Error("BUG ALERT! Invalid AuthenticationService configuration. No valid configuration for local storage");
386
- }
387
- };
388
- AuthenticationService.prototype.handleError = function (error) {
389
- var errMsg = (error.message) ? error.message : AuthenticationService.GENERIC_ERR_MSG;
390
- return throwError(errMsg);
391
- };
392
- /**
393
- * The generic error message used when a server error is thrown without a status.
394
- *
395
- * @type {string}
396
- */
397
- AuthenticationService.GENERIC_ERR_MSG = "Server error";
398
- AuthenticationService.CONTENT_TYPE = "Content-Type";
399
- AuthenticationService.SEC_GOV_CLASS_HEADER = "SecurityGovernorClass";
400
- AuthenticationService.SEC_GOV_ID_HEADER = "SecurityGovernorId";
401
- AuthenticationService.DEIDENT_HEADER = "DeidentifiedContext";
402
- AuthenticationService.LIMITED_HEADER = "LimitedContext";
403
- AuthenticationService.ɵfac = ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationService, deps: [{ token: HttpClient }, { token: Router }, { token: CoolLocalStorage }, { token: JwtHelperService }, { token: AuthenticationProvider }, { token: AUTHENTICATION_ROUTE }, { token: AUTHENTICATION_LOGOUT_PATH }, { token: AUTHENTICATION_TOKEN_ENDPOINT }, { token: AUTHENTICATION_SERVER_URL, optional: true }, { token: AUTHENTICATION_DIRECT_ENDPOINT, optional: true }, { token: AUTHENTICATION_MAX_INACTIVITY_MINUTES, optional: true }, { token: AUTHENTICATION_USER_COUNTDOWN_SECONDS, optional: true }, { token: AUTHENTICATION_IDP_INACTIVITY_MINUTES, optional: true }, { token: LocationStrategy, optional: true }], target: ɵɵFactoryTarget.Injectable });
404
- AuthenticationService.ɵprov = ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationService });
405
- return AuthenticationService;
406
- }());
407
- ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationService, decorators: [{
408
- type: Injectable
409
- }], ctorParameters: function () { return [{ type: HttpClient }, { type: Router }, { type: CoolLocalStorage }, { type: JwtHelperService }, { type: AuthenticationProvider }, { type: undefined, decorators: [{
410
- type: Inject,
411
- args: [AUTHENTICATION_ROUTE]
412
- }] }, { type: undefined, decorators: [{
413
- type: Inject,
414
- args: [AUTHENTICATION_LOGOUT_PATH]
415
- }] }, { type: undefined, decorators: [{
416
- type: Inject,
417
- args: [AUTHENTICATION_TOKEN_ENDPOINT]
418
- }] }, { type: undefined, decorators: [{
419
- type: Optional
420
- }, {
421
- type: Inject,
422
- args: [AUTHENTICATION_SERVER_URL]
423
- }] }, { type: undefined, decorators: [{
424
- type: Optional
425
- }, {
426
- type: Inject,
427
- args: [AUTHENTICATION_DIRECT_ENDPOINT]
428
- }] }, { type: undefined, decorators: [{
429
- type: Optional
430
- }, {
431
- type: Inject,
432
- args: [AUTHENTICATION_MAX_INACTIVITY_MINUTES]
433
- }] }, { type: undefined, decorators: [{
434
- type: Optional
435
- }, {
436
- type: Inject,
437
- args: [AUTHENTICATION_USER_COUNTDOWN_SECONDS]
438
- }] }, { type: undefined, decorators: [{
439
- type: Optional
440
- }, {
441
- type: Inject,
442
- args: [AUTHENTICATION_IDP_INACTIVITY_MINUTES]
443
- }] }, { type: LocationStrategy, decorators: [{
444
- type: Optional
445
- }, {
446
- type: Inject,
447
- args: [LocationStrategy]
448
- }] }]; } });
449
-
450
- /*
451
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
452
- */
453
- /**
454
- * A {@code CanActivate} implementation which makes its calculation based on the current authentication state.
455
- *
456
- * @since 1.0.0
457
- */
458
- var RouteGuardService = /** @class */ (function () {
459
- function RouteGuardService(_authenticationService, _router, _authenticationRoute) {
460
- this._authenticationService = _authenticationService;
461
- this._router = _router;
462
- this._authenticationRoute = _authenticationRoute;
463
- }
464
- /**
465
- * Determines whether or not a route can be activated, based on the current authentication state.
466
- *
467
- * @param route for activation to be determined on
468
- * @param state of the router snapshot
469
- * @returns {Observable<boolean>} describing the result of this calculation
470
- */
471
- RouteGuardService.prototype.canActivate = function (route, state) {
472
- var _this = this;
473
- return this._authenticationService.isAuthenticated().pipe(map(function (authenticated) {
474
- if (!authenticated) {
475
- // Store the attempted URL for redirecting
476
- _this._authenticationService.redirectUrl = state.url;
477
- // Navigate to the login page
478
- _this._router.navigate([_this._authenticationRoute]);
479
- }
480
- return authenticated;
481
- }, function (error) {
482
- return false;
483
- }));
484
- };
485
- ;
486
- RouteGuardService.ɵfac = ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RouteGuardService, deps: [{ token: AuthenticationService }, { token: Router }, { token: AUTHENTICATION_ROUTE }], target: ɵɵFactoryTarget.Injectable });
487
- RouteGuardService.ɵprov = ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RouteGuardService });
488
- return RouteGuardService;
489
- }());
490
- ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RouteGuardService, decorators: [{
491
- type: Injectable
492
- }], ctorParameters: function () { return [{ type: AuthenticationService }, { type: Router }, { type: undefined, decorators: [{
493
- type: Inject,
494
- args: [AUTHENTICATION_ROUTE]
495
- }] }]; } });
496
-
497
- /*
498
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
499
- */
500
- var AuthenticationComponent = /** @class */ (function () {
501
- function AuthenticationComponent(authenticationService, domSanitizer, router, location, renderer, authenticationRoute) {
502
- this.authenticationService = authenticationService;
503
- this.domSanitizer = domSanitizer;
504
- this.router = router;
505
- this.location = location;
506
- this.renderer = renderer;
507
- this.authenticationRoute = authenticationRoute;
508
- }
509
- AuthenticationComponent.prototype.ngOnInit = function () {
510
- /*
511
- * Fix back bug
512
- * Issue is that the browser will go back to the previous route. If it's guarded, the route guard will just load the login again
513
- * Eventually the browser gets to the /authenticate route and going back from there loads the iframe history and Shibboleth displays
514
- * an error relating to navigating back.
515
- */
516
- history.pushState(null, null, this.location.prepareExternalUrl(this.authenticationRoute));
517
- this.popstateSubscription = this.location.subscribe(function (value) {
518
- //This is going to prevent back from working from the login component
519
- history.go(1);
520
- });
521
- this.beginAuthenticationProcess();
522
- };
523
- AuthenticationComponent.prototype.handleChanges = function () {
524
- if (!this.iframe.nativeElement.contentDocument) {
525
- return;
526
- }
527
- try {
528
- var element = this.iframe.nativeElement.contentDocument.body;
529
- if (element.querySelector("pre")) {
530
- element = element.querySelector("pre");
531
- }
532
- this._errorMsg = null;
533
- var jsonText = element.innerText;
534
- var json = JSON.parse(jsonText);
535
- this.authenticationService.storeToken(json.auth_token);
536
- var authenticated = this.authenticationService.proceedIfAuthenticated();
537
- if (!authenticated) {
538
- this.resetSubscription.unsubscribe();
539
- this.beginAuthenticationProcess();
540
- }
541
- }
542
- catch (error) {
543
- if (this.iframe.nativeElement.contentDocument.title.toUpperCase() === "ERROR") {
544
- if (this.iframe.nativeElement.contentDocument.body.innerHTML.toUpperCase() === "FORBIDDEN") {
545
- this._errorMsg = "You do not have permission to log into this application";
546
- }
547
- else {
548
- this._errorMsg = null;
549
- }
550
- //A bit of a workaround for a WildFly issue. Success on Pac4j authentication, but failure on DB load of user put things in a weird state. Just logout, and redo the login.
551
- this.clearLoginAndRetry();
552
- }
553
- }
554
- // After the iframe loads, make the background transparent so we use the implementation's background and not the sso background.
555
- this.renderer.setStyle(this.iframe.nativeElement.contentDocument.body, "background-color", "transparent");
556
- };
557
- AuthenticationComponent.prototype.ngOnDestroy = function () {
558
- this.resetSubscription.unsubscribe();
559
- this.popstateSubscription.unsubscribe();
560
- };
561
- AuthenticationComponent.prototype.clearLoginAndRetry = function () {
562
- var _this = this;
563
- this.resetSubscription.unsubscribe();
564
- this.authenticationService.clearLogin().subscribe(function () { _this.beginAuthenticationProcess(); }, function (error) { _this.beginAuthenticationProcess(); });
565
- };
566
- AuthenticationComponent.prototype.beginAuthenticationProcess = function () {
567
- var _this = this;
568
- var tokenEndpoint = this.authenticationService.tokenLocation();
569
- if (tokenEndpoint !== "") {
570
- this.url = this.domSanitizer.bypassSecurityTrustResourceUrl(tokenEndpoint);
571
- }
572
- /**
573
- * If the user doesn't complete authentication before the IdP session times out, that will be a problem when they eventually
574
- * attampt to log in. It is likely that users will do this often when they log out or are timed out in the evening, leave
575
- * their browser open, then attempt to log back in in the morning. In order to work around this, this component will re-request
576
- * the token prior to IdP timeout, which will reset the process. This will happen 1 minute before idpInactivityMinutes
577
- **/
578
- this.resetSubscription = interval((this.authenticationService.idpInactivityMinutes - 1) * 60 * 1000)
579
- .pipe(first())
580
- .subscribe(function (value) {
581
- _this.beginAuthenticationProcess();
582
- });
583
- };
584
- AuthenticationComponent.ɵfac = ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationComponent, deps: [{ token: AuthenticationService }, { token: DomSanitizer }, { token: Router }, { token: Location }, { token: Renderer2 }, { token: AUTHENTICATION_ROUTE }], target: ɵɵFactoryTarget.Component });
585
- AuthenticationComponent.ɵcmp = ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: AuthenticationComponent, selector: "authentication-iframe", host: { classAttribute: "outlet-row" }, viewQueries: [{ propertyName: "iframe", first: true, predicate: ["iframe"], descendants: true, static: true }], ngImport: i0, template: "\n <div class=\"container\">\n <iframe #iframe class=\"frame\" [src]=\"url\" (load)=\"handleChanges()\"></iframe>\n <div *ngIf=\"_errorMsg\" class=\"alert-box\">\n <div class=\"alert alert-danger\">\n <h5 class=\"alert-heading\">Authentication Failed</h5>\n <span id=\"hci-login-error\" class=\"alert-text\">{{_errorMsg}}</span>\n </div>\n </div>\n </div>\n ", isInline: true, styles: ["\n \n :host {\n background-color: white;\n }\n \n .container {\n max-width: 100%;\n margin-top: 60px;\n padding-top: 15px;\n }\n\n .frame {\n width: 100%;\n height: 100%;\n border: 0px;\n }\n "], directives: [{ type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
586
- return AuthenticationComponent;
587
- }());
588
- ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationComponent, decorators: [{
589
- type: Component,
590
- args: [{
591
- selector: "authentication-iframe",
592
- template: "\n <div class=\"container\">\n <iframe #iframe class=\"frame\" [src]=\"url\" (load)=\"handleChanges()\"></iframe>\n <div *ngIf=\"_errorMsg\" class=\"alert-box\">\n <div class=\"alert alert-danger\">\n <h5 class=\"alert-heading\">Authentication Failed</h5>\n <span id=\"hci-login-error\" class=\"alert-text\">{{_errorMsg}}</span>\n </div>\n </div>\n </div>\n ",
593
- styles: ["\n \n :host {\n background-color: white;\n }\n \n .container {\n max-width: 100%;\n margin-top: 60px;\n padding-top: 15px;\n }\n\n .frame {\n width: 100%;\n height: 100%;\n border: 0px;\n }\n "],
594
- host: { class: "outlet-row" }
595
- }]
596
- }], ctorParameters: function () { return [{ type: AuthenticationService }, { type: DomSanitizer }, { type: Router }, { type: Location }, { type: Renderer2 }, { type: undefined, decorators: [{
597
- type: Inject,
598
- args: [AUTHENTICATION_ROUTE]
599
- }] }]; }, propDecorators: { iframe: [{
600
- type: ViewChild,
601
- args: ["iframe", { static: true }]
602
- }] } });
603
-
604
- /*
605
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
606
- */
607
- var DirectLoginComponent = /** @class */ (function () {
608
- function DirectLoginComponent(_authenticationService, _formBuilder) {
609
- this._authenticationService = _authenticationService;
610
- this._formBuilder = _formBuilder;
611
- }
612
- /**
613
- * Initializes the authentication form.
614
- */
615
- DirectLoginComponent.prototype.ngOnInit = function () {
616
- this._loginForm = this._formBuilder.group({
617
- username: ["", Validators.required],
618
- password: ["", Validators.required]
619
- });
620
- };
621
- /**
622
- * A function to submit the login form the the {@link UserService}.
623
- */
624
- DirectLoginComponent.prototype.login = function () {
625
- var _this = this;
626
- this._authenticationService.login(this._loginForm.value.username, this._loginForm.value.password)
627
- .subscribe(function (res) {
628
- if (res) {
629
- _this._errorMsg = null;
630
- _this._authenticationService.requestAccessToken(true);
631
- }
632
- }, function (error) {
633
- _this._errorMsg = "Please check your username and password.";
634
- });
635
- };
636
- DirectLoginComponent.ɵfac = ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DirectLoginComponent, deps: [{ token: AuthenticationService }, { token: FormBuilder }], target: ɵɵFactoryTarget.Component });
637
- DirectLoginComponent.ɵcmp = ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: DirectLoginComponent, selector: "hci-login-form", ngImport: i0, template: "\n <div class=\"container\">\n <div class=\"login-box\" id=\"hci-login-form-box\">\n <div class=\"login-heading\" id=\"hci-login-form-heading\">\n <h3>Sign in</h3>\n </div>\n <div class=\"panel-body\">\n <form [formGroup]=\"_loginForm\" (ngSubmit)=\"login()\">\n <input formControlName=\"username\" class=\"form-control\" id=\"username\" name=\"username\" placeholder=\"Username\" type=\"text\">\n <input formControlName=\"password\" class=\"form-control\" id=\"password\" name=\"password\" type=\"password\" placeholder=\"Password\">\n \n <div *ngIf=\"_errorMsg\" class=\"alert-box\">\n <div class=\"alert alert-danger\">\n <h5 class=\"alert-heading\">Authentication Failed</h5>\n <span id=\"hci-login-error\" class=\"alert-text\">{{_errorMsg}}</span>\n </div>\n </div>\n \n <div class=\"btn-box\">\n <button class=\"btn btn-primary\" id=\"hci-login-form-submit-button\" type=\"submit\" [disabled]=\"!_loginForm.valid\">Login</button>\n </div>\n </form>\n </div>\n </div>\n </div>\n ", isInline: true, styles: ["\n .container {\n max-width: 400px;\n margin-top: 20px;\n padding-top: 15px;\n }\n \n .login-box {\n border-radius: 10px;\n box-shadow: 0 0 2px #ccc;\n padding: 15px;\n }\n \n .login-box .login-heading h3 {\n line-height:1.5;\n margin: 0 0 10px\n }\n \n .login-box .form-control {\n padding: 10px;\n border: 1px solid #ccc;\n }\n \n .login-box input[type=\"password\"] {\n margin-bottom: 10px;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n \n .login-box input[type=\"text\"] {\n margin-bottom: -1px;\n border-bottom-right-radius: 0;\n border-bottom-left-radius: 0;\n }\n \n .login-box .alert-box {\n margin: 10px 0 -5px 0\n }\n \n .login-box .alert-text {\n font-size: small;\n }\n \n .login-box .btn-box {\n margin: 10px 0 0px 0\n }\n "], directives: [{ type: ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
638
- return DirectLoginComponent;
639
- }());
640
- ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DirectLoginComponent, decorators: [{
641
- type: Component,
642
- args: [{
643
- selector: "hci-login-form",
644
- template: "\n <div class=\"container\">\n <div class=\"login-box\" id=\"hci-login-form-box\">\n <div class=\"login-heading\" id=\"hci-login-form-heading\">\n <h3>Sign in</h3>\n </div>\n <div class=\"panel-body\">\n <form [formGroup]=\"_loginForm\" (ngSubmit)=\"login()\">\n <input formControlName=\"username\" class=\"form-control\" id=\"username\" name=\"username\" placeholder=\"Username\" type=\"text\">\n <input formControlName=\"password\" class=\"form-control\" id=\"password\" name=\"password\" type=\"password\" placeholder=\"Password\">\n \n <div *ngIf=\"_errorMsg\" class=\"alert-box\">\n <div class=\"alert alert-danger\">\n <h5 class=\"alert-heading\">Authentication Failed</h5>\n <span id=\"hci-login-error\" class=\"alert-text\">{{_errorMsg}}</span>\n </div>\n </div>\n \n <div class=\"btn-box\">\n <button class=\"btn btn-primary\" id=\"hci-login-form-submit-button\" type=\"submit\" [disabled]=\"!_loginForm.valid\">Login</button>\n </div>\n </form>\n </div>\n </div>\n </div>\n ",
645
- styles: ["\n .container {\n max-width: 400px;\n margin-top: 20px;\n padding-top: 15px;\n }\n \n .login-box {\n border-radius: 10px;\n box-shadow: 0 0 2px #ccc;\n padding: 15px;\n }\n \n .login-box .login-heading h3 {\n line-height:1.5;\n margin: 0 0 10px\n }\n \n .login-box .form-control {\n padding: 10px;\n border: 1px solid #ccc;\n }\n \n .login-box input[type=\"password\"] {\n margin-bottom: 10px;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n \n .login-box input[type=\"text\"] {\n margin-bottom: -1px;\n border-bottom-right-radius: 0;\n border-bottom-left-radius: 0;\n }\n \n .login-box .alert-box {\n margin: 10px 0 -5px 0\n }\n \n .login-box .alert-text {\n font-size: small;\n }\n \n .login-box .btn-box {\n margin: 10px 0 0px 0\n }\n "]
646
- }]
647
- }], ctorParameters: function () { return [{ type: AuthenticationService }, { type: FormBuilder }]; } });
648
-
649
- /*
650
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
651
- */
652
- var TimeoutNotificationComponent = /** @class */ (function () {
653
- function TimeoutNotificationComponent(authenticationService) {
654
- var _this = this;
655
- this.authenticationService = authenticationService;
656
- this.openState = "hidden";
657
- authenticationService.isAboutToTimeOut().subscribe(function (isAboutToTimeOut) {
658
- if (isAboutToTimeOut) {
659
- _this.openState = "opened";
660
- _this.startCountdown();
661
- }
662
- else {
663
- _this.openState = "hidden";
664
- //If something changed mid-timeout, cancel the timeout/logout.
665
- if (_this.subscription != null && !_this.subscription.closed) {
666
- _this.subscription.unsubscribe();
667
- }
668
- }
669
- });
670
- }
671
- TimeoutNotificationComponent.prototype.startCountdown = function () {
672
- var _this = this;
673
- this.seconds = timer(0, 1000)
674
- .pipe(map(function () {
675
- var elapsed = Math.round((Date.now() - _this.authenticationService.getTimeoutStart()) / 1000);
676
- return _this.authenticationService.userCountdownSeconds - elapsed;
677
- }),
678
- // The true argument emits the final value that completed the observable
679
- takeWhile(function (value) { return value > 0; }, true));
680
- this.subscription = this.seconds.subscribe(function (value) {
681
- if (value < 1) {
682
- _this.subscription.unsubscribe();
683
- _this.authenticationService.logout(true);
684
- }
685
- });
686
- };
687
- TimeoutNotificationComponent.prototype.click = function () {
688
- this.subscription.unsubscribe();
689
- this.authenticationService.updateUserActivity();
690
- };
691
- TimeoutNotificationComponent.ɵfac = ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TimeoutNotificationComponent, deps: [{ token: AuthenticationService }], target: ɵɵFactoryTarget.Component });
692
- TimeoutNotificationComponent.ɵcmp = ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TimeoutNotificationComponent, selector: "timeout-notification", ngImport: i0, template: "\n <div class=\"flyout-max\" [@openBacksplash]=\"openState\">\n <div class=\"modal-dialog\" [@openModal]=\"openState\" role=\"document\">\n <div class=\"modal-header\">\n <h4 class=\"modal-title\">Your Session Is About To Expire</h4>\n </div>\n <div class=\"modal-body\">\n <p>For your security, your session is about to automatically time out in the next <b>{{seconds | async}}</b> seconds. Would you like to stay signed in?</p>\n </div>\n <div class=\"modal-footer\">\n <ng-container>\n <button id=\"updateBtn\" type=\"button\" class=\"btn btn-secondary\" (click)=\"click()\">Yes, Keep me signed in</button>\n </ng-container>\n </div>\n </div>\n </div>\n ", isInline: true, styles: ["\n\n .flyout-max {\n position: fixed;\n z-index: 9999;\n top: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.4);\n width: 100vw;\n }\n \n .modal-dialog {\n position: fixed;\n max-width: 50vw;\n min-width: 50vw;\n left: -50vw;\n top: 25vw;\n margin: 0;\n background-color: white;\n border: black 1px solid;\n border-left: none;\n border-top-right-radius: 20px;\n border-bottom-right-radius: 20px;\n border-top-left-radius: 20px;\n border-bottom-left-radius: 20px;\n pointer-events: all;\n }\n \n .modal-body {\n width: 100%;\n display: inline-block;\n }\n \n .modal-body-left {\n display: inline-block;\n overflow-y: auto;\n overflow-x: hidden;\n min-height: 300px;\n max-height: 300px;\n }\n \n .modal-body-right {\n width: 70%;\n vertical-align: top;\n padding-left: 15px;\n border-left: black 1px solid;\n margin-left: 15px;\n display: inline-block;\n overflow-y: auto;\n min-height: 300px;\n max-height: 300px;\n }\n "], pipes: { "async": AsyncPipe }, animations: [
693
- trigger("openBacksplash", [
694
- state("in", style({
695
- "display": "none"
696
- })),
697
- state("hidden", style({
698
- "display": "none"
699
- })),
700
- state("opened", style({
701
- "display": "inherit"
702
- })),
703
- transition("hidden => opened", animate(100)),
704
- transition("opened => hidden", animate(200))
705
- ]),
706
- trigger("openModal", [
707
- state("in", style({
708
- "opacity": "0",
709
- "left": "-50vw"
710
- })),
711
- state("hidden", style({
712
- "opacity": "0",
713
- "left": "-50vw"
714
- })),
715
- state("opened", style({
716
- "opacity": "1",
717
- "left": "25vw"
718
- })),
719
- transition("hidden => opened", animate(500)),
720
- transition("opened => hidden", animate(300))
721
- ])
722
- ] });
723
- return TimeoutNotificationComponent;
724
- }());
725
- ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TimeoutNotificationComponent, decorators: [{
726
- type: Component,
727
- args: [{
728
- selector: "timeout-notification",
729
- template: "\n <div class=\"flyout-max\" [@openBacksplash]=\"openState\">\n <div class=\"modal-dialog\" [@openModal]=\"openState\" role=\"document\">\n <div class=\"modal-header\">\n <h4 class=\"modal-title\">Your Session Is About To Expire</h4>\n </div>\n <div class=\"modal-body\">\n <p>For your security, your session is about to automatically time out in the next <b>{{seconds | async}}</b> seconds. Would you like to stay signed in?</p>\n </div>\n <div class=\"modal-footer\">\n <ng-container>\n <button id=\"updateBtn\" type=\"button\" class=\"btn btn-secondary\" (click)=\"click()\">Yes, Keep me signed in</button>\n </ng-container>\n </div>\n </div>\n </div>\n ",
730
- animations: [
731
- trigger("openBacksplash", [
732
- state("in", style({
733
- "display": "none"
734
- })),
735
- state("hidden", style({
736
- "display": "none"
737
- })),
738
- state("opened", style({
739
- "display": "inherit"
740
- })),
741
- transition("hidden => opened", animate(100)),
742
- transition("opened => hidden", animate(200))
743
- ]),
744
- trigger("openModal", [
745
- state("in", style({
746
- "opacity": "0",
747
- "left": "-50vw"
748
- })),
749
- state("hidden", style({
750
- "opacity": "0",
751
- "left": "-50vw"
752
- })),
753
- state("opened", style({
754
- "opacity": "1",
755
- "left": "25vw"
756
- })),
757
- transition("hidden => opened", animate(500)),
758
- transition("opened => hidden", animate(300))
759
- ])
760
- ],
761
- styles: ["\n\n .flyout-max {\n position: fixed;\n z-index: 9999;\n top: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.4);\n width: 100vw;\n }\n \n .modal-dialog {\n position: fixed;\n max-width: 50vw;\n min-width: 50vw;\n left: -50vw;\n top: 25vw;\n margin: 0;\n background-color: white;\n border: black 1px solid;\n border-left: none;\n border-top-right-radius: 20px;\n border-bottom-right-radius: 20px;\n border-top-left-radius: 20px;\n border-bottom-left-radius: 20px;\n pointer-events: all;\n }\n \n .modal-body {\n width: 100%;\n display: inline-block;\n }\n \n .modal-body-left {\n display: inline-block;\n overflow-y: auto;\n overflow-x: hidden;\n min-height: 300px;\n max-height: 300px;\n }\n \n .modal-body-right {\n width: 70%;\n vertical-align: top;\n padding-left: 15px;\n border-left: black 1px solid;\n margin-left: 15px;\n display: inline-block;\n overflow-y: auto;\n min-height: 300px;\n max-height: 300px;\n }\n "]
762
- }]
763
- }], ctorParameters: function () { return [{ type: AuthenticationService }]; } });
764
-
765
- var AuthorizationInterceptor = /** @class */ (function () {
766
- function AuthorizationInterceptor(injector) {
767
- this.injector = injector;
768
- }
769
- AuthorizationInterceptor.prototype.intercept = function (req, next) {
770
- if (isDevMode()) {
771
- console.debug("AuthorizationInterceptor.intercept");
772
- }
773
- var authService = this.injector.get(AuthenticationService);
774
- //Don't want to include background token refreshes in considering the user 'active'
775
- if (req.url !== authService.tokenLocation()) {
776
- //Update user activity. Done here instead of the previous method using a subscription to a subject in AuthenticationProvider
777
- authService.updateUserActivity();
778
- }
779
- var headers = authService.getHeaders(req);
780
- var url = req.url;
781
- if (url.startsWith("/")) {
782
- url = authService.getBaseUrl() + url;
783
- }
784
- else if (!url.startsWith("http")) {
785
- if (authService.getContextRoot().length > 0) {
786
- url = authService.getBaseUrl() + "/" + authService.getContextRoot() + "/" + url;
787
- }
788
- else {
789
- url = authService.getBaseUrl() + "/" + url;
790
- }
791
- }
792
- var params = req.params;
793
- if (url.indexOf("/crud/") > 0) {
794
- params = params.set("maxViewPermission", authService.getMaxViewPermission());
795
- }
796
- var reqClone = req.clone({
797
- url: url,
798
- withCredentials: true,
799
- headers: headers,
800
- params: params
801
- });
802
- return next.handle(reqClone)
803
- .pipe(catchError(function (error) {
804
- if (isDevMode()) {
805
- console.error("AuthorizationInterceptor.error");
806
- console.error(error);
807
- }
808
- /**
809
- * If the token is not authenticated which angular does not know about, then a REST request to the backend will
810
- * return a 401. To duplicate this, open Core in two tabs. In one tab, logout, in the other, perform a request
811
- * that hits a protected resource.
812
- */
813
- if (error.status === 401) {
814
- authService.isAuthenticated().subscribe(function (authenticated) {
815
- if (authenticated) {
816
- // If authenticated, then logout which will redirect.
817
- authService.logout(true);
818
- return throwError(error.message);
819
- }
820
- else {
821
- // Otherwise, for example, when the user first opens Core, 401s are expected.
822
- return throwError(error);
823
- }
824
- });
825
- }
826
- if (error.status === 403) {
827
- // TODO: Trigger notification for unauthorized.
828
- }
829
- return throwError(error);
830
- }));
831
- };
832
- AuthorizationInterceptor.ɵfac = ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthorizationInterceptor, deps: [{ token: Injector }], target: ɵɵFactoryTarget.Injectable });
833
- AuthorizationInterceptor.ɵprov = ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthorizationInterceptor });
834
- return AuthorizationInterceptor;
835
- }());
836
- ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthorizationInterceptor, decorators: [{
837
- type: Injectable
838
- }], ctorParameters: function () { return [{ type: Injector }]; } });
839
-
840
- /*
841
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
842
- */
843
- /**
844
- * Provide a single auth service and interceptor for the implementing application. Also provide everything
845
- * from the angular-jwt library.
846
- *
847
- * @since 1.0.0
848
- */
849
- var AuthenticationModule = /** @class */ (function () {
850
- function AuthenticationModule(parentModule) {
851
- if (parentModule) {
852
- throw new Error("AuthenticationModule is already loaded.");
853
- }
854
- }
855
- AuthenticationModule.forRoot = function () {
856
- return {
857
- providers: [
858
- AuthenticationProvider,
859
- JwtHelperService,
860
- AuthenticationService,
861
- RouteGuardService,
862
- {
863
- provide: HTTP_INTERCEPTORS,
864
- useClass: AuthorizationInterceptor,
865
- multi: true
866
- },
867
- {
868
- provide: HTTP_INTERCEPTORS,
869
- useClass: JwtInterceptor,
870
- multi: true
871
- },
872
- {
873
- provide: JWT_OPTIONS,
874
- useClass: AuthenticationProvider
875
- }
876
- ],
877
- ngModule: AuthenticationModule
878
- };
879
- };
880
- AuthenticationModule.ɵfac = ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationModule, deps: [{ token: JwtModule, optional: true, skipSelf: true }], target: ɵɵFactoryTarget.NgModule });
881
- AuthenticationModule.ɵmod = ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationModule, declarations: [AuthenticationComponent,
882
- DirectLoginComponent,
883
- TimeoutNotificationComponent], imports: [CommonModule,
884
- HttpClientModule,
885
- //JwtModule,
886
- RouterModule,
887
- FormsModule,
888
- ReactiveFormsModule,
889
- CoolStorageModule], exports: [AuthenticationComponent,
890
- DirectLoginComponent,
891
- TimeoutNotificationComponent] });
892
- AuthenticationModule.ɵinj = ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationModule, imports: [[
893
- CommonModule,
894
- HttpClientModule,
895
- //JwtModule,
896
- RouterModule,
897
- FormsModule,
898
- ReactiveFormsModule,
899
- CoolStorageModule
900
- ]] });
901
- return AuthenticationModule;
902
- }());
903
- ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: AuthenticationModule, decorators: [{
904
- type: NgModule,
905
- args: [{
906
- imports: [
907
- CommonModule,
908
- HttpClientModule,
909
- //JwtModule,
910
- RouterModule,
911
- FormsModule,
912
- ReactiveFormsModule,
913
- CoolStorageModule
914
- ],
915
- declarations: [
916
- AuthenticationComponent,
917
- DirectLoginComponent,
918
- TimeoutNotificationComponent
919
- ],
920
- exports: [
921
- AuthenticationComponent,
922
- DirectLoginComponent,
923
- TimeoutNotificationComponent
924
- ]
925
- }]
926
- }], ctorParameters: function () { return [{ type: JwtModule, decorators: [{
927
- type: Optional
928
- }, {
929
- type: SkipSelf
930
- }] }]; } });
931
-
932
- /**
933
- * Generated bundle index. Do not edit.
934
- */
935
-
936
- export { AUTHENTICATION_DIRECT_ENDPOINT, AUTHENTICATION_IDP_INACTIVITY_MINUTES, AUTHENTICATION_LOGOUT_PATH, AUTHENTICATION_MAX_INACTIVITY_MINUTES, AUTHENTICATION_ROUTE, AUTHENTICATION_SERVER_URL, AUTHENTICATION_TOKEN_ENDPOINT, AUTHENTICATION_TOKEN_KEY, AUTHENTICATION_USER_COUNTDOWN_SECONDS, AuthenticationComponent, AuthenticationModule, AuthenticationService, AuthorizationInterceptor, DirectLoginComponent, RouteGuardService, TimeoutNotificationComponent };
937
- //# sourceMappingURL=huntsman-cancer-institute-authentication.js.map