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