@valtimo/keycloak 10.4.0 → 10.5.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.
- package/esm2020/lib/callback.component.mjs +22 -16
- package/esm2020/lib/constants/index.mjs +17 -0
- package/esm2020/lib/constants/storage-keys.mjs +23 -0
- package/esm2020/lib/keycloak-routing.module.mjs +2 -2
- package/esm2020/lib/keycloak.init.mjs +8 -9
- package/esm2020/lib/keycloak.module.mjs +2 -2
- package/esm2020/lib/models/index.mjs +2 -2
- package/esm2020/lib/models/keycloak.config.mjs +2 -2
- package/esm2020/lib/services/index.mjs +20 -0
- package/esm2020/lib/services/keycloak-auth-guard.service.mjs +61 -0
- package/esm2020/lib/services/keycloak-options.service.mjs +24 -0
- package/esm2020/lib/services/keycloak-storage.service.mjs +43 -0
- package/esm2020/lib/services/keycloak-user.service.mjs +180 -0
- package/esm2020/public_api.mjs +6 -5
- package/fesm2015/valtimo-keycloak.mjs +262 -148
- package/fesm2015/valtimo-keycloak.mjs.map +1 -1
- package/fesm2020/valtimo-keycloak.mjs +264 -151
- package/fesm2020/valtimo-keycloak.mjs.map +1 -1
- package/lib/callback.component.d.ts +3 -2
- package/lib/callback.component.d.ts.map +1 -1
- package/lib/constants/index.d.ts +2 -0
- package/lib/constants/index.d.ts.map +1 -0
- package/lib/constants/storage-keys.d.ts +8 -0
- package/lib/constants/storage-keys.d.ts.map +1 -0
- package/lib/keycloak.init.d.ts.map +1 -1
- package/lib/services/index.d.ts +5 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/keycloak-auth-guard.service.d.ts.map +1 -0
- package/lib/services/keycloak-options.service.d.ts.map +1 -0
- package/lib/services/keycloak-storage.service.d.ts +11 -0
- package/lib/services/keycloak-storage.service.d.ts.map +1 -0
- package/lib/{keycloak-user.service.d.ts → services/keycloak-user.service.d.ts} +9 -2
- package/lib/services/keycloak-user.service.d.ts.map +1 -0
- package/package.json +1 -1
- package/public_api.d.ts +4 -3
- package/public_api.d.ts.map +1 -1
- package/esm2020/lib/keycloak-auth-guard.service.mjs +0 -61
- package/esm2020/lib/keycloak-options.service.mjs +0 -24
- package/esm2020/lib/keycloak-user.service.mjs +0 -162
- package/lib/keycloak-auth-guard.service.d.ts.map +0 -1
- package/lib/keycloak-options.service.d.ts.map +0 -1
- package/lib/keycloak-user.service.d.ts.map +0 -1
- /package/lib/{keycloak-auth-guard.service.d.ts → services/keycloak-auth-guard.service.d.ts} +0 -0
- /package/lib/{keycloak-options.service.d.ts → services/keycloak-options.service.d.ts} +0 -0
|
@@ -1,62 +1,25 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, Component, NgModule } from '@angular/core';
|
|
3
3
|
import * as i2 from 'keycloak-angular';
|
|
4
|
-
import {
|
|
5
|
-
import * as i1
|
|
4
|
+
import { KeycloakAuthGuard, KeycloakEventType, KeycloakAngularModule, KeycloakService } from 'keycloak-angular';
|
|
5
|
+
import * as i1 from '@angular/router';
|
|
6
6
|
import { RouterModule } from '@angular/router';
|
|
7
|
-
import * as i1 from '@valtimo/config';
|
|
8
|
-
import { ValtimoUserIdentity } from '@valtimo/config';
|
|
9
7
|
import * as i3 from 'ngx-logger';
|
|
10
8
|
import { NGXLogger } from 'ngx-logger';
|
|
11
|
-
import * as
|
|
12
|
-
import {
|
|
13
|
-
import * as i5 from '@ngx-translate/core';
|
|
14
|
-
import { TranslateModule } from '@ngx-translate/core';
|
|
9
|
+
import * as i1$1 from '@valtimo/config';
|
|
10
|
+
import { ValtimoUserIdentity } from '@valtimo/config';
|
|
15
11
|
import { __awaiter } from 'tslib';
|
|
16
12
|
import { Subject, ReplaySubject, timer, map, switchMap, combineLatest } from 'rxjs';
|
|
17
13
|
import jwt_decode from 'jwt-decode';
|
|
18
14
|
import { take } from 'rxjs/operators';
|
|
19
15
|
import * as i4 from '@valtimo/user-interface';
|
|
16
|
+
import * as i5 from '@ngx-translate/core';
|
|
17
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
18
|
+
import * as i6 from '@angular/common';
|
|
19
|
+
import { CommonModule, DatePipe } from '@angular/common';
|
|
20
20
|
|
|
21
21
|
/*
|
|
22
|
-
* Copyright 2015-
|
|
23
|
-
*
|
|
24
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
25
|
-
* you may not use this file except in compliance with the License.
|
|
26
|
-
* You may obtain a copy of the License at
|
|
27
|
-
*
|
|
28
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
29
|
-
*
|
|
30
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
31
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
32
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
33
|
-
* See the License for the specific language governing permissions and
|
|
34
|
-
* limitations under the License.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
class KeycloakOptionsService {
|
|
38
|
-
constructor(configService) {
|
|
39
|
-
this.configService = configService;
|
|
40
|
-
this.valtimoKeycloakOptions = configService.config.authentication.options;
|
|
41
|
-
}
|
|
42
|
-
get keycloakOptions() {
|
|
43
|
-
return this.valtimoKeycloakOptions.keycloakOptions;
|
|
44
|
-
}
|
|
45
|
-
get logoutRedirectUri() {
|
|
46
|
-
return this.valtimoKeycloakOptions.logoutRedirectUri;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
KeycloakOptionsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakOptionsService, deps: [{ token: i1.ConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
50
|
-
KeycloakOptionsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakOptionsService, providedIn: 'root' });
|
|
51
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakOptionsService, decorators: [{
|
|
52
|
-
type: Injectable,
|
|
53
|
-
args: [{
|
|
54
|
-
providedIn: 'root',
|
|
55
|
-
}]
|
|
56
|
-
}], ctorParameters: function () { return [{ type: i1.ConfigService }]; } });
|
|
57
|
-
|
|
58
|
-
/*
|
|
59
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
22
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
60
23
|
*
|
|
61
24
|
* Licensed under EUPL, Version 1.2 (the "License");
|
|
62
25
|
* you may not use this file except in compliance with the License.
|
|
@@ -70,45 +33,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
70
33
|
* See the License for the specific language governing permissions and
|
|
71
34
|
* limitations under the License.
|
|
72
35
|
*/
|
|
73
|
-
class CallbackComponent {
|
|
74
|
-
constructor(router, keycloakOptionsService, logger) {
|
|
75
|
-
this.router = router;
|
|
76
|
-
this.keycloakOptionsService = keycloakOptionsService;
|
|
77
|
-
this.logger = logger;
|
|
78
|
-
logger.debug('callback');
|
|
79
|
-
const savedRedirectTo = window.sessionStorage.getItem('redirectTo');
|
|
80
|
-
const savedRedirectToParams = window.sessionStorage.getItem('redirectToParams');
|
|
81
|
-
const parsedSavedRedirectToParams = typeof savedRedirectToParams === 'string' &&
|
|
82
|
-
savedRedirectToParams.length > 2 &&
|
|
83
|
-
JSON.parse(savedRedirectToParams);
|
|
84
|
-
let redirectTo;
|
|
85
|
-
let redirectToParams;
|
|
86
|
-
if (savedRedirectTo) {
|
|
87
|
-
redirectTo = savedRedirectTo;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
redirectTo = '/';
|
|
91
|
-
}
|
|
92
|
-
if (savedRedirectToParams && parsedSavedRedirectToParams) {
|
|
93
|
-
redirectToParams = parsedSavedRedirectToParams;
|
|
94
|
-
}
|
|
95
|
-
logger.debug('keycloak callback redirect =', redirectTo);
|
|
96
|
-
logger.debug('keycloak callback redirect params =', savedRedirectToParams);
|
|
97
|
-
this.router.navigate([redirectTo], { queryParams: redirectToParams || {} });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
CallbackComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: CallbackComponent, deps: [{ token: i1$1.Router }, { token: KeycloakOptionsService }, { token: i3.NGXLogger }], target: i0.ɵɵFactoryTarget.Component });
|
|
101
|
-
CallbackComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: CallbackComponent, selector: "valtimo-keycloak-callback", ngImport: i0, template: '', isInline: true });
|
|
102
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: CallbackComponent, decorators: [{
|
|
103
|
-
type: Component,
|
|
104
|
-
args: [{
|
|
105
|
-
selector: 'valtimo-keycloak-callback',
|
|
106
|
-
template: '',
|
|
107
|
-
}]
|
|
108
|
-
}], ctorParameters: function () { return [{ type: i1$1.Router }, { type: KeycloakOptionsService }, { type: i3.NGXLogger }]; } });
|
|
109
36
|
|
|
110
37
|
/*
|
|
111
|
-
* Copyright 2015-
|
|
38
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
112
39
|
*
|
|
113
40
|
* Licensed under EUPL, Version 1.2 (the "License");
|
|
114
41
|
* you may not use this file except in compliance with the License.
|
|
@@ -122,28 +49,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
122
49
|
* See the License for the specific language governing permissions and
|
|
123
50
|
* limitations under the License.
|
|
124
51
|
*/
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
];
|
|
132
|
-
class KeycloakRoutingModule {
|
|
133
|
-
}
|
|
134
|
-
KeycloakRoutingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
135
|
-
KeycloakRoutingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: KeycloakRoutingModule, imports: [CommonModule, i1$1.RouterModule], exports: [RouterModule] });
|
|
136
|
-
KeycloakRoutingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakRoutingModule, imports: [CommonModule, RouterModule.forChild(routes), RouterModule] });
|
|
137
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakRoutingModule, decorators: [{
|
|
138
|
-
type: NgModule,
|
|
139
|
-
args: [{
|
|
140
|
-
imports: [CommonModule, RouterModule.forChild(routes)],
|
|
141
|
-
exports: [RouterModule],
|
|
142
|
-
}]
|
|
143
|
-
}] });
|
|
52
|
+
const STORAGE_KEYS = {
|
|
53
|
+
urlBeforeExpiration: 'urlBeforeExpiration',
|
|
54
|
+
urlBeforeExpirationParams: 'urlBeforeExpirationParams',
|
|
55
|
+
redirectTo: 'redirectTo',
|
|
56
|
+
redirectToParams: 'redirectToParams',
|
|
57
|
+
};
|
|
144
58
|
|
|
145
59
|
/*
|
|
146
|
-
* Copyright 2015-
|
|
60
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
147
61
|
*
|
|
148
62
|
* Licensed under EUPL, Version 1.2 (the "License");
|
|
149
63
|
* you may not use this file except in compliance with the License.
|
|
@@ -157,23 +71,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
157
71
|
* See the License for the specific language governing permissions and
|
|
158
72
|
* limitations under the License.
|
|
159
73
|
*/
|
|
160
|
-
class KeycloakModule {
|
|
161
|
-
}
|
|
162
|
-
KeycloakModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
163
|
-
KeycloakModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: KeycloakModule, declarations: [CallbackComponent], imports: [KeycloakRoutingModule, KeycloakAngularModule, TranslateModule], exports: [CallbackComponent] });
|
|
164
|
-
KeycloakModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakModule, providers: [DatePipe], imports: [KeycloakRoutingModule, KeycloakAngularModule, TranslateModule] });
|
|
165
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakModule, decorators: [{
|
|
166
|
-
type: NgModule,
|
|
167
|
-
args: [{
|
|
168
|
-
declarations: [CallbackComponent],
|
|
169
|
-
imports: [KeycloakRoutingModule, KeycloakAngularModule, TranslateModule],
|
|
170
|
-
exports: [CallbackComponent],
|
|
171
|
-
providers: [DatePipe],
|
|
172
|
-
}]
|
|
173
|
-
}] });
|
|
174
74
|
|
|
175
75
|
/*
|
|
176
|
-
* Copyright 2015-
|
|
76
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
177
77
|
*
|
|
178
78
|
* Licensed under EUPL, Version 1.2 (the "License");
|
|
179
79
|
* you may not use this file except in compliance with the License.
|
|
@@ -218,23 +118,88 @@ class KeycloakAuthGuardService extends KeycloakAuthGuard {
|
|
|
218
118
|
});
|
|
219
119
|
}
|
|
220
120
|
}
|
|
221
|
-
KeycloakAuthGuardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakAuthGuardService, deps: [{ token: i1
|
|
121
|
+
KeycloakAuthGuardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakAuthGuardService, deps: [{ token: i1.Router }, { token: i2.KeycloakService }, { token: i3.NGXLogger }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
222
122
|
KeycloakAuthGuardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakAuthGuardService, providedIn: 'root' });
|
|
223
123
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakAuthGuardService, decorators: [{
|
|
224
124
|
type: Injectable,
|
|
225
125
|
args: [{
|
|
226
126
|
providedIn: 'root',
|
|
227
127
|
}]
|
|
228
|
-
}], ctorParameters: function () { return [{ type: i1
|
|
128
|
+
}], ctorParameters: function () { return [{ type: i1.Router }, { type: i2.KeycloakService }, { type: i3.NGXLogger }]; } });
|
|
129
|
+
|
|
130
|
+
class KeycloakOptionsService {
|
|
131
|
+
constructor(configService) {
|
|
132
|
+
this.configService = configService;
|
|
133
|
+
this.valtimoKeycloakOptions = configService.config.authentication.options;
|
|
134
|
+
}
|
|
135
|
+
get keycloakOptions() {
|
|
136
|
+
return this.valtimoKeycloakOptions.keycloakOptions;
|
|
137
|
+
}
|
|
138
|
+
get logoutRedirectUri() {
|
|
139
|
+
return this.valtimoKeycloakOptions.logoutRedirectUri;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
KeycloakOptionsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakOptionsService, deps: [{ token: i1$1.ConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
143
|
+
KeycloakOptionsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakOptionsService, providedIn: 'root' });
|
|
144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakOptionsService, decorators: [{
|
|
145
|
+
type: Injectable,
|
|
146
|
+
args: [{
|
|
147
|
+
providedIn: 'root',
|
|
148
|
+
}]
|
|
149
|
+
}], ctorParameters: function () { return [{ type: i1$1.ConfigService }]; } });
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
153
|
+
*
|
|
154
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
155
|
+
* you may not use this file except in compliance with the License.
|
|
156
|
+
* You may obtain a copy of the License at
|
|
157
|
+
*
|
|
158
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
159
|
+
*
|
|
160
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
161
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
162
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
163
|
+
* See the License for the specific language governing permissions and
|
|
164
|
+
* limitations under the License.
|
|
165
|
+
*/
|
|
166
|
+
class KeycloakStorageService {
|
|
167
|
+
getCurrentUrlParams() {
|
|
168
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
169
|
+
const params = Object.fromEntries(urlSearchParams.entries());
|
|
170
|
+
return JSON.stringify(params);
|
|
171
|
+
}
|
|
172
|
+
getCurrentUrl() {
|
|
173
|
+
return window.location.pathname;
|
|
174
|
+
}
|
|
175
|
+
parseSavedParams(savedParams) {
|
|
176
|
+
return ((savedParams &&
|
|
177
|
+
typeof savedParams === 'string' &&
|
|
178
|
+
savedParams.length > 2 &&
|
|
179
|
+
JSON.parse(savedParams)) ||
|
|
180
|
+
{});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
KeycloakStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
184
|
+
KeycloakStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakStorageService, providedIn: 'root' });
|
|
185
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakStorageService, decorators: [{
|
|
186
|
+
type: Injectable,
|
|
187
|
+
args: [{
|
|
188
|
+
providedIn: 'root',
|
|
189
|
+
}]
|
|
190
|
+
}] });
|
|
229
191
|
|
|
230
192
|
class KeycloakUserService {
|
|
231
|
-
constructor(keycloakService, keycloakOptionsService, logger, promptService, translateService, datePipe) {
|
|
193
|
+
constructor(keycloakService, keycloakOptionsService, logger, promptService, translateService, datePipe, configService, router, keycloakStorageService) {
|
|
232
194
|
this.keycloakService = keycloakService;
|
|
233
195
|
this.keycloakOptionsService = keycloakOptionsService;
|
|
234
196
|
this.logger = logger;
|
|
235
197
|
this.promptService = promptService;
|
|
236
198
|
this.translateService = translateService;
|
|
237
199
|
this.datePipe = datePipe;
|
|
200
|
+
this.configService = configService;
|
|
201
|
+
this.router = router;
|
|
202
|
+
this.keycloakStorageService = keycloakStorageService;
|
|
238
203
|
this._refreshToken$ = new Subject();
|
|
239
204
|
this.FIVE_MINUTES_MS = 300000;
|
|
240
205
|
this.EXPIRE_TOKEN_CONFIRMATION = 'EXPIRE_TOKEN_CONFIRMATION';
|
|
@@ -326,30 +291,14 @@ class KeycloakUserService {
|
|
|
326
291
|
this.promptService.identifier$.pipe(take(1)).subscribe(identifier => {
|
|
327
292
|
if ((!promptVisible || identifier !== this.EXPIRE_TOKEN_CONFIRMATION) &&
|
|
328
293
|
this._expiryTimeMs <= this.FIVE_MINUTES_MS) {
|
|
329
|
-
this.
|
|
330
|
-
identifier: this.EXPIRE_TOKEN_CONFIRMATION,
|
|
331
|
-
headerText,
|
|
332
|
-
bodyText,
|
|
333
|
-
cancelButtonText,
|
|
334
|
-
confirmButtonText,
|
|
335
|
-
cancelMdiIcon: 'logout',
|
|
336
|
-
confirmMdiIcon: 'check',
|
|
337
|
-
closeOnConfirm: true,
|
|
338
|
-
closeOnCancel: false,
|
|
339
|
-
cancelCallbackFunction: () => {
|
|
340
|
-
this.keycloakService.logout();
|
|
341
|
-
},
|
|
342
|
-
confirmCallBackFunction: () => {
|
|
343
|
-
this.closeExpiryTimerSubscription();
|
|
344
|
-
this.updateToken(20);
|
|
345
|
-
},
|
|
346
|
-
});
|
|
294
|
+
this.openConfirmationPrompt(headerText, bodyText, cancelButtonText, confirmButtonText);
|
|
347
295
|
}
|
|
348
296
|
if (promptVisible && identifier === this.EXPIRE_TOKEN_CONFIRMATION) {
|
|
349
297
|
this.promptService.setBodyText(bodyText);
|
|
350
298
|
}
|
|
351
299
|
});
|
|
352
300
|
if (this._expiryTimeMs < 2000) {
|
|
301
|
+
this.saveUrl();
|
|
353
302
|
this.logout();
|
|
354
303
|
}
|
|
355
304
|
});
|
|
@@ -358,20 +307,187 @@ class KeycloakUserService {
|
|
|
358
307
|
var _a;
|
|
359
308
|
(_a = this.expiryTimerSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
360
309
|
}
|
|
310
|
+
openConfirmationPrompt(headerText, bodyText, cancelButtonText, confirmButtonText) {
|
|
311
|
+
this.promptService.openPrompt({
|
|
312
|
+
identifier: this.EXPIRE_TOKEN_CONFIRMATION,
|
|
313
|
+
headerText,
|
|
314
|
+
bodyText,
|
|
315
|
+
cancelButtonText,
|
|
316
|
+
confirmButtonText,
|
|
317
|
+
cancelMdiIcon: 'logout',
|
|
318
|
+
confirmMdiIcon: 'check',
|
|
319
|
+
closeOnConfirm: true,
|
|
320
|
+
closeOnCancel: false,
|
|
321
|
+
cancelCallbackFunction: () => {
|
|
322
|
+
this.keycloakService.logout();
|
|
323
|
+
},
|
|
324
|
+
confirmCallBackFunction: () => {
|
|
325
|
+
this.closeExpiryTimerSubscription();
|
|
326
|
+
this.updateToken(20);
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
saveUrl() {
|
|
331
|
+
var _a, _b, _c;
|
|
332
|
+
const returnToLastUrlAfterTokenExpiration = (_c = (_b = (_a = this.configService) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.featureToggles) === null || _c === void 0 ? void 0 : _c.returnToLastUrlAfterTokenExpiration;
|
|
333
|
+
if (returnToLastUrlAfterTokenExpiration) {
|
|
334
|
+
sessionStorage.setItem(STORAGE_KEYS.urlBeforeExpiration, this.keycloakStorageService.getCurrentUrl());
|
|
335
|
+
sessionStorage.setItem(STORAGE_KEYS.urlBeforeExpirationParams, this.keycloakStorageService.getCurrentUrlParams());
|
|
336
|
+
}
|
|
337
|
+
}
|
|
361
338
|
}
|
|
362
|
-
KeycloakUserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakUserService, deps: [{ token: i2.KeycloakService }, { token: KeycloakOptionsService }, { token: i3.NGXLogger }, { token: i4.PromptService }, { token: i5.TranslateService }, { token: i6.DatePipe }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
339
|
+
KeycloakUserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakUserService, deps: [{ token: i2.KeycloakService }, { token: KeycloakOptionsService }, { token: i3.NGXLogger }, { token: i4.PromptService }, { token: i5.TranslateService }, { token: i6.DatePipe }, { token: i1$1.ConfigService }, { token: i1.Router }, { token: KeycloakStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
363
340
|
KeycloakUserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakUserService, providedIn: 'root' });
|
|
364
341
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakUserService, decorators: [{
|
|
365
342
|
type: Injectable,
|
|
366
343
|
args: [{
|
|
367
344
|
providedIn: 'root',
|
|
368
345
|
}]
|
|
369
|
-
}], ctorParameters: function () { return [{ type: i2.KeycloakService }, { type: KeycloakOptionsService }, { type: i3.NGXLogger }, { type: i4.PromptService }, { type: i5.TranslateService }, { type: i6.DatePipe }]; } });
|
|
346
|
+
}], ctorParameters: function () { return [{ type: i2.KeycloakService }, { type: KeycloakOptionsService }, { type: i3.NGXLogger }, { type: i4.PromptService }, { type: i5.TranslateService }, { type: i6.DatePipe }, { type: i1$1.ConfigService }, { type: i1.Router }, { type: KeycloakStorageService }]; } });
|
|
347
|
+
|
|
348
|
+
/*
|
|
349
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
350
|
+
*
|
|
351
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
352
|
+
* you may not use this file except in compliance with the License.
|
|
353
|
+
* You may obtain a copy of the License at
|
|
354
|
+
*
|
|
355
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
356
|
+
*
|
|
357
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
358
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
359
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
360
|
+
* See the License for the specific language governing permissions and
|
|
361
|
+
* limitations under the License.
|
|
362
|
+
*/
|
|
363
|
+
|
|
364
|
+
/*
|
|
365
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
366
|
+
*
|
|
367
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
368
|
+
* you may not use this file except in compliance with the License.
|
|
369
|
+
* You may obtain a copy of the License at
|
|
370
|
+
*
|
|
371
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
372
|
+
*
|
|
373
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
374
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
375
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
376
|
+
* See the License for the specific language governing permissions and
|
|
377
|
+
* limitations under the License.
|
|
378
|
+
*/
|
|
379
|
+
class CallbackComponent {
|
|
380
|
+
constructor(router, keycloakOptionsService, logger, keycloakStorageService) {
|
|
381
|
+
this.router = router;
|
|
382
|
+
this.keycloakOptionsService = keycloakOptionsService;
|
|
383
|
+
this.logger = logger;
|
|
384
|
+
this.keycloakStorageService = keycloakStorageService;
|
|
385
|
+
logger.debug('callback');
|
|
386
|
+
const savedRedirectTo = window.sessionStorage.getItem(STORAGE_KEYS.redirectTo);
|
|
387
|
+
const savedRedirectToParams = window.sessionStorage.getItem(STORAGE_KEYS.redirectToParams);
|
|
388
|
+
const parsedSavedRedirectToParams = this.keycloakStorageService.parseSavedParams(savedRedirectToParams);
|
|
389
|
+
const urlBeforeExpiration = sessionStorage.getItem(STORAGE_KEYS.urlBeforeExpiration);
|
|
390
|
+
const paramsBeforeExpiration = sessionStorage.getItem(STORAGE_KEYS.urlBeforeExpirationParams);
|
|
391
|
+
const parsedParamsBeforeExpiration = this.keycloakStorageService.parseSavedParams(paramsBeforeExpiration);
|
|
392
|
+
let redirectTo;
|
|
393
|
+
if (savedRedirectTo) {
|
|
394
|
+
redirectTo = savedRedirectTo;
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
redirectTo = '/';
|
|
398
|
+
}
|
|
399
|
+
logger.debug('keycloak callback redirect =', redirectTo);
|
|
400
|
+
logger.debug('keycloak callback redirect params =', savedRedirectToParams);
|
|
401
|
+
if (STORAGE_KEYS.urlBeforeExpiration in sessionStorage) {
|
|
402
|
+
this.router.navigate([urlBeforeExpiration], { queryParams: parsedParamsBeforeExpiration });
|
|
403
|
+
sessionStorage.removeItem(STORAGE_KEYS.urlBeforeExpiration);
|
|
404
|
+
sessionStorage.removeItem(STORAGE_KEYS.urlBeforeExpirationParams);
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
this.router.navigate([redirectTo], { queryParams: parsedSavedRedirectToParams });
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
CallbackComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: CallbackComponent, deps: [{ token: i1.Router }, { token: KeycloakOptionsService }, { token: i3.NGXLogger }, { token: KeycloakStorageService }], target: i0.ɵɵFactoryTarget.Component });
|
|
412
|
+
CallbackComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: CallbackComponent, selector: "valtimo-keycloak-callback", ngImport: i0, template: '', isInline: true });
|
|
413
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: CallbackComponent, decorators: [{
|
|
414
|
+
type: Component,
|
|
415
|
+
args: [{
|
|
416
|
+
selector: 'valtimo-keycloak-callback',
|
|
417
|
+
template: '',
|
|
418
|
+
}]
|
|
419
|
+
}], ctorParameters: function () { return [{ type: i1.Router }, { type: KeycloakOptionsService }, { type: i3.NGXLogger }, { type: KeycloakStorageService }]; } });
|
|
420
|
+
|
|
421
|
+
/*
|
|
422
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
423
|
+
*
|
|
424
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
425
|
+
* you may not use this file except in compliance with the License.
|
|
426
|
+
* You may obtain a copy of the License at
|
|
427
|
+
*
|
|
428
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
429
|
+
*
|
|
430
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
431
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
432
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
433
|
+
* See the License for the specific language governing permissions and
|
|
434
|
+
* limitations under the License.
|
|
435
|
+
*/
|
|
436
|
+
const routes = [
|
|
437
|
+
{
|
|
438
|
+
path: 'keycloak/callback',
|
|
439
|
+
component: CallbackComponent,
|
|
440
|
+
data: { title: 'Loading...' },
|
|
441
|
+
},
|
|
442
|
+
];
|
|
443
|
+
class KeycloakRoutingModule {
|
|
444
|
+
}
|
|
445
|
+
KeycloakRoutingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
446
|
+
KeycloakRoutingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: KeycloakRoutingModule, imports: [CommonModule, i1.RouterModule], exports: [RouterModule] });
|
|
447
|
+
KeycloakRoutingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakRoutingModule, imports: [CommonModule, RouterModule.forChild(routes), RouterModule] });
|
|
448
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakRoutingModule, decorators: [{
|
|
449
|
+
type: NgModule,
|
|
450
|
+
args: [{
|
|
451
|
+
imports: [CommonModule, RouterModule.forChild(routes)],
|
|
452
|
+
exports: [RouterModule],
|
|
453
|
+
}]
|
|
454
|
+
}] });
|
|
455
|
+
|
|
456
|
+
/*
|
|
457
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
458
|
+
*
|
|
459
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
460
|
+
* you may not use this file except in compliance with the License.
|
|
461
|
+
* You may obtain a copy of the License at
|
|
462
|
+
*
|
|
463
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
464
|
+
*
|
|
465
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
466
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
467
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
468
|
+
* See the License for the specific language governing permissions and
|
|
469
|
+
* limitations under the License.
|
|
470
|
+
*/
|
|
471
|
+
class KeycloakModule {
|
|
472
|
+
}
|
|
473
|
+
KeycloakModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
474
|
+
KeycloakModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: KeycloakModule, declarations: [CallbackComponent], imports: [KeycloakRoutingModule, KeycloakAngularModule, TranslateModule], exports: [CallbackComponent] });
|
|
475
|
+
KeycloakModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakModule, providers: [DatePipe], imports: [KeycloakRoutingModule, KeycloakAngularModule, TranslateModule] });
|
|
476
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: KeycloakModule, decorators: [{
|
|
477
|
+
type: NgModule,
|
|
478
|
+
args: [{
|
|
479
|
+
declarations: [CallbackComponent],
|
|
480
|
+
imports: [KeycloakRoutingModule, KeycloakAngularModule, TranslateModule],
|
|
481
|
+
exports: [CallbackComponent],
|
|
482
|
+
providers: [DatePipe],
|
|
483
|
+
}]
|
|
484
|
+
}] });
|
|
370
485
|
|
|
371
486
|
function keycloakInitializer(injector) {
|
|
372
487
|
const keycloakService = injector.get(KeycloakService);
|
|
373
488
|
const keycloakUserService = injector.get(KeycloakUserService);
|
|
374
489
|
const optionsService = injector.get(KeycloakOptionsService); // TODO possible removal of abstraction
|
|
490
|
+
const storageService = injector.get(KeycloakStorageService);
|
|
375
491
|
const logger = injector.get(NGXLogger);
|
|
376
492
|
return () => __awaiter(this, void 0, void 0, function* () {
|
|
377
493
|
try {
|
|
@@ -379,12 +495,10 @@ function keycloakInitializer(injector) {
|
|
|
379
495
|
const keycloakOptions = optionsService.keycloakOptions;
|
|
380
496
|
const currentUrl = window.location.href.split('#')[0];
|
|
381
497
|
if (keycloakOptions.initOptions.redirectUri !== currentUrl) {
|
|
382
|
-
const redirectTo =
|
|
383
|
-
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
384
|
-
const params = Object.fromEntries(urlSearchParams.entries());
|
|
498
|
+
const redirectTo = storageService.getCurrentUrl();
|
|
385
499
|
logger.debug('Setting redirectTo =', redirectTo);
|
|
386
|
-
window.sessionStorage.setItem(
|
|
387
|
-
window.sessionStorage.setItem(
|
|
500
|
+
window.sessionStorage.setItem(STORAGE_KEYS.redirectTo, redirectTo);
|
|
501
|
+
window.sessionStorage.setItem(STORAGE_KEYS.redirectToParams, storageService.getCurrentUrlParams());
|
|
388
502
|
}
|
|
389
503
|
const initResult = yield keycloakService.init(keycloakOptions);
|
|
390
504
|
logger.debug('Keycloak initializer after init');
|
|
@@ -399,7 +513,7 @@ function keycloakInitializer(injector) {
|
|
|
399
513
|
}
|
|
400
514
|
|
|
401
515
|
/*
|
|
402
|
-
* Copyright 2015-
|
|
516
|
+
* Copyright 2015-2023 Ritense BV, the Netherlands.
|
|
403
517
|
*
|
|
404
518
|
* Licensed under EUPL, Version 1.2 (the "License");
|
|
405
519
|
* you may not use this file except in compliance with the License.
|
|
@@ -418,5 +532,5 @@ function keycloakInitializer(injector) {
|
|
|
418
532
|
* Generated bundle index. Do not edit.
|
|
419
533
|
*/
|
|
420
534
|
|
|
421
|
-
export { CallbackComponent, KeycloakAuthGuardService, KeycloakModule, KeycloakOptionsService, KeycloakUserService, keycloakInitializer };
|
|
535
|
+
export { CallbackComponent, KeycloakAuthGuardService, KeycloakModule, KeycloakOptionsService, KeycloakUserService, STORAGE_KEYS, keycloakInitializer };
|
|
422
536
|
//# sourceMappingURL=valtimo-keycloak.mjs.map
|