@valtimo/keycloak 4.15.2-next-main.8
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/bundles/valtimo-keycloak.umd.js +619 -0
- package/bundles/valtimo-keycloak.umd.js.map +1 -0
- package/bundles/valtimo-keycloak.umd.min.js +17 -0
- package/bundles/valtimo-keycloak.umd.min.js.map +1 -0
- package/esm2015/lib/callback.component.js +49 -0
- package/esm2015/lib/keycloak-auth-guard.service.js +64 -0
- package/esm2015/lib/keycloak-options.service.js +26 -0
- package/esm2015/lib/keycloak-routing.module.js +37 -0
- package/esm2015/lib/keycloak-user.service.js +76 -0
- package/esm2015/lib/keycloak.init.js +47 -0
- package/esm2015/lib/keycloak.module.js +32 -0
- package/esm2015/public_api.js +24 -0
- package/esm2015/valtimo-keycloak.js +7 -0
- package/fesm2015/valtimo-keycloak.js +307 -0
- package/fesm2015/valtimo-keycloak.js.map +1 -0
- package/lib/callback.component.d.ts +9 -0
- package/lib/keycloak-auth-guard.service.d.ts +10 -0
- package/lib/keycloak-options.service.d.ts +8 -0
- package/lib/keycloak-routing.module.d.ts +2 -0
- package/lib/keycloak-user.service.d.ts +17 -0
- package/lib/keycloak.init.d.ts +2 -0
- package/lib/keycloak.module.d.ts +2 -0
- package/package.json +24 -0
- package/public_api.d.ts +5 -0
- package/valtimo-keycloak.d.ts +6 -0
- package/valtimo-keycloak.metadata.json +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/*
|
|
17
|
+
* Public API Surface of keycloak
|
|
18
|
+
*/
|
|
19
|
+
export * from './lib/keycloak.module';
|
|
20
|
+
export * from './lib/keycloak-auth-guard.service';
|
|
21
|
+
export * from './lib/keycloak-user.service';
|
|
22
|
+
export * from './lib/keycloak.init';
|
|
23
|
+
export * from './lib/keycloak-options.service';
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3ZhbHRpbW8va2V5Y2xvYWsvc3JjL3B1YmxpY19hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFFSDs7R0FFRztBQUVILGNBQWMsdUJBQXVCLENBQUM7QUFDdEMsY0FBYyxtQ0FBbUMsQ0FBQztBQUNsRCxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyxnQ0FBZ0MsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBDb3B5cmlnaHQgMjAxNS0yMDIwIFJpdGVuc2UgQlYsIHRoZSBOZXRoZXJsYW5kcy5cbiAqXG4gKiBMaWNlbnNlZCB1bmRlciBFVVBMLCBWZXJzaW9uIDEuMiAodGhlIFwiTGljZW5zZVwiKTtcbiAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS5cbiAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdFxuICpcbiAqIGh0dHBzOi8vam9pbnVwLmVjLmV1cm9wYS5ldS9jb2xsZWN0aW9uL2V1cGwvZXVwbC10ZXh0LWV1cGwtMTJcbiAqXG4gKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlXG4gKiBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiBcIkFTIElTXCIgYmFzaXMsXG4gKiBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC5cbiAqIFNlZSB0aGUgTGljZW5zZSBmb3IgdGhlIHNwZWNpZmljIGxhbmd1YWdlIGdvdmVybmluZyBwZXJtaXNzaW9ucyBhbmRcbiAqIGxpbWl0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLlxuICovXG5cbi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2Yga2V5Y2xvYWtcbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2xpYi9rZXljbG9hay5tb2R1bGUnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIva2V5Y2xvYWstYXV0aC1ndWFyZC5zZXJ2aWNlJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL2tleWNsb2FrLXVzZXIuc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9rZXljbG9hay5pbml0JztcbmV4cG9ydCAqIGZyb20gJy4vbGliL2tleWNsb2FrLW9wdGlvbnMuc2VydmljZSc7XG4iXX0=
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './public_api';
|
|
5
|
+
export { CallbackComponent as ɵa } from './lib/callback.component';
|
|
6
|
+
export { KeycloakRoutingModule as ɵb } from './lib/keycloak-routing.module';
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsdGltby1rZXljbG9hay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3ZhbHRpbW8va2V5Y2xvYWsvc3JjL3ZhbHRpbW8ta2V5Y2xvYWsudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGNBQWMsQ0FBQztBQUU3QixPQUFPLEVBQUMsaUJBQWlCLElBQUksRUFBRSxFQUFDLE1BQU0sMEJBQTBCLENBQUM7QUFDakUsT0FBTyxFQUFDLHFCQUFxQixJQUFJLEVBQUUsRUFBQyxNQUFNLCtCQUErQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuXG5leHBvcnQge0NhbGxiYWNrQ29tcG9uZW50IGFzIMm1YX0gZnJvbSAnLi9saWIvY2FsbGJhY2suY29tcG9uZW50JztcbmV4cG9ydCB7S2V5Y2xvYWtSb3V0aW5nTW9kdWxlIGFzIMm1Yn0gZnJvbSAnLi9saWIva2V5Y2xvYWstcm91dGluZy5tb2R1bGUnOyJdfQ==
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { ɵɵdefineInjectable, ɵɵinject, Injectable, Component, NgModule } from '@angular/core';
|
|
2
|
+
import { KeycloakAngularModule, KeycloakAuthGuard, KeycloakService } from 'keycloak-angular';
|
|
3
|
+
import { Router, RouterModule } from '@angular/router';
|
|
4
|
+
import { NGXLogger } from 'ngx-logger';
|
|
5
|
+
import { ConfigService } from '@valtimo/config';
|
|
6
|
+
import { CommonModule } from '@angular/common';
|
|
7
|
+
import { __awaiter } from 'tslib';
|
|
8
|
+
import { ReplaySubject } from 'rxjs';
|
|
9
|
+
import { ValtimoUserIdentity } from '@valtimo/contract';
|
|
10
|
+
|
|
11
|
+
class KeycloakOptionsService {
|
|
12
|
+
constructor(configService) {
|
|
13
|
+
this.configService = configService;
|
|
14
|
+
this.valtimoKeycloakOptions = configService.config.authentication.options;
|
|
15
|
+
}
|
|
16
|
+
get keycloakOptions() {
|
|
17
|
+
return this.valtimoKeycloakOptions.keycloakOptions;
|
|
18
|
+
}
|
|
19
|
+
get logoutRedirectUri() {
|
|
20
|
+
return this.valtimoKeycloakOptions.logoutRedirectUri;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
KeycloakOptionsService.ɵprov = ɵɵdefineInjectable({ factory: function KeycloakOptionsService_Factory() { return new KeycloakOptionsService(ɵɵinject(ConfigService)); }, token: KeycloakOptionsService, providedIn: "root" });
|
|
24
|
+
KeycloakOptionsService.decorators = [
|
|
25
|
+
{ type: Injectable, args: [{
|
|
26
|
+
providedIn: 'root'
|
|
27
|
+
},] }
|
|
28
|
+
];
|
|
29
|
+
KeycloakOptionsService.ctorParameters = () => [
|
|
30
|
+
{ type: ConfigService }
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
35
|
+
*
|
|
36
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
37
|
+
* you may not use this file except in compliance with the License.
|
|
38
|
+
* You may obtain a copy of the License at
|
|
39
|
+
*
|
|
40
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
41
|
+
*
|
|
42
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
43
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
44
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
45
|
+
* See the License for the specific language governing permissions and
|
|
46
|
+
* limitations under the License.
|
|
47
|
+
*/
|
|
48
|
+
class CallbackComponent {
|
|
49
|
+
constructor(router, keycloakOptionsService, logger) {
|
|
50
|
+
this.router = router;
|
|
51
|
+
this.keycloakOptionsService = keycloakOptionsService;
|
|
52
|
+
this.logger = logger;
|
|
53
|
+
logger.debug('callback');
|
|
54
|
+
const savedRedirectTo = window.sessionStorage.getItem('redirectTo');
|
|
55
|
+
let redirectTo;
|
|
56
|
+
if (savedRedirectTo !== null) {
|
|
57
|
+
redirectTo = window.sessionStorage.getItem('redirectTo');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
redirectTo = '/';
|
|
61
|
+
}
|
|
62
|
+
logger.debug('keycloak callback redirect =', redirectTo);
|
|
63
|
+
this.router.navigate([redirectTo]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
CallbackComponent.decorators = [
|
|
67
|
+
{ type: Component, args: [{
|
|
68
|
+
selector: 'valtimo-keycloak-callback',
|
|
69
|
+
template: ''
|
|
70
|
+
},] }
|
|
71
|
+
];
|
|
72
|
+
CallbackComponent.ctorParameters = () => [
|
|
73
|
+
{ type: Router },
|
|
74
|
+
{ type: KeycloakOptionsService },
|
|
75
|
+
{ type: NGXLogger }
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
80
|
+
*
|
|
81
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
82
|
+
* you may not use this file except in compliance with the License.
|
|
83
|
+
* You may obtain a copy of the License at
|
|
84
|
+
*
|
|
85
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
86
|
+
*
|
|
87
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
88
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
89
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
90
|
+
* See the License for the specific language governing permissions and
|
|
91
|
+
* limitations under the License.
|
|
92
|
+
*/
|
|
93
|
+
const ɵ0 = { title: 'Loading...' };
|
|
94
|
+
const routes = [
|
|
95
|
+
{
|
|
96
|
+
path: 'keycloak/callback',
|
|
97
|
+
component: CallbackComponent,
|
|
98
|
+
data: ɵ0
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
class KeycloakRoutingModule {
|
|
102
|
+
}
|
|
103
|
+
KeycloakRoutingModule.decorators = [
|
|
104
|
+
{ type: NgModule, args: [{
|
|
105
|
+
imports: [CommonModule, RouterModule.forChild(routes)],
|
|
106
|
+
exports: [RouterModule]
|
|
107
|
+
},] }
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
/*
|
|
111
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
112
|
+
*
|
|
113
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
114
|
+
* you may not use this file except in compliance with the License.
|
|
115
|
+
* You may obtain a copy of the License at
|
|
116
|
+
*
|
|
117
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
118
|
+
*
|
|
119
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
120
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
121
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
122
|
+
* See the License for the specific language governing permissions and
|
|
123
|
+
* limitations under the License.
|
|
124
|
+
*/
|
|
125
|
+
class KeycloakModule {
|
|
126
|
+
}
|
|
127
|
+
KeycloakModule.decorators = [
|
|
128
|
+
{ type: NgModule, args: [{
|
|
129
|
+
declarations: [CallbackComponent],
|
|
130
|
+
imports: [
|
|
131
|
+
KeycloakRoutingModule,
|
|
132
|
+
KeycloakAngularModule
|
|
133
|
+
],
|
|
134
|
+
exports: [CallbackComponent]
|
|
135
|
+
},] }
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
140
|
+
*
|
|
141
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
142
|
+
* you may not use this file except in compliance with the License.
|
|
143
|
+
* You may obtain a copy of the License at
|
|
144
|
+
*
|
|
145
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
146
|
+
*
|
|
147
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
148
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
149
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
150
|
+
* See the License for the specific language governing permissions and
|
|
151
|
+
* limitations under the License.
|
|
152
|
+
*/
|
|
153
|
+
class KeycloakAuthGuardService extends KeycloakAuthGuard {
|
|
154
|
+
constructor(router, keycloakAngular, logger) {
|
|
155
|
+
super(router, keycloakAngular);
|
|
156
|
+
this.router = router;
|
|
157
|
+
this.keycloakAngular = keycloakAngular;
|
|
158
|
+
this.logger = logger;
|
|
159
|
+
this.logger.debug('KeycloakAuthGuardService: ctor');
|
|
160
|
+
}
|
|
161
|
+
isAccessAllowed(route, state) {
|
|
162
|
+
this.logger.debug('KeycloakAuthGuardService: isAccessAllowed');
|
|
163
|
+
return new Promise((resolve, reject) => {
|
|
164
|
+
this.logger.debug('KeycloakAuthGuardService: isAccessAllowed checking access');
|
|
165
|
+
if (!this.authenticated) {
|
|
166
|
+
this.keycloakAngular.login().catch(e => `KeycloakAuthGuardService error: ${this.logger.error(e)}`);
|
|
167
|
+
return reject(false);
|
|
168
|
+
}
|
|
169
|
+
const requiredRoles = route.data.roles;
|
|
170
|
+
if (!requiredRoles || requiredRoles.length === 0) {
|
|
171
|
+
return resolve(true);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
if (!this.roles || this.roles.length === 0) {
|
|
175
|
+
resolve(false);
|
|
176
|
+
}
|
|
177
|
+
resolve(requiredRoles.some(role => this.roles.includes(role)));
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
KeycloakAuthGuardService.ɵprov = ɵɵdefineInjectable({ factory: function KeycloakAuthGuardService_Factory() { return new KeycloakAuthGuardService(ɵɵinject(Router), ɵɵinject(KeycloakService), ɵɵinject(NGXLogger)); }, token: KeycloakAuthGuardService, providedIn: "root" });
|
|
183
|
+
KeycloakAuthGuardService.decorators = [
|
|
184
|
+
{ type: Injectable, args: [{
|
|
185
|
+
providedIn: 'root'
|
|
186
|
+
},] }
|
|
187
|
+
];
|
|
188
|
+
KeycloakAuthGuardService.ctorParameters = () => [
|
|
189
|
+
{ type: Router },
|
|
190
|
+
{ type: KeycloakService },
|
|
191
|
+
{ type: NGXLogger }
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
class KeycloakUserService {
|
|
195
|
+
constructor(keycloakService, keycloakOptionsService, logger) {
|
|
196
|
+
this.keycloakService = keycloakService;
|
|
197
|
+
this.keycloakOptionsService = keycloakOptionsService;
|
|
198
|
+
this.logger = logger;
|
|
199
|
+
}
|
|
200
|
+
init() {
|
|
201
|
+
this.userIdentity = new ReplaySubject();
|
|
202
|
+
this.keycloakService.loadUserProfile().then(user => {
|
|
203
|
+
this.logger.debug('KeycloakUserService: loadUserProfile = ', user);
|
|
204
|
+
const roles = [];
|
|
205
|
+
this.keycloakService.getUserRoles(true).forEach(role => roles.push(role));
|
|
206
|
+
const valtimoUserIdentity = new ValtimoUserIdentity(user.email, user.firstName, user.lastName, roles, user.username);
|
|
207
|
+
this.logger.debug('KeycloakUserService: loaded user identity', valtimoUserIdentity);
|
|
208
|
+
this.userIdentity.next(valtimoUserIdentity);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
getUserSubject() {
|
|
212
|
+
this.logger.debug('KeycloakUserService: getUserIdentity');
|
|
213
|
+
return this.userIdentity;
|
|
214
|
+
}
|
|
215
|
+
logout() {
|
|
216
|
+
this.logger.debug('KeycloakUserService: logout');
|
|
217
|
+
this.keycloakService.logout(this.keycloakOptionsService.logoutRedirectUri);
|
|
218
|
+
}
|
|
219
|
+
getToken() {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
this.logger.debug('KeycloakUserService: getToken');
|
|
222
|
+
return this.keycloakService.getToken();
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
updateToken(minValidity) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
227
|
+
this.logger.debug('KeycloakUserService: updateToken');
|
|
228
|
+
return this.keycloakService.updateToken(minValidity);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
KeycloakUserService.ɵprov = ɵɵdefineInjectable({ factory: function KeycloakUserService_Factory() { return new KeycloakUserService(ɵɵinject(KeycloakService), ɵɵinject(KeycloakOptionsService), ɵɵinject(NGXLogger)); }, token: KeycloakUserService, providedIn: "root" });
|
|
233
|
+
KeycloakUserService.decorators = [
|
|
234
|
+
{ type: Injectable, args: [{
|
|
235
|
+
providedIn: 'root'
|
|
236
|
+
},] }
|
|
237
|
+
];
|
|
238
|
+
KeycloakUserService.ctorParameters = () => [
|
|
239
|
+
{ type: KeycloakService },
|
|
240
|
+
{ type: KeycloakOptionsService },
|
|
241
|
+
{ type: NGXLogger }
|
|
242
|
+
];
|
|
243
|
+
|
|
244
|
+
/*
|
|
245
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
246
|
+
*
|
|
247
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
248
|
+
* you may not use this file except in compliance with the License.
|
|
249
|
+
* You may obtain a copy of the License at
|
|
250
|
+
*
|
|
251
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
252
|
+
*
|
|
253
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
254
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
255
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
256
|
+
* See the License for the specific language governing permissions and
|
|
257
|
+
* limitations under the License.
|
|
258
|
+
*/
|
|
259
|
+
function keycloakInitializer(injector) {
|
|
260
|
+
const keycloakService = injector.get(KeycloakService);
|
|
261
|
+
const keycloakUserService = injector.get(KeycloakUserService);
|
|
262
|
+
const optionsService = injector.get(KeycloakOptionsService); // TODO possible removal of abstraction
|
|
263
|
+
const logger = injector.get(NGXLogger);
|
|
264
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
265
|
+
try {
|
|
266
|
+
logger.debug('Keycloak initializer before init');
|
|
267
|
+
const keycloakOptions = optionsService.keycloakOptions;
|
|
268
|
+
const currentUrl = window.location.href.split('#')[0];
|
|
269
|
+
if (keycloakOptions.initOptions.redirectUri !== currentUrl) {
|
|
270
|
+
const redirectTo = window.location.pathname;
|
|
271
|
+
logger.debug('Setting redirectTo =', redirectTo);
|
|
272
|
+
window.sessionStorage.setItem('redirectTo', redirectTo);
|
|
273
|
+
}
|
|
274
|
+
const initResult = yield keycloakService.init(keycloakOptions);
|
|
275
|
+
logger.debug('Keycloak initializer after init');
|
|
276
|
+
keycloakUserService.init();
|
|
277
|
+
return initResult;
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
logger.debug('Keycloak initializer error', error);
|
|
281
|
+
throw error;
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/*
|
|
287
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
288
|
+
*
|
|
289
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
290
|
+
* you may not use this file except in compliance with the License.
|
|
291
|
+
* You may obtain a copy of the License at
|
|
292
|
+
*
|
|
293
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
294
|
+
*
|
|
295
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
296
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
297
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
298
|
+
* See the License for the specific language governing permissions and
|
|
299
|
+
* limitations under the License.
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Generated bundle index. Do not edit.
|
|
304
|
+
*/
|
|
305
|
+
|
|
306
|
+
export { KeycloakAuthGuardService, KeycloakModule, KeycloakOptionsService, KeycloakUserService, keycloakInitializer, CallbackComponent as ɵa, KeycloakRoutingModule as ɵb };
|
|
307
|
+
//# sourceMappingURL=valtimo-keycloak.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valtimo-keycloak.js","sources":["../../../../projects/valtimo/keycloak/src/lib/keycloak-options.service.ts","../../../../projects/valtimo/keycloak/src/lib/callback.component.ts","../../../../projects/valtimo/keycloak/src/lib/keycloak-routing.module.ts","../../../../projects/valtimo/keycloak/src/lib/keycloak.module.ts","../../../../projects/valtimo/keycloak/src/lib/keycloak-auth-guard.service.ts","../../../../projects/valtimo/keycloak/src/lib/keycloak-user.service.ts","../../../../projects/valtimo/keycloak/src/lib/keycloak.init.ts","../../../../projects/valtimo/keycloak/src/public_api.ts","../../../../projects/valtimo/keycloak/src/valtimo-keycloak.ts"],"sourcesContent":["/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {ValtimoKeycloakOptions} from '@valtimo/contract';\nimport {Injectable} from '@angular/core';\nimport {ConfigService} from '@valtimo/config';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class KeycloakOptionsService {\n\n private readonly valtimoKeycloakOptions: ValtimoKeycloakOptions;\n\n constructor(\n private configService: ConfigService\n ) {\n this.valtimoKeycloakOptions = configService.config.authentication.options;\n }\n\n get keycloakOptions() {\n return this.valtimoKeycloakOptions.keycloakOptions;\n }\n\n get logoutRedirectUri() {\n return this.valtimoKeycloakOptions.logoutRedirectUri;\n }\n\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Component} from '@angular/core';\nimport {Router} from '@angular/router';\nimport {NGXLogger} from 'ngx-logger';\nimport {KeycloakOptionsService} from './keycloak-options.service';\n\n@Component({\n selector: 'valtimo-keycloak-callback',\n template: ''\n})\nexport class CallbackComponent {\n\n constructor(\n private router: Router,\n private keycloakOptionsService: KeycloakOptionsService,\n private logger: NGXLogger\n ) {\n logger.debug('callback');\n const savedRedirectTo = window.sessionStorage.getItem('redirectTo');\n let redirectTo;\n if (savedRedirectTo !== null) {\n redirectTo = window.sessionStorage.getItem('redirectTo');\n } else {\n redirectTo = '/';\n }\n logger.debug('keycloak callback redirect =', redirectTo);\n this.router.navigate([redirectTo]);\n }\n\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {NgModule} from '@angular/core';\nimport {RouterModule, Routes} from '@angular/router';\nimport {CallbackComponent} from './callback.component';\nimport {CommonModule} from '@angular/common';\n\nconst routes: Routes = [\n {\n path: 'keycloak/callback',\n component: CallbackComponent,\n data: {title: 'Loading...'}\n }\n];\n\n@NgModule({\n imports: [CommonModule, RouterModule.forChild(routes)],\n exports: [RouterModule]\n})\nexport class KeycloakRoutingModule {\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {NgModule} from '@angular/core';\nimport {KeycloakAngularModule} from 'keycloak-angular';\nimport {CallbackComponent} from './callback.component';\nimport {KeycloakRoutingModule} from './keycloak-routing.module';\n\n@NgModule({\n declarations: [CallbackComponent],\n imports: [\n KeycloakRoutingModule,\n KeycloakAngularModule\n ],\n exports: [CallbackComponent]\n})\nexport class KeycloakModule {\n\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {KeycloakAuthGuard, KeycloakService} from 'keycloak-angular';\nimport {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';\nimport {NGXLogger} from 'ngx-logger';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class KeycloakAuthGuardService extends KeycloakAuthGuard implements CanActivate {\n\n constructor(protected router: Router, protected keycloakAngular: KeycloakService, private logger: NGXLogger) {\n super(router, keycloakAngular);\n this.logger.debug('KeycloakAuthGuardService: ctor');\n }\n\n isAccessAllowed(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {\n this.logger.debug('KeycloakAuthGuardService: isAccessAllowed');\n return new Promise((resolve, reject) => {\n this.logger.debug('KeycloakAuthGuardService: isAccessAllowed checking access');\n if (!this.authenticated) {\n this.keycloakAngular.login().catch(e => `KeycloakAuthGuardService error: ${this.logger.error(e)}`);\n return reject(false);\n }\n\n const requiredRoles: string[] = route.data.roles;\n if (!requiredRoles || requiredRoles.length === 0) {\n return resolve(true);\n } else {\n if (!this.roles || this.roles.length === 0) {\n resolve(false);\n }\n resolve(requiredRoles.some(role => this.roles.includes(role)));\n }\n });\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {ReplaySubject} from 'rxjs';\nimport {NGXLogger} from 'ngx-logger';\nimport {KeycloakService} from 'keycloak-angular';\nimport {UserIdentity, UserService, ValtimoUserIdentity} from '@valtimo/contract';\nimport {KeycloakOptionsService} from './keycloak-options.service';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class KeycloakUserService implements UserService {\n private userIdentity: ReplaySubject<UserIdentity>;\n\n constructor(\n private keycloakService: KeycloakService,\n private keycloakOptionsService: KeycloakOptionsService,\n private logger: NGXLogger\n ) {}\n\n init(): void {\n this.userIdentity = new ReplaySubject();\n this.keycloakService.loadUserProfile().then(user => {\n this.logger.debug('KeycloakUserService: loadUserProfile = ', user);\n const roles: Array<string> = [];\n this.keycloakService.getUserRoles(true).forEach(role => roles.push(role));\n const valtimoUserIdentity = new ValtimoUserIdentity(\n user.email,\n user.firstName,\n user.lastName,\n roles,\n user.username\n );\n this.logger.debug('KeycloakUserService: loaded user identity', valtimoUserIdentity);\n this.userIdentity.next(valtimoUserIdentity);\n });\n }\n\n getUserSubject(): ReplaySubject<UserIdentity> {\n this.logger.debug('KeycloakUserService: getUserIdentity');\n return this.userIdentity;\n }\n\n logout(): void {\n this.logger.debug('KeycloakUserService: logout');\n this.keycloakService.logout(this.keycloakOptionsService.logoutRedirectUri);\n }\n\n async getToken(): Promise<string> {\n this.logger.debug('KeycloakUserService: getToken');\n return this.keycloakService.getToken();\n }\n\n async updateToken(minValidity: number): Promise<boolean> {\n this.logger.debug('KeycloakUserService: updateToken');\n return this.keycloakService.updateToken(minValidity);\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {KeycloakService} from 'keycloak-angular';\nimport {KeycloakOptionsService} from './keycloak-options.service';\nimport {Injector} from '@angular/core';\nimport {NGXLogger} from 'ngx-logger';\nimport {KeycloakUserService} from './keycloak-user.service';\n\nexport function keycloakInitializer(\n injector: Injector\n): () => Promise<any> {\n\n const keycloakService = injector.get<KeycloakService>(KeycloakService);\n const keycloakUserService = injector.get<KeycloakUserService>(KeycloakUserService);\n const optionsService = injector.get<KeycloakOptionsService>(KeycloakOptionsService); // TODO possible removal of abstraction\n const logger = injector.get<NGXLogger>(NGXLogger);\n\n return async (): Promise<any> => {\n try {\n logger.debug('Keycloak initializer before init');\n\n const keycloakOptions = optionsService.keycloakOptions;\n const currentUrl = window.location.href.split('#')[0];\n\n if (keycloakOptions.initOptions.redirectUri !== currentUrl) {\n const redirectTo = window.location.pathname;\n logger.debug('Setting redirectTo =', redirectTo);\n window.sessionStorage.setItem('redirectTo', redirectTo);\n }\n\n const initResult = await keycloakService.init(keycloakOptions);\n logger.debug('Keycloak initializer after init');\n\n keycloakUserService.init();\n\n return initResult;\n } catch (error) {\n logger.debug('Keycloak initializer error', error);\n throw error;\n }\n };\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * Public API Surface of keycloak\n */\n\nexport * from './lib/keycloak.module';\nexport * from './lib/keycloak-auth-guard.service';\nexport * from './lib/keycloak-user.service';\nexport * from './lib/keycloak.init';\nexport * from './lib/keycloak-options.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n\nexport {CallbackComponent as ɵa} from './lib/callback.component';\nexport {KeycloakRoutingModule as ɵb} from './lib/keycloak-routing.module';"],"names":[],"mappings":";;;;;;;;;;MAuBa,sBAAsB;IAIjC,YACU,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAEpC,IAAI,CAAC,sBAAsB,GAAG,aAAa,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC;KAC3E;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,sBAAsB,CAAC,eA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AAC,CAAC;YAEtD,IAAI,eAAe,CAAC,WAAW,CAAC,WAAW,KAAK,UAAU,EAAE;gBAC1D,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAC5C,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;gBACjD,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;aACzD;YAED,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC/D,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;YAEhD,mBAAmB,CAAC,IAAI,EAAE,CAAC;YAE3B,OAAO,UAAU,CAAC;SACnB;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;YAClD,MAAM,KAAK,CAAC;SACb;KACF,CAAA,CAAC;AACJ;;ACvDA;;;;;;;;;;;;;;;;ACAA;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Router } from '@angular/router';
|
|
2
|
+
import { NGXLogger } from 'ngx-logger';
|
|
3
|
+
import { KeycloakOptionsService } from './keycloak-options.service';
|
|
4
|
+
export declare class CallbackComponent {
|
|
5
|
+
private router;
|
|
6
|
+
private keycloakOptionsService;
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(router: Router, keycloakOptionsService: KeycloakOptionsService, logger: NGXLogger);
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KeycloakAuthGuard, KeycloakService } from 'keycloak-angular';
|
|
2
|
+
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
|
|
3
|
+
import { NGXLogger } from 'ngx-logger';
|
|
4
|
+
export declare class KeycloakAuthGuardService extends KeycloakAuthGuard implements CanActivate {
|
|
5
|
+
protected router: Router;
|
|
6
|
+
protected keycloakAngular: KeycloakService;
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(router: Router, keycloakAngular: KeycloakService, logger: NGXLogger);
|
|
9
|
+
isAccessAllowed(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConfigService } from '@valtimo/config';
|
|
2
|
+
export declare class KeycloakOptionsService {
|
|
3
|
+
private configService;
|
|
4
|
+
private readonly valtimoKeycloakOptions;
|
|
5
|
+
constructor(configService: ConfigService);
|
|
6
|
+
get keycloakOptions(): import("keycloak-angular").KeycloakOptions;
|
|
7
|
+
get logoutRedirectUri(): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReplaySubject } from 'rxjs';
|
|
2
|
+
import { NGXLogger } from 'ngx-logger';
|
|
3
|
+
import { KeycloakService } from 'keycloak-angular';
|
|
4
|
+
import { UserIdentity, UserService } from '@valtimo/contract';
|
|
5
|
+
import { KeycloakOptionsService } from './keycloak-options.service';
|
|
6
|
+
export declare class KeycloakUserService implements UserService {
|
|
7
|
+
private keycloakService;
|
|
8
|
+
private keycloakOptionsService;
|
|
9
|
+
private logger;
|
|
10
|
+
private userIdentity;
|
|
11
|
+
constructor(keycloakService: KeycloakService, keycloakOptionsService: KeycloakOptionsService, logger: NGXLogger);
|
|
12
|
+
init(): void;
|
|
13
|
+
getUserSubject(): ReplaySubject<UserIdentity>;
|
|
14
|
+
logout(): void;
|
|
15
|
+
getToken(): Promise<string>;
|
|
16
|
+
updateToken(minValidity: number): Promise<boolean>;
|
|
17
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@valtimo/keycloak",
|
|
3
|
+
"version": "4.15.2-next-main.8",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^10.0.11",
|
|
6
|
+
"@angular/core": "^10.0.11"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"registry": "http://repo.ritense.com/repository/npm-ritense-private/"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"keycloak-angular": "^8.0.1",
|
|
13
|
+
"keycloak-js": "^10.0.2",
|
|
14
|
+
"tslib": "^2.0.0"
|
|
15
|
+
},
|
|
16
|
+
"main": "bundles/valtimo-keycloak.umd.js",
|
|
17
|
+
"module": "fesm2015/valtimo-keycloak.js",
|
|
18
|
+
"es2015": "fesm2015/valtimo-keycloak.js",
|
|
19
|
+
"esm2015": "esm2015/valtimo-keycloak.js",
|
|
20
|
+
"fesm2015": "fesm2015/valtimo-keycloak.js",
|
|
21
|
+
"typings": "valtimo-keycloak.d.ts",
|
|
22
|
+
"metadata": "valtimo-keycloak.metadata.json",
|
|
23
|
+
"sideEffects": false
|
|
24
|
+
}
|
package/public_api.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"__symbolic":"module","version":4,"metadata":{"KeycloakModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":21,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ɵa"}],"imports":[{"__symbolic":"reference","name":"ɵb"},{"__symbolic":"reference","module":"keycloak-angular","name":"KeycloakAngularModule","line":25,"character":4}],"exports":[{"__symbolic":"reference","name":"ɵa"}]}]}],"members":{}},"KeycloakAuthGuardService":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"keycloak-angular","name":"KeycloakAuthGuard","line":24,"character":46},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":21,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"Router","line":26,"character":32},{"__symbolic":"reference","module":"keycloak-angular","name":"KeycloakService","line":26,"character":67},{"__symbolic":"reference","module":"ngx-logger","name":"NGXLogger","line":26,"character":100}]}],"isAccessAllowed":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"KeycloakUserService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":23,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"keycloak-angular","name":"KeycloakService","line":30,"character":29},{"__symbolic":"reference","name":"KeycloakOptionsService"},{"__symbolic":"reference","module":"ngx-logger","name":"NGXLogger","line":32,"character":20}]}],"init":[{"__symbolic":"method"}],"getUserSubject":[{"__symbolic":"method"}],"logout":[{"__symbolic":"method"}],"getToken":[{"__symbolic":"method"}],"updateToken":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"keycloakInitializer":{"__symbolic":"function"},"KeycloakOptionsService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":20,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@valtimo/config","name":"ConfigService","line":28,"character":27}]}]},"statics":{"ɵprov":{}}},"ɵa":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":21,"character":1},"arguments":[{"selector":"valtimo-keycloak-callback","template":""}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"Router","line":28,"character":20},{"__symbolic":"reference","name":"KeycloakOptionsService"},{"__symbolic":"reference","module":"ngx-logger","name":"NGXLogger","line":30,"character":20}]}]}},"ɵb":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":29,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":30,"character":12},{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@angular/router","name":"RouterModule","line":30,"character":26},"member":"forChild"},"arguments":[[{"path":"keycloak/callback","component":{"__symbolic":"reference","name":"ɵa"},"data":{"title":"Loading..."}}]]}],"exports":[{"__symbolic":"reference","module":"@angular/router","name":"RouterModule","line":31,"character":12}]}]}],"members":{}}},"origins":{"KeycloakModule":"./lib/keycloak.module","KeycloakAuthGuardService":"./lib/keycloak-auth-guard.service","KeycloakUserService":"./lib/keycloak-user.service","keycloakInitializer":"./lib/keycloak.init","KeycloakOptionsService":"./lib/keycloak-options.service","ɵa":"./lib/callback.component","ɵb":"./lib/keycloak-routing.module"},"importAs":"@valtimo/keycloak"}
|