keycloak-angular 7.0.1 → 7.3.1
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/README.md +29 -21
- package/bundles/keycloak-angular.umd.js +309 -216
- package/bundles/keycloak-angular.umd.js.map +1 -1
- package/bundles/keycloak-angular.umd.min.js +15 -1
- package/bundles/keycloak-angular.umd.min.js.map +1 -1
- package/esm2015/keycloak-angular.js +2 -2
- package/esm2015/lib/core/core.module.js +18 -16
- package/esm2015/lib/core/interceptors/keycloak-bearer.interceptor.js +20 -14
- package/esm2015/lib/core/interfaces/keycloak-config.js +1 -8
- package/esm2015/lib/core/interfaces/keycloak-event.js +11 -23
- package/esm2015/lib/core/interfaces/keycloak-options.js +1 -21
- package/esm2015/lib/core/services/keycloak-auth-guard.js +4 -11
- package/esm2015/lib/core/services/keycloak.service.js +78 -134
- package/esm2015/lib/core/utils/to-promise.js +10 -0
- package/esm2015/lib/keycloak-angular.module.js +10 -8
- package/esm2015/public_api.js +1 -1
- package/esm5/keycloak-angular.js +2 -2
- package/esm5/lib/core/core.module.js +15 -14
- package/esm5/lib/core/interceptors/keycloak-bearer.interceptor.js +15 -10
- package/esm5/lib/core/interfaces/keycloak-config.js +1 -8
- package/esm5/lib/core/interfaces/keycloak-event.js +11 -23
- package/esm5/lib/core/interfaces/keycloak-options.js +1 -21
- package/esm5/lib/core/services/keycloak-auth-guard.js +5 -12
- package/esm5/lib/core/services/keycloak.service.js +131 -183
- package/esm5/lib/core/utils/to-promise.js +10 -0
- package/esm5/lib/keycloak-angular.module.js +7 -6
- package/esm5/public_api.js +1 -1
- package/fesm2015/keycloak-angular.js +134 -172
- package/fesm2015/keycloak-angular.js.map +1 -1
- package/fesm5/keycloak-angular.js +175 -208
- package/fesm5/keycloak-angular.js.map +1 -1
- package/keycloak-angular.metadata.json +1 -1
- package/lib/core/interceptors/keycloak-bearer.interceptor.d.ts +1 -0
- package/lib/core/interfaces/keycloak-config.d.ts +2 -2
- package/lib/core/interfaces/keycloak-options.d.ts +1 -2
- package/lib/core/services/keycloak-auth-guard.d.ts +3 -3
- package/lib/core/services/keycloak.service.d.ts +7 -7
- package/lib/core/utils/to-promise.d.ts +7 -0
- package/package.json +8 -9
- package/public_api.d.ts +1 -1
- package/esm2015/lib/core/interfaces/keycloak-init-options.js +0 -13
- package/esm5/lib/core/interfaces/keycloak-init-options.js +0 -13
- package/lib/core/interfaces/keycloak-init-options.d.ts +0 -15
package/README.md
CHANGED
|
@@ -45,6 +45,11 @@ This library helps you to use [keycloak-js](https://www.keycloak.org/docs/latest
|
|
|
45
45
|
npm i --save keycloak-angular
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
**Note about versions**:
|
|
49
|
+
|
|
50
|
+
- For Angular v9, please use keycloak-angular v7.3 or higher.
|
|
51
|
+
- For Angular v8 and bellow, keycloak-angular v7.2.
|
|
52
|
+
|
|
48
53
|
### keycloak-js
|
|
49
54
|
|
|
50
55
|
> Since keycloak-angular v.7.0.0, the [keycloak-js](https://www.npmjs.com/package/keycloak-js) dependency became a peer dependency. This change allows greater flexibility for choosing the keycloak-js adapter version and follows the [project documentation recommendation](https://www.keycloak.org/docs/latest/securing_apps/index.html#_javascript_adapter).
|
|
@@ -83,9 +88,9 @@ import { initializer } from './utils/app-init';
|
|
|
83
88
|
provide: APP_INITIALIZER,
|
|
84
89
|
useFactory: initializer,
|
|
85
90
|
multi: true,
|
|
86
|
-
deps: [KeycloakService]
|
|
87
|
-
}
|
|
88
|
-
]
|
|
91
|
+
deps: [KeycloakService],
|
|
92
|
+
},
|
|
93
|
+
],
|
|
89
94
|
})
|
|
90
95
|
export class AppModule {}
|
|
91
96
|
```
|
|
@@ -111,13 +116,12 @@ The KeycloakService can be initialized before the application loading. When the
|
|
|
111
116
|
This has two major benefits.
|
|
112
117
|
|
|
113
118
|
1. This is faster because the application isn't fully bootstrapped and
|
|
114
|
-
1.
|
|
119
|
+
1. It prevents a moment when you see the application without having the authorization.
|
|
115
120
|
|
|
116
121
|
#### AppModule
|
|
117
122
|
|
|
118
123
|
```js
|
|
119
|
-
import { NgModule } from '@angular/core';
|
|
120
|
-
|
|
124
|
+
import { NgModule, DoBootstrap, ApplicationRef } from '@angular/core';
|
|
121
125
|
import { KeycloakAngularModule, KeycloakService } from 'keycloak-angular';
|
|
122
126
|
|
|
123
127
|
const keycloakService = new KeycloakService();
|
|
@@ -127,25 +131,29 @@ const keycloakService = new KeycloakService();
|
|
|
127
131
|
providers: [
|
|
128
132
|
{
|
|
129
133
|
provide: KeycloakService,
|
|
130
|
-
useValue: keycloakService
|
|
131
|
-
}
|
|
134
|
+
useValue: keycloakService,
|
|
135
|
+
},
|
|
132
136
|
],
|
|
133
|
-
entryComponents: [AppComponent]
|
|
137
|
+
entryComponents: [AppComponent],
|
|
134
138
|
})
|
|
135
|
-
export class AppModule {
|
|
136
|
-
ngDoBootstrap(
|
|
139
|
+
export class AppModule implements DoBootstrap {
|
|
140
|
+
ngDoBootstrap(appRef: ApplicationRef) {
|
|
137
141
|
keycloakService
|
|
138
142
|
.init()
|
|
139
143
|
.then(() => {
|
|
140
144
|
console.log('[ngDoBootstrap] bootstrap app');
|
|
141
145
|
|
|
142
|
-
|
|
146
|
+
appRef.bootstrap(AppComponent);
|
|
143
147
|
})
|
|
144
|
-
.catch(error =>
|
|
148
|
+
.catch((error) =>
|
|
149
|
+
console.error('[ngDoBootstrap] init Keycloak failed', error)
|
|
150
|
+
);
|
|
145
151
|
}
|
|
146
152
|
}
|
|
147
153
|
```
|
|
148
154
|
|
|
155
|
+
**Hint:** Do not forget to remove `bootstrap: [AppComponent]` from NgModule decorator options.
|
|
156
|
+
|
|
149
157
|
### Keycloak
|
|
150
158
|
|
|
151
159
|
Besides configuring the keycloak lib in your application it is also necessary to setup the
|
|
@@ -172,8 +180,8 @@ Example:
|
|
|
172
180
|
|
|
173
181
|
```js
|
|
174
182
|
import { Injectable } from '@angular/core';
|
|
175
|
-
import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router} from '@angular/router';
|
|
176
|
-
import {KeycloakAuthGuard, KeycloakService} from 'keycloak-angular';
|
|
183
|
+
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
|
|
184
|
+
import { KeycloakAuthGuard, KeycloakService } from 'keycloak-angular';
|
|
177
185
|
|
|
178
186
|
@Injectable({
|
|
179
187
|
providedIn: 'root'
|
|
@@ -217,14 +225,14 @@ try {
|
|
|
217
225
|
config: {
|
|
218
226
|
url: 'http://localhost:8080/auth',
|
|
219
227
|
realm: 'your-realm',
|
|
220
|
-
clientId: 'client-id'
|
|
228
|
+
clientId: 'client-id',
|
|
221
229
|
},
|
|
222
230
|
initOptions: {
|
|
223
231
|
onLoad: 'login-required',
|
|
224
|
-
checkLoginIframe: false
|
|
232
|
+
checkLoginIframe: false,
|
|
225
233
|
},
|
|
226
234
|
enableBearerInterceptor: true,
|
|
227
|
-
bearerExcludedUrls: ['/assets', '/clients/public']
|
|
235
|
+
bearerExcludedUrls: ['/assets', '/clients/public'],
|
|
228
236
|
});
|
|
229
237
|
resolve();
|
|
230
238
|
} catch (error) {}
|
|
@@ -235,12 +243,12 @@ try {
|
|
|
235
243
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
236
244
|
|
|
237
245
|
<!-- prettier-ignore -->
|
|
238
|
-
|[<img src="https://avatars3.githubusercontent.com/u/676270?v=4" width="
|
|
239
|
-
| :---: | :---: | :---: | :---: | :---: | :---: |
|
|
246
|
+
|[<img src="https://avatars3.githubusercontent.com/u/676270?v=4" width="89px;"/><br /><sub><b>Mauricio Gemelli Vigolo</b></sub>](https://github.com/mauriciovigolo)<br />|[<img src="https://avatars1.githubusercontent.com/u/695720?s=400&v=4" width="89px;"/><br /><sub><b>Jon Koops</b></sub>](https://github.com/https://github.com/jonkoops)<br />|[<img src="https://avatars0.githubusercontent.com/u/2146903?v=4" width="89px;"/><br /><sub><b>Frederik Prijck</b></sub>](https://github.com/frederikprijck)<br /> | [<img src="https://avatars2.githubusercontent.com/u/161351?s=460&v=4" width="89px;"/><br /><sub><b>Jonathan Share</b></sub>](https://github.com/sharebear)<br /> | [<img src="https://avatars1.githubusercontent.com/u/980278?v=4" width="89px;"/><br /><sub><b>jmparra</b></sub>](https://github.com/jmparra)<br /> | [<img src="https://avatars2.githubusercontent.com/u/6547340?v=4" width="89px;"/><br /><sub><b>Marcel Német</b></sub>](https://github.com/marcelnem)<br /> | [<img src="https://avatars3.githubusercontent.com/u/14264577?v=4" width="89px;"/><br /><sub><b>Raphael Alex Silva Abreu</b></sub>](https://github.com/aelkz)<br /> |
|
|
247
|
+
| :---: | :---: | :---: | :---: | :---: | :---: |:---: |
|
|
240
248
|
|
|
241
249
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
242
250
|
|
|
243
|
-
If you want to contribute to the project, please check out the [contributing](docs/
|
|
251
|
+
If you want to contribute to the project, please check out the [contributing](docs/contributing.md)
|
|
244
252
|
document.
|
|
245
253
|
|
|
246
254
|
## License
|