KeycloakService
Defined in: services/auth.service.ts:23
Service for handling Keycloak sessions
Constructors
Constructor
new KeycloakService(): KeycloakService;Returns
KeycloakService
Methods
forceUpdateAccessToken()
forceUpdateAccessToken(httpHeaders?): Observable<KeycloakTokensResponse>;Defined in: services/auth.service.ts:366
Force the Access Token update. Can also take additional HTTP Headers.
Parameters
| Parameter | Type | Description |
|---|---|---|
httpHeaders? | HttpHeaders | Additionals for the HTTP Request (Header- and/or Body-Additions) |
Returns
Observable<KeycloakTokensResponse>
Keycloak Tokens as Observable
Since
1.0.0
Author
Simon Kovtyk
hasAccessTokenAllowedOrigin()
hasAccessTokenAllowedOrigin(allowedOrigin): boolean;Defined in: services/auth.service.ts:417
Check if an explicit allowed origin is in the Access Token
Parameters
| Parameter | Type | Description |
|---|---|---|
allowedOrigin | string | The allowedOrigin to check |
Returns
boolean
true, if the allowedOrigin exists, otherwise false
Since
1.0.0
Author
Simon Kovtyk
hasAccessTokenAud()
hasAccessTokenAud(aud): boolean;Defined in: services/auth.service.ts:433
Check if an aud is in the Access Token
Parameters
| Parameter | Type | Description |
|---|---|---|
aud | string | aud to check |
Returns
boolean
true, if the aud exists, otherwise false
Since
1.0.0
Author
Simon Kovtyk
hasAccessTokenRealmAccess()
hasAccessTokenRealmAccess(realmAccess): boolean;Defined in: services/auth.service.ts:449
Check if an explicit realmAccess is in the Access Token
Parameters
| Parameter | Type | Description |
|---|---|---|
realmAccess | string | The realmAccess to check |
Returns
boolean
true, if the realmAccess exists, otherwise false
Since
1.0.0
Author
Simon Kovtyk
hasAccessTokenResourceAccess()
hasAccessTokenResourceAccess(key, resourceAccess): boolean;Defined in: services/auth.service.ts:466
Check if an resourceAccess is in the Access Token
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The key to resolve the resourceAccess |
resourceAccess | string | The resourceAccess to check |
Returns
boolean
true, if the resourceAccess exists, otherwise false
Since
1.0.0
Author
Simon Kovtyk
isAccessTokenValid()
isAccessTokenValid(): boolean;Defined in: services/auth.service.ts:230
Checks if the current access token is valid
Returns
boolean
The state of the access token validity
Since
1.0.0
Author
Simon Kovtyk
isAuthorized()
isAuthorized(): boolean;Defined in: services/auth.service.ts:60
Checks if a user is authorized by checking the state of the called workflow
Returns
boolean
The current status of the potential authorization
Author
Simon Kovtyk
Since
1.0.0
isAuthorized$()
isAuthorized$(): Observable<boolean>;Defined in: services/auth.service.ts:71
Checks if a user is authorized by checking the state of the called workflow
Returns
Observable<boolean>
An observable with the status of the potential authorization
Author
Simon Kovtyk
Since
1.0.0
isRefreshTokenValid()
isRefreshTokenValid(): boolean;Defined in: services/auth.service.ts:209
Checks if the current refresh token is valid
Returns
boolean
The state of the refresh token validity
Since
1.0.0
Author
Simon Kovtyk
login()
login(
email,
password,
autoStartInterval?,
httpHeaders?): Observable<KeycloakTokensResponse>;Defined in: services/auth.service.ts:254
Creating sessions by email and password. Can also take additional HTTP Headers.
Parameters
| Parameter | Type | Description |
|---|---|---|
email | string | Email that the user uses |
password | string | Password the users uses |
autoStartInterval? | boolean | - |
httpHeaders? | HttpHeaders | Additionals for the HTTP Request (Header- and/or Body-Additions) |
Returns
Observable<KeycloakTokensResponse>
Tokens as Observable
Since
1.0.0
Author
Simon Kovtyk
logout()
logout(httpHeaders?): Observable<void>;Defined in: services/auth.service.ts:303
Revoke sessions by logged in user
Parameters
| Parameter | Type | Description |
|---|---|---|
httpHeaders? | HttpHeaders | Additionals for the HTTP Request (Header- and/or Body-Additions) |
Returns
Observable<void>
An observable that completes when the logout is done
Since
1.0.0
Author
Simon Kovtyk
revokeAccessToken()
revokeAccessToken(overwriteAccessToken?): Observable<void>;Defined in: services/auth.service.ts:194
Revoke Access Token
Parameters
| Parameter | Type | Description |
|---|---|---|
overwriteAccessToken? | string | Overwrite the Access Token, that should be revoked. |
Returns
Observable<void>
An Observable that completes when the access token has been revoked
See
https://datatracker.ietf.org/doc/html/rfc7009
Since
1.0.0
Author
Simon Kovtyk
revokeRefreshToken()
revokeRefreshToken(overwriteRefreshToken?): Observable<void>;Defined in: services/auth.service.ts:177
Revoke Refresh Token
Parameters
| Parameter | Type | Description |
|---|---|---|
overwriteRefreshToken? | string | Overwrite the Refresh Token, that should be revoked. |
Returns
Observable<void>
Observable that completes when the token has been revoked
See
https://datatracker.ietf.org/doc/html/rfc7009
Since
1.0.0
Author
Simon Kovtyk
setAuthorized()
setAuthorized(isAuthorized): void;Defined in: services/auth.service.ts:82
Setter for setting the authorization of
Parameters
| Parameter | Type | Description |
|---|---|---|
isAuthorized | boolean | Determine if the user is authorized |
Returns
void
Author
Simon Kovtyk
Since
1.0.0
startAccessTokenUpdate()
startAccessTokenUpdate(httpHeaders?): void;Defined in: services/auth.service.ts:338
Initializing the Access Token refresh procedure after the remaining TTL of the existing Access Token is reached
Parameters
| Parameter | Type | Description |
|---|---|---|
httpHeaders? | HttpHeaders | Additionals for the HTTP Request (Header- and/or Body-Additions) |
Returns
void
Since
1.0.0
Author
Simon Kovtyk
stopAccessTokenUpdate()
stopAccessTokenUpdate(): void;Defined in: services/auth.service.ts:353
Removing the Access Token refresh procedure
Returns
void
Remarks
Gets called after successfull KeycloakService.logout().
Since
1.0.0
Author
Simon Kovtyk
validateCredentials()
validateCredentials(
email,
password,
httpOptions?): Observable<void>;Defined in: services/auth.service.ts:382
Validate user Credentials by creating a new Session and mark the newly created Session as invalid.
Parameters
| Parameter | Type | Description |
|---|---|---|
email | string | The email as partial credential |
password | string | The password as partial credential |
httpOptions? | HttpOptions<never, HttpHeadersOption, HttpParamsOption> | Additionals for the HTTP Request (Header- and/or Body-Additions) |
Returns
Observable<void>
An observable that completes when the credentials have been validated
Since
1.0.0
Author
Simon Kovtyk