keycloak-angular 19.0.2 → 20.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.
- package/README.md +39 -2
- package/fesm2022/keycloak-angular.mjs +101 -62
- package/fesm2022/keycloak-angular.mjs.map +1 -1
- package/index.d.ts +1534 -3
- package/package.json +5 -4
- package/lib/directives/has-roles.directive.d.ts +0 -95
- package/lib/features/keycloak.feature.d.ts +0 -43
- package/lib/features/with-refresh-token.feature.d.ts +0 -66
- package/lib/guards/auth.guard.d.ts +0 -75
- package/lib/interceptors/custom-bearer-token.interceptor.d.ts +0 -97
- package/lib/interceptors/include-bearer-token.interceptor.d.ts +0 -111
- package/lib/interceptors/keycloak.interceptor.d.ts +0 -71
- package/lib/legacy/core/core.module.d.ts +0 -12
- package/lib/legacy/core/interceptors/keycloak-bearer.interceptor.d.ts +0 -53
- package/lib/legacy/core/interfaces/keycloak-event.d.ts +0 -74
- package/lib/legacy/core/interfaces/keycloak-options.d.ts +0 -146
- package/lib/legacy/core/services/keycloak-auth-guard.d.ts +0 -50
- package/lib/legacy/core/services/keycloak.service.d.ts +0 -316
- package/lib/legacy/keycloak-angular.module.d.ts +0 -12
- package/lib/legacy/public_api.d.ts +0 -14
- package/lib/provide-keycloak.d.ts +0 -74
- package/lib/services/auto-refresh-token.service.d.ts +0 -47
- package/lib/services/user-activity.service.d.ts +0 -66
- package/lib/signals/keycloak-events-signal.d.ts +0 -118
- package/public_api.d.ts +0 -19
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Mauricio Gemelli Vigolo and contributors.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by a MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/blob/main/LICENSE.md
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Keycloak event types, as described at the keycloak-js documentation:
|
|
10
|
-
* https://www.keycloak.org/docs/latest/securing_apps/index.html#callback-events
|
|
11
|
-
*
|
|
12
|
-
* @deprecated Keycloak Event based on the KeycloakService is deprecated and
|
|
13
|
-
* will be removed in future versions.
|
|
14
|
-
* Use the new `KEYCLOAK_EVENT_SIGNAL` injection token to listen for the keycloak
|
|
15
|
-
* events.
|
|
16
|
-
* More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md
|
|
17
|
-
*/
|
|
18
|
-
export declare enum KeycloakEventTypeLegacy {
|
|
19
|
-
/**
|
|
20
|
-
* Called if there was an error during authentication.
|
|
21
|
-
*/
|
|
22
|
-
OnAuthError = 0,
|
|
23
|
-
/**
|
|
24
|
-
* Called if the user is logged out
|
|
25
|
-
* (will only be called if the session status iframe is enabled, or in Cordova mode).
|
|
26
|
-
*/
|
|
27
|
-
OnAuthLogout = 1,
|
|
28
|
-
/**
|
|
29
|
-
* Called if there was an error while trying to refresh the token.
|
|
30
|
-
*/
|
|
31
|
-
OnAuthRefreshError = 2,
|
|
32
|
-
/**
|
|
33
|
-
* Called when the token is refreshed.
|
|
34
|
-
*/
|
|
35
|
-
OnAuthRefreshSuccess = 3,
|
|
36
|
-
/**
|
|
37
|
-
* Called when a user is successfully authenticated.
|
|
38
|
-
*/
|
|
39
|
-
OnAuthSuccess = 4,
|
|
40
|
-
/**
|
|
41
|
-
* Called when the adapter is initialized.
|
|
42
|
-
*/
|
|
43
|
-
OnReady = 5,
|
|
44
|
-
/**
|
|
45
|
-
* Called when the access token is expired. If a refresh token is available the token
|
|
46
|
-
* can be refreshed with updateToken, or in cases where it is not (that is, with implicit flow)
|
|
47
|
-
* you can redirect to login screen to obtain a new access token.
|
|
48
|
-
*/
|
|
49
|
-
OnTokenExpired = 6,
|
|
50
|
-
/**
|
|
51
|
-
* Called when a AIA has been requested by the application.
|
|
52
|
-
*/
|
|
53
|
-
OnActionUpdate = 7
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Structure of an event triggered by Keycloak, contains it's type
|
|
57
|
-
* and arguments (if any).
|
|
58
|
-
*
|
|
59
|
-
* @deprecated Keycloak Event based on the KeycloakService is deprecated and
|
|
60
|
-
* will be removed in future versions.
|
|
61
|
-
* Use the new `KEYCLOAK_EVENT_SIGNAL` injection token to listen for the keycloak
|
|
62
|
-
* events.
|
|
63
|
-
* More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md
|
|
64
|
-
*/
|
|
65
|
-
export interface KeycloakEventLegacy {
|
|
66
|
-
/**
|
|
67
|
-
* Event type as described at {@link KeycloakEventTypeLegacy}.
|
|
68
|
-
*/
|
|
69
|
-
type: KeycloakEventTypeLegacy;
|
|
70
|
-
/**
|
|
71
|
-
* Arguments from the keycloak-js event function.
|
|
72
|
-
*/
|
|
73
|
-
args?: unknown;
|
|
74
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Mauricio Gemelli Vigolo and contributors.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by a MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/blob/main/LICENSE.md
|
|
7
|
-
*/
|
|
8
|
-
import { HttpRequest } from '@angular/common/http';
|
|
9
|
-
/**
|
|
10
|
-
* HTTP Methods
|
|
11
|
-
*
|
|
12
|
-
* @deprecated KeycloakBearerInterceptor is deprecated and will be removed in future versions.
|
|
13
|
-
* Use the new functional interceptor `includeBearerTokenInterceptor`.
|
|
14
|
-
* More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md
|
|
15
|
-
*/
|
|
16
|
-
export type HttpMethodsLegacy = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
17
|
-
/**
|
|
18
|
-
* ExcludedUrl type may be used to specify the url and the HTTP method that
|
|
19
|
-
* should not be intercepted by the KeycloakBearerInterceptor.
|
|
20
|
-
*
|
|
21
|
-
* Example:
|
|
22
|
-
* const excludedUrl: ExcludedUrl[] = [
|
|
23
|
-
* {
|
|
24
|
-
* url: 'reports/public'
|
|
25
|
-
* httpMethods: ['GET']
|
|
26
|
-
* }
|
|
27
|
-
* ]
|
|
28
|
-
*
|
|
29
|
-
* In the example above for URL reports/public and HTTP Method GET the
|
|
30
|
-
* bearer will not be automatically added.
|
|
31
|
-
*
|
|
32
|
-
* If the url is informed but httpMethod is undefined, then the bearer
|
|
33
|
-
* will not be added for all HTTP Methods.
|
|
34
|
-
*
|
|
35
|
-
* @deprecated KeycloakBearerInterceptor is deprecated and will be removed in future versions.
|
|
36
|
-
* Use the new functional interceptor `includeBearerTokenInterceptor`.
|
|
37
|
-
* More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md
|
|
38
|
-
*/
|
|
39
|
-
export interface ExcludedUrl {
|
|
40
|
-
url: string;
|
|
41
|
-
httpMethods?: HttpMethodsLegacy[];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Similar to ExcludedUrl, contains the HTTP methods and a regex to
|
|
45
|
-
* include the url patterns.
|
|
46
|
-
* This interface is used internally by the KeycloakService.
|
|
47
|
-
*
|
|
48
|
-
* @deprecated KeycloakBearerInterceptor is deprecated and will be removed in future versions.
|
|
49
|
-
* Use the new functional interceptor `includeBearerTokenInterceptor`.
|
|
50
|
-
* More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md
|
|
51
|
-
*/
|
|
52
|
-
export interface ExcludedUrlRegex {
|
|
53
|
-
urlPattern: RegExp;
|
|
54
|
-
httpMethods?: HttpMethodsLegacy[];
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* keycloak-angular initialization options.
|
|
58
|
-
*
|
|
59
|
-
* @deprecated KeycloakService is deprecated and will be removed in future versions.
|
|
60
|
-
* Use the new `provideKeycloak` method to load Keycloak in an Angular application.
|
|
61
|
-
* More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md
|
|
62
|
-
*/
|
|
63
|
-
export interface KeycloakOptions {
|
|
64
|
-
/**
|
|
65
|
-
* Configs to init the keycloak-js library. If undefined, will look for a keycloak.json file
|
|
66
|
-
* at root of the project.
|
|
67
|
-
* If not undefined, can be a string meaning the url to the keycloak.json file or an object
|
|
68
|
-
* of {@link Keycloak.KeycloakConfig}. Use this configuration if you want to specify the keycloak server,
|
|
69
|
-
* realm, clientId. This is usefull if you have different configurations for production, stage
|
|
70
|
-
* and development environments. Hint: Make use of Angular environment configuration.
|
|
71
|
-
*/
|
|
72
|
-
config?: string | Keycloak.KeycloakConfig;
|
|
73
|
-
/**
|
|
74
|
-
* Options to initialize the Keycloak adapter, matches the options as provided by Keycloak itself.
|
|
75
|
-
*/
|
|
76
|
-
initOptions?: Keycloak.KeycloakInitOptions;
|
|
77
|
-
/**
|
|
78
|
-
* By default all requests made by Angular HttpClient will be intercepted in order to
|
|
79
|
-
* add the bearer in the Authorization Http Header. However, if this is a not desired
|
|
80
|
-
* feature, the enableBearerInterceptor must be false.
|
|
81
|
-
*
|
|
82
|
-
* Briefly, if enableBearerInterceptor === false, the bearer will not be added
|
|
83
|
-
* to the authorization header.
|
|
84
|
-
*
|
|
85
|
-
* The default value is true.
|
|
86
|
-
*/
|
|
87
|
-
enableBearerInterceptor?: boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Forces the execution of loadUserProfile after the keycloak initialization considering that the
|
|
90
|
-
* user logged in.
|
|
91
|
-
* This option is recommended if is desirable to have the user details at the beginning,
|
|
92
|
-
* so after the login, the loadUserProfile function will be called and its value cached.
|
|
93
|
-
*
|
|
94
|
-
* The default value is true.
|
|
95
|
-
*/
|
|
96
|
-
loadUserProfileAtStartUp?: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* @deprecated
|
|
99
|
-
* String Array to exclude the urls that should not have the Authorization Header automatically
|
|
100
|
-
* added. This library makes use of Angular Http Interceptor, to automatically add the Bearer
|
|
101
|
-
* token to the request.
|
|
102
|
-
*/
|
|
103
|
-
bearerExcludedUrls?: (string | ExcludedUrl)[];
|
|
104
|
-
/**
|
|
105
|
-
* This value will be used as the Authorization Http Header name. The default value is
|
|
106
|
-
* **Authorization**. If the backend expects requests to have a token in a different header, you
|
|
107
|
-
* should change this value, i.e: **JWT-Authorization**. This will result in a Http Header
|
|
108
|
-
* Authorization as "JWT-Authorization: bearer <token>".
|
|
109
|
-
*/
|
|
110
|
-
authorizationHeaderName?: string;
|
|
111
|
-
/**
|
|
112
|
-
* This value will be included in the Authorization Http Header param. The default value is
|
|
113
|
-
* **Bearer**, which will result in a Http Header Authorization as "Authorization: Bearer <token>".
|
|
114
|
-
*
|
|
115
|
-
* If any other value is needed by the backend in the authorization header, you should change this
|
|
116
|
-
* value.
|
|
117
|
-
*
|
|
118
|
-
* Warning: this value must be in compliance with the keycloak server instance and the adapter.
|
|
119
|
-
*/
|
|
120
|
-
bearerPrefix?: string;
|
|
121
|
-
/**
|
|
122
|
-
* This value will be used to determine whether or not the token needs to be updated. If the token
|
|
123
|
-
* will expire is fewer seconds than the updateMinValidity value, then it will be updated.
|
|
124
|
-
*
|
|
125
|
-
* The default value is 20.
|
|
126
|
-
*/
|
|
127
|
-
updateMinValidity?: number;
|
|
128
|
-
/**
|
|
129
|
-
* A function that will tell the KeycloakBearerInterceptor whether to add the token to the request
|
|
130
|
-
* or to leave the request as it is. If the returned value is `true`, the request will have the token
|
|
131
|
-
* present on it. If it is `false`, the token will be left off the request.
|
|
132
|
-
*
|
|
133
|
-
* The default is a function that always returns `true`.
|
|
134
|
-
*/
|
|
135
|
-
shouldAddToken?: (request: HttpRequest<unknown>) => boolean;
|
|
136
|
-
/**
|
|
137
|
-
* A function that will tell the KeycloakBearerInterceptor if the token should be considered for
|
|
138
|
-
* updating as a part of the request being made. If the returned value is `true`, the request will
|
|
139
|
-
* check the token's expiry time and if it is less than the number of seconds configured by
|
|
140
|
-
* updateMinValidity then it will be updated before the request is made. If the returned value is
|
|
141
|
-
* false, the token will not be updated.
|
|
142
|
-
*
|
|
143
|
-
* The default is a function that always returns `true`.
|
|
144
|
-
*/
|
|
145
|
-
shouldUpdateToken?: (request: HttpRequest<unknown>) => boolean;
|
|
146
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Mauricio Gemelli Vigolo and contributors.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by a MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/blob/main/LICENSE.md
|
|
7
|
-
*/
|
|
8
|
-
import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
|
|
9
|
-
import { KeycloakService } from './keycloak.service';
|
|
10
|
-
/**
|
|
11
|
-
* A simple guard implementation out of the box. This class should be inherited and
|
|
12
|
-
* implemented by the application. The only method that should be implemented is #isAccessAllowed.
|
|
13
|
-
* The reason for this is that the authorization flow is usually not unique, so in this way you will
|
|
14
|
-
* have more freedom to customize your authorization flow.
|
|
15
|
-
*
|
|
16
|
-
* @deprecated Class based guards are deprecated in Keycloak Angular and will be removed in future versions.
|
|
17
|
-
* Use the new `createAuthGuard` function to create a Guard for your application.
|
|
18
|
-
* More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md
|
|
19
|
-
*/
|
|
20
|
-
export declare abstract class KeycloakAuthGuard implements CanActivate {
|
|
21
|
-
protected router: Router;
|
|
22
|
-
protected keycloakAngular: KeycloakService;
|
|
23
|
-
/**
|
|
24
|
-
* Indicates if the user is authenticated or not.
|
|
25
|
-
*/
|
|
26
|
-
protected authenticated: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Roles of the logged user. It contains the clientId and realm user roles.
|
|
29
|
-
*/
|
|
30
|
-
protected roles: string[];
|
|
31
|
-
constructor(router: Router, keycloakAngular: KeycloakService);
|
|
32
|
-
/**
|
|
33
|
-
* CanActivate checks if the user is logged in and get the full list of roles (REALM + CLIENT)
|
|
34
|
-
* of the logged user. This values are set to authenticated and roles params.
|
|
35
|
-
*
|
|
36
|
-
* @param route
|
|
37
|
-
* @param state
|
|
38
|
-
*/
|
|
39
|
-
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree>;
|
|
40
|
-
/**
|
|
41
|
-
* Create your own customized authorization flow in this method. From here you already known
|
|
42
|
-
* if the user is authenticated (this.authenticated) and the user roles (this.roles).
|
|
43
|
-
*
|
|
44
|
-
* Return a UrlTree if the user should be redirected to another route.
|
|
45
|
-
*
|
|
46
|
-
* @param route
|
|
47
|
-
* @param state
|
|
48
|
-
*/
|
|
49
|
-
abstract isAccessAllowed(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree>;
|
|
50
|
-
}
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import { HttpHeaders, HttpRequest } from '@angular/common/http';
|
|
2
|
-
import { Subject } from 'rxjs';
|
|
3
|
-
import { ExcludedUrlRegex, KeycloakOptions } from '../interfaces/keycloak-options';
|
|
4
|
-
import { KeycloakEventLegacy } from '../interfaces/keycloak-event';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
/**
|
|
7
|
-
* Service to expose existent methods from the Keycloak JS adapter, adding new
|
|
8
|
-
* functionalities to improve the use of keycloak in Angular v > 4.3 applications.
|
|
9
|
-
*
|
|
10
|
-
* This class should be injected in the application bootstrap, so the same instance will be used
|
|
11
|
-
* along the web application.
|
|
12
|
-
*
|
|
13
|
-
* @deprecated This service is deprecated and will be removed in future versions.
|
|
14
|
-
* Use the new `provideKeycloak` function to load Keycloak in an Angular application.
|
|
15
|
-
* More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md
|
|
16
|
-
*/
|
|
17
|
-
export declare class KeycloakService {
|
|
18
|
-
/**
|
|
19
|
-
* Keycloak-js instance.
|
|
20
|
-
*/
|
|
21
|
-
private _instance;
|
|
22
|
-
/**
|
|
23
|
-
* User profile as KeycloakProfile interface.
|
|
24
|
-
*/
|
|
25
|
-
private _userProfile;
|
|
26
|
-
/**
|
|
27
|
-
* Flag to indicate if the bearer will not be added to the authorization header.
|
|
28
|
-
*/
|
|
29
|
-
private _enableBearerInterceptor;
|
|
30
|
-
/**
|
|
31
|
-
* When the implicit flow is choosen there must exist a silentRefresh, as there is
|
|
32
|
-
* no refresh token.
|
|
33
|
-
*/
|
|
34
|
-
private _silentRefresh;
|
|
35
|
-
/**
|
|
36
|
-
* Indicates that the user profile should be loaded at the keycloak initialization,
|
|
37
|
-
* just after the login.
|
|
38
|
-
*/
|
|
39
|
-
private _loadUserProfileAtStartUp;
|
|
40
|
-
/**
|
|
41
|
-
* The bearer prefix that will be appended to the Authorization Header.
|
|
42
|
-
*/
|
|
43
|
-
private _bearerPrefix;
|
|
44
|
-
/**
|
|
45
|
-
* Value that will be used as the Authorization Http Header name.
|
|
46
|
-
*/
|
|
47
|
-
private _authorizationHeaderName;
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated
|
|
50
|
-
* The excluded urls patterns that must skip the KeycloakBearerInterceptor.
|
|
51
|
-
*/
|
|
52
|
-
private _excludedUrls;
|
|
53
|
-
/**
|
|
54
|
-
* Observer for the keycloak events
|
|
55
|
-
*/
|
|
56
|
-
private _keycloakEvents$;
|
|
57
|
-
/**
|
|
58
|
-
* The amount of required time remaining before expiry of the token before the token will be refreshed.
|
|
59
|
-
*/
|
|
60
|
-
private _updateMinValidity;
|
|
61
|
-
/**
|
|
62
|
-
* Returns true if the request should have the token added to the headers by the KeycloakBearerInterceptor.
|
|
63
|
-
*/
|
|
64
|
-
shouldAddToken: (request: HttpRequest<unknown>) => boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Returns true if the request being made should potentially update the token.
|
|
67
|
-
*/
|
|
68
|
-
shouldUpdateToken: (request: HttpRequest<unknown>) => boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Binds the keycloak-js events to the keycloakEvents Subject
|
|
71
|
-
* which is a good way to monitor for changes, if needed.
|
|
72
|
-
*
|
|
73
|
-
* The keycloakEvents returns the keycloak-js event type and any
|
|
74
|
-
* argument if the source function provides any.
|
|
75
|
-
*/
|
|
76
|
-
private bindsKeycloakEvents;
|
|
77
|
-
/**
|
|
78
|
-
* Loads all bearerExcludedUrl content in a uniform type: ExcludedUrl,
|
|
79
|
-
* so it becomes easier to handle.
|
|
80
|
-
*
|
|
81
|
-
* @param bearerExcludedUrls array of strings or ExcludedUrl that includes
|
|
82
|
-
* the url and HttpMethod.
|
|
83
|
-
*/
|
|
84
|
-
private loadExcludedUrls;
|
|
85
|
-
/**
|
|
86
|
-
* Handles the class values initialization.
|
|
87
|
-
*
|
|
88
|
-
* @param options
|
|
89
|
-
*/
|
|
90
|
-
private initServiceValues;
|
|
91
|
-
/**
|
|
92
|
-
* Keycloak initialization. It should be called to initialize the adapter.
|
|
93
|
-
* Options is an object with 2 main parameters: config and initOptions. The first one
|
|
94
|
-
* will be used to create the Keycloak instance. The second one are options to initialize the
|
|
95
|
-
* keycloak instance.
|
|
96
|
-
*
|
|
97
|
-
* @param options
|
|
98
|
-
* Config: may be a string representing the keycloak URI or an object with the
|
|
99
|
-
* following content:
|
|
100
|
-
* - url: Keycloak json URL
|
|
101
|
-
* - realm: realm name
|
|
102
|
-
* - clientId: client id
|
|
103
|
-
*
|
|
104
|
-
* initOptions:
|
|
105
|
-
* Options to initialize the Keycloak adapter, matches the options as provided by Keycloak itself.
|
|
106
|
-
*
|
|
107
|
-
* enableBearerInterceptor:
|
|
108
|
-
* Flag to indicate if the bearer will added to the authorization header.
|
|
109
|
-
*
|
|
110
|
-
* loadUserProfileInStartUp:
|
|
111
|
-
* Indicates that the user profile should be loaded at the keycloak initialization,
|
|
112
|
-
* just after the login.
|
|
113
|
-
*
|
|
114
|
-
* bearerExcludedUrls:
|
|
115
|
-
* String Array to exclude the urls that should not have the Authorization Header automatically
|
|
116
|
-
* added.
|
|
117
|
-
*
|
|
118
|
-
* authorizationHeaderName:
|
|
119
|
-
* This value will be used as the Authorization Http Header name.
|
|
120
|
-
*
|
|
121
|
-
* bearerPrefix:
|
|
122
|
-
* This value will be included in the Authorization Http Header param.
|
|
123
|
-
*
|
|
124
|
-
* tokenUpdateExcludedHeaders:
|
|
125
|
-
* Array of Http Header key/value maps that should not trigger the token to be updated.
|
|
126
|
-
*
|
|
127
|
-
* updateMinValidity:
|
|
128
|
-
* This value determines if the token will be refreshed based on its expiration time.
|
|
129
|
-
*
|
|
130
|
-
* @returns
|
|
131
|
-
* A Promise with a boolean indicating if the initialization was successful.
|
|
132
|
-
*/
|
|
133
|
-
init(options?: KeycloakOptions): Promise<boolean>;
|
|
134
|
-
/**
|
|
135
|
-
* Redirects to login form on (options is an optional object with redirectUri and/or
|
|
136
|
-
* prompt fields).
|
|
137
|
-
*
|
|
138
|
-
* @param options
|
|
139
|
-
* Object, where:
|
|
140
|
-
* - redirectUri: Specifies the uri to redirect to after login.
|
|
141
|
-
* - prompt:By default the login screen is displayed if the user is not logged-in to Keycloak.
|
|
142
|
-
* To only authenticate to the application if the user is already logged-in and not display the
|
|
143
|
-
* login page if the user is not logged-in, set this option to none. To always require
|
|
144
|
-
* re-authentication and ignore SSO, set this option to login .
|
|
145
|
-
* - maxAge: Used just if user is already authenticated. Specifies maximum time since the
|
|
146
|
-
* authentication of user happened. If user is already authenticated for longer time than
|
|
147
|
-
* maxAge, the SSO is ignored and he will need to re-authenticate again.
|
|
148
|
-
* - loginHint: Used to pre-fill the username/email field on the login form.
|
|
149
|
-
* - action: If value is 'register' then user is redirected to registration page, otherwise to
|
|
150
|
-
* login page.
|
|
151
|
-
* - locale: Specifies the desired locale for the UI.
|
|
152
|
-
* @returns
|
|
153
|
-
* A void Promise if the login is successful and after the user profile loading.
|
|
154
|
-
*/
|
|
155
|
-
login(options?: Keycloak.KeycloakLoginOptions): Promise<void>;
|
|
156
|
-
/**
|
|
157
|
-
* Redirects to logout.
|
|
158
|
-
*
|
|
159
|
-
* @param redirectUri
|
|
160
|
-
* Specifies the uri to redirect to after logout.
|
|
161
|
-
* @returns
|
|
162
|
-
* A void Promise if the logout was successful, cleaning also the userProfile.
|
|
163
|
-
*/
|
|
164
|
-
logout(redirectUri?: string): Promise<void>;
|
|
165
|
-
/**
|
|
166
|
-
* Redirects to registration form. Shortcut for login with option
|
|
167
|
-
* action = 'register'. Options are same as for the login method but 'action' is set to
|
|
168
|
-
* 'register'.
|
|
169
|
-
*
|
|
170
|
-
* @param options
|
|
171
|
-
* login options
|
|
172
|
-
* @returns
|
|
173
|
-
* A void Promise if the register flow was successful.
|
|
174
|
-
*/
|
|
175
|
-
register(options?: Keycloak.KeycloakLoginOptions): Promise<void>;
|
|
176
|
-
/**
|
|
177
|
-
* Check if the user has access to the specified role. It will look for roles in
|
|
178
|
-
* realm and the given resource, but will not check if the user is logged in for better performance.
|
|
179
|
-
*
|
|
180
|
-
* @param role
|
|
181
|
-
* role name
|
|
182
|
-
* @param resource
|
|
183
|
-
* resource name. If not specified, `clientId` is used
|
|
184
|
-
* @returns
|
|
185
|
-
* A boolean meaning if the user has the specified Role.
|
|
186
|
-
*/
|
|
187
|
-
isUserInRole(role: string, resource?: string): boolean;
|
|
188
|
-
/**
|
|
189
|
-
* Return the roles of the logged user. The realmRoles parameter, with default value
|
|
190
|
-
* true, will return the resource roles and realm roles associated with the logged user. If set to false
|
|
191
|
-
* it will only return the resource roles. The resource parameter, if specified, will return only resource roles
|
|
192
|
-
* associated with the given resource.
|
|
193
|
-
*
|
|
194
|
-
* @param realmRoles
|
|
195
|
-
* Set to false to exclude realm roles (only client roles)
|
|
196
|
-
* @param resource
|
|
197
|
-
* resource name If not specified, returns roles from all resources
|
|
198
|
-
* @returns
|
|
199
|
-
* Array of Roles associated with the logged user.
|
|
200
|
-
*/
|
|
201
|
-
getUserRoles(realmRoles?: boolean, resource?: string): string[];
|
|
202
|
-
/**
|
|
203
|
-
* Check if user is logged in.
|
|
204
|
-
*
|
|
205
|
-
* @returns
|
|
206
|
-
* A boolean that indicates if the user is logged in.
|
|
207
|
-
*/
|
|
208
|
-
isLoggedIn(): boolean;
|
|
209
|
-
/**
|
|
210
|
-
* Returns true if the token has less than minValidity seconds left before
|
|
211
|
-
* it expires.
|
|
212
|
-
*
|
|
213
|
-
* @param minValidity
|
|
214
|
-
* Seconds left. (minValidity) is optional. Default value is 0.
|
|
215
|
-
* @returns
|
|
216
|
-
* Boolean indicating if the token is expired.
|
|
217
|
-
*/
|
|
218
|
-
isTokenExpired(minValidity?: number): boolean;
|
|
219
|
-
/**
|
|
220
|
-
* If the token expires within _updateMinValidity seconds the token is refreshed. If the
|
|
221
|
-
* session status iframe is enabled, the session status is also checked.
|
|
222
|
-
* Returns a promise telling if the token was refreshed or not. If the session is not active
|
|
223
|
-
* anymore, the promise is rejected.
|
|
224
|
-
*
|
|
225
|
-
* @param minValidity
|
|
226
|
-
* Seconds left. (minValidity is optional, if not specified updateMinValidity - default 20 is used)
|
|
227
|
-
* @returns
|
|
228
|
-
* Promise with a boolean indicating if the token was succesfully updated.
|
|
229
|
-
*/
|
|
230
|
-
updateToken(minValidity?: number): Promise<boolean>;
|
|
231
|
-
/**
|
|
232
|
-
* Loads the user profile.
|
|
233
|
-
* Returns promise to set functions to be invoked if the profile was loaded
|
|
234
|
-
* successfully, or if the profile could not be loaded.
|
|
235
|
-
*
|
|
236
|
-
* @param forceReload
|
|
237
|
-
* If true will force the loadUserProfile even if its already loaded.
|
|
238
|
-
* @returns
|
|
239
|
-
* A promise with the KeycloakProfile data loaded.
|
|
240
|
-
*/
|
|
241
|
-
loadUserProfile(forceReload?: boolean): Promise<import("keycloak-js").KeycloakProfile>;
|
|
242
|
-
/**
|
|
243
|
-
* Returns the authenticated token.
|
|
244
|
-
*/
|
|
245
|
-
getToken(): Promise<string>;
|
|
246
|
-
/**
|
|
247
|
-
* Returns the logged username.
|
|
248
|
-
*
|
|
249
|
-
* @returns
|
|
250
|
-
* The logged username.
|
|
251
|
-
*/
|
|
252
|
-
getUsername(): string;
|
|
253
|
-
/**
|
|
254
|
-
* Clear authentication state, including tokens. This can be useful if application
|
|
255
|
-
* has detected the session was expired, for example if updating token fails.
|
|
256
|
-
* Invoking this results in onAuthLogout callback listener being invoked.
|
|
257
|
-
*/
|
|
258
|
-
clearToken(): void;
|
|
259
|
-
/**
|
|
260
|
-
* Adds a valid token in header. The key & value format is:
|
|
261
|
-
* Authorization Bearer <token>.
|
|
262
|
-
* If the headers param is undefined it will create the Angular headers object.
|
|
263
|
-
*
|
|
264
|
-
* @param headers
|
|
265
|
-
* Updated header with Authorization and Keycloak token.
|
|
266
|
-
* @returns
|
|
267
|
-
* An observable with with the HTTP Authorization header and the current token.
|
|
268
|
-
*/
|
|
269
|
-
addTokenToHeader(headers?: HttpHeaders): import("rxjs").Observable<HttpHeaders>;
|
|
270
|
-
/**
|
|
271
|
-
* Returns the original Keycloak instance, if you need any customization that
|
|
272
|
-
* this Angular service does not support yet. Use with caution.
|
|
273
|
-
*
|
|
274
|
-
* @returns
|
|
275
|
-
* The KeycloakInstance from keycloak-js.
|
|
276
|
-
*/
|
|
277
|
-
getKeycloakInstance(): Keycloak.KeycloakInstance;
|
|
278
|
-
/**
|
|
279
|
-
* @deprecated
|
|
280
|
-
* Returns the excluded URLs that should not be considered by
|
|
281
|
-
* the http interceptor which automatically adds the authorization header in the Http Request.
|
|
282
|
-
*
|
|
283
|
-
* @returns
|
|
284
|
-
* The excluded urls that must not be intercepted by the KeycloakBearerInterceptor.
|
|
285
|
-
*/
|
|
286
|
-
get excludedUrls(): ExcludedUrlRegex[];
|
|
287
|
-
/**
|
|
288
|
-
* Flag to indicate if the bearer will be added to the authorization header.
|
|
289
|
-
*
|
|
290
|
-
* @returns
|
|
291
|
-
* Returns if the bearer interceptor was set to be disabled.
|
|
292
|
-
*/
|
|
293
|
-
get enableBearerInterceptor(): boolean;
|
|
294
|
-
/**
|
|
295
|
-
* Keycloak subject to monitor the events triggered by keycloak-js.
|
|
296
|
-
* The following events as available (as described at keycloak docs -
|
|
297
|
-
* https://www.keycloak.org/docs/latest/securing_apps/index.html#callback-events):
|
|
298
|
-
* - OnAuthError
|
|
299
|
-
* - OnAuthLogout
|
|
300
|
-
* - OnAuthRefreshError
|
|
301
|
-
* - OnAuthRefreshSuccess
|
|
302
|
-
* - OnAuthSuccess
|
|
303
|
-
* - OnReady
|
|
304
|
-
* - OnTokenExpire
|
|
305
|
-
* In each occurrence of any of these, this subject will return the event type,
|
|
306
|
-
* described at {@link KeycloakEventTypeLegacy} enum and the function args from the keycloak-js
|
|
307
|
-
* if provided any.
|
|
308
|
-
*
|
|
309
|
-
* @returns
|
|
310
|
-
* A subject with the {@link KeycloakEventLegacy} which describes the event type and attaches the
|
|
311
|
-
* function args.
|
|
312
|
-
*/
|
|
313
|
-
get keycloakEvents$(): Subject<KeycloakEventLegacy>;
|
|
314
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<KeycloakService, never>;
|
|
315
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<KeycloakService>;
|
|
316
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
import * as i1 from "./core/core.module";
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated NgModules are deprecated in Keycloak Angular and will be removed in future versions.
|
|
5
|
-
* Use the new `provideKeycloak` function to load Keycloak in an Angular application.
|
|
6
|
-
* More info: https://github.com/mauriciovigolo/keycloak-angular/docs/migration-guides/v19.md
|
|
7
|
-
*/
|
|
8
|
-
export declare class KeycloakAngularModule {
|
|
9
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<KeycloakAngularModule, never>;
|
|
10
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<KeycloakAngularModule, never, [typeof i1.CoreModule], never>;
|
|
11
|
-
static ɵinj: i0.ɵɵInjectorDeclaration<KeycloakAngularModule>;
|
|
12
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Mauricio Gemelli Vigolo All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by a MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/blob/main/LICENSE.md
|
|
7
|
-
*/
|
|
8
|
-
export { KeycloakEventLegacy, KeycloakEventTypeLegacy } from './core/interfaces/keycloak-event';
|
|
9
|
-
export { KeycloakOptions } from './core/interfaces/keycloak-options';
|
|
10
|
-
export { KeycloakAuthGuard } from './core/services/keycloak-auth-guard';
|
|
11
|
-
export { KeycloakService } from './core/services/keycloak.service';
|
|
12
|
-
export { KeycloakBearerInterceptor } from './core/interceptors/keycloak-bearer.interceptor';
|
|
13
|
-
export { CoreModule } from './core/core.module';
|
|
14
|
-
export { KeycloakAngularModule } from './keycloak-angular.module';
|