diff --git a/README.md b/README.md
index 04f133ea..4beeb486 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,6 @@ Support for OAuth 2 and OpenId Connect (OIDC) in Angular. Already prepared for t
- Source Code Documentation: [https://manfredsteyer.github.io/angular-oauth2-oidc/docs](https://manfredsteyer.github.io/angular-oauth2-oidc/docs)
- Community-provided sample implementation: [https://github.com/jeroenheijmans/sample-angular-oauth2-oidc-with-auth-guards/](https://github.com/jeroenheijmans/sample-angular-oauth2-oidc-with-auth-guards/)
-
## Tested Environment
Successfully tested with **Angular 4.3 to Angular 16** and its Router, PathLocationStrategy as well as HashLocationStrategy and CommonJS-Bundling via webpack.
@@ -119,10 +118,9 @@ _redirectUris:_
npm i angular-oauth2-oidc --save
```
-
## Option 1: Standalone APIs
-If you use Standalone Components introduced with Angular 14, you can use our standalone API (call to ``provideOAuthClient``) in your ``main.ts`` to setup the ``OAuthClient``:
+If you use Standalone Components introduced with Angular 14, you can use our standalone API (call to `provideOAuthClient`) in your `main.ts` to setup the `OAuthClient`:
```TypeScript
// main.ts -- Angular 15+ version
@@ -141,7 +139,7 @@ bootstrapApplication(AppComponent, {
});
```
-As Angular 14 does have Standalone Components but no Standalone API for its ``HttpClient``, you need to go with the traditional ``HttpClientModule`` in this version:
+As Angular 14 does have Standalone Components but no Standalone API for its `HttpClient`, you need to go with the traditional `HttpClientModule` in this version:
```TypeScript
// main.ts -- Angular 14 version
@@ -161,7 +159,7 @@ bootstrapApplication(AppComponent, {
});
```
-The ``provideOAuthClient`` function takes the same parameters as the forRoot function of the OAuthModule that is still in place for the sake of compatibility with existing code bases.
+The `provideOAuthClient` function takes the same parameters as the forRoot function of the OAuthModule that is still in place for the sake of compatibility with existing code bases.
## Option 2: Using NgModules
@@ -248,7 +246,7 @@ this.oauthService.loadDiscoveryDocumentAndTryLogin();
### Logging out
-The logOut method clears the used token store (by default ``sessionStorage``) and forwards the user to the auth servers logout endpoint if one was configured (manually or via the discovery document).
+The logOut method clears the used token store (by default `sessionStorage`) and forwards the user to the auth servers logout endpoint if one was configured (manually or via the discovery document).
```typescript
this.oauthService.logOut();
@@ -281,6 +279,22 @@ OAuthModule.forRoot({
If you need more versatility, you can look in the [documentation](https://manfredsteyer.github.io/angular-oauth2-oidc/docs/additional-documentation/working-with-httpinterceptors.html) how to setup a custom interceptor.
+In case you are in a standalone application, you have to use provideHttpClient`with`defaultOAuthInterceptor`.
+
+```Typescript
+bootstrapApplication(App, {
+ providers: [
+ provideOAuthClient({
+ resourceServer: {
+ allowedUrls: ['http://www.angular.at/api'],
+ sendAccessToken: true
+ }
+ }),
+ provideHttpClient(withInterceptors([defaultOAuthInterceptor]))
+ ]
+})
+```
+
## Token Refresh
See docs: https://manfredsteyer.github.io/angular-oauth2-oidc/docs/additional-documentation/refreshing-a-token.html
@@ -297,13 +311,14 @@ Nowadays, using code flow + PKCE -- as shown above -- is the recommended OAuth 2
See the [documentation](https://manfredsteyer.github.io/angular-oauth2-oidc/docs/) for more information about this library.
-
## Breaking Change in Version 9
With regards to tree shaking, beginning with version 9, the `JwksValidationHandler` has been moved to a library of its own. If you need it for implementing **implicit flow**, please install it using npm:
```
+
npm i angular-oauth2-oidc-jwks --save
+
```
After that, you can import it into your application by using this:
@@ -320,8 +335,6 @@ import { JwksValidationHandler } from 'angular-oauth2-oidc';
Please note, that this dependency is not needed for the **code flow**, which is nowadays the **recommended** flow for single page applications. This also results in smaller bundle sizes.
-
-
### Breaking change in 9.1.0
The use of `encodeURIComponent` on the argument passed to `initImplicitFlow` and its Code Flow counterparts was mandatory before this version.
@@ -379,5 +392,3 @@ Now the reverse is true **if you're upgrading from before 9.0.0**: you need to r
[](https://github.com/mabdelaal86)[
](https://github.com/nhance)[
](https://github.com/Razzeee)[
](https://github.com/maxisam)[
](https://github.com/ismcagdas)
[
](https://github.com/Toxicable)[
](https://github.com/ManuelRauber)[
](https://github.com/vdveer)[
](https://github.com/jeroenheijmans)[
](https://github.com/manfredsteyer)
-
-
diff --git a/docs/changelog.html b/docs/changelog.html
index 8dbcfcf4..3589e350 100644
--- a/docs/changelog.html
+++ b/docs/changelog.html
@@ -12,10 +12,61 @@
calcHash(valueToHash: string, algorithm: string)
Calculates the hash for the passed value by using +
Calculates the hash for the passed value by using the passed hash algorithm.
| Name | -Type | -Optional | -
| valueToHash | -
- string
- |
-
- - No - | - - -
| algorithm | -
- string
- |
-
- - No - | - - -
Promise<string>
-
- | Name | +Type | +Optional | +
| valueToHash | +
+ string
+ |
+
+ + No + | + + +
| algorithm | +
+ string
+ |
+
+ + No + | + + +
Promise<string>
+
+ inferHashAlgorithm(jwtHeader: object)
Infers the name of the hash algorithm to use +
Infers the name of the hash algorithm to use from the alg field of an id_token.
| Name | -Type | -Optional | -Description | -
| jwtHeader | -
- object
- |
-
- - No - | - - -
- the id_token's parsed header - - |
-
string
-
- | Name | +Type | +Optional | +Description | +
| jwtHeader | +
+ object
+ |
+
+ + No + | + + +
+ the id_token's parsed header + + |
+
string
+
+ validateAtHash(params: ValidationParams)
Validates the at_hash in an id_token against the received access_token.
+Validates the at_hash in an id_token against the received access_token.
| Name | -Type | -Optional | -
| params | -
- ValidationParams
- |
-
- - No - | - - -
Promise<boolean>
-
- | Name | +Type | +Optional | +
| params | +
+ ValidationParams
+ |
+
+ + No + | + + +
Promise<boolean>
+
+ validateSignature(validationParams: ValidationParams)
Validates the signature of an id_token.
+Validates the signature of an id_token.
| Name | -Type | -Optional | -
| validationParams | -
- ValidationParams
- |
-
- - No - | - - -
Promise<any>
-
- | Name | +Type | +Optional | +
| validationParams | +
+ ValidationParams
+ |
+
+ + No + | + + +
Promise<any>
+
+ | + + + Public + Optional + siletRefreshTimeout + + + | +
| + use silentRefreshTimeout + | +
+ Type : number
+
+ |
+
+ Default value : 1000 * 20
+ |
+
|
+ Defined in projects/lib/src/auth.config.ts:116
+ |
+
|
+ Timeout for silent refresh. + |
+
-
+
new()
|
|
- Defined in projects/lib/src/date-time-provider.ts:5
- |
-
|
+ Defined in projects/lib/src/date-time-provider.ts:5
+ |
+
| - |
- Abstract
+ Abstract
now
@@ -169,27 +220,27 @@
-
+
|
now()
- |
- Defined in projects/lib/src/date-time-provider.ts:4
-
+ |
+ Defined in projects/lib/src/date-time-provider.ts:4
+
-
|
- angular-oauth2-oidc
-
+
+
+
+
+ angular-oauth2-oidc
+
+
@@ -24,7 +75,7 @@
-
+ Properties |
@@ -247,6 +314,124 @@
| + + + Private + inner + + + | +
+ Type : Hash
+
+ |
+
+ Default value : new Hash()
+ |
+
| + + | +
| + + + Private + istate + + + | +
+ Type : Uint32Array
+
+ |
+
| + + | +
| + + + Private + ostate + + + | +
+ Type : Uint32Array
+
+ |
+
| + + | +
| + + + Private + outer + + + | +
+ Type : Hash
+
+ |
+
+ Default value : new Hash()
+ |
+
| + + | +
Uint8Array
+ Uint8Array
- | Name | -Type | -Optional | -
| out | -
- Uint8Array
- |
-
- - No - | - - -
| Name | +Type | +Optional | +
| out | +
+ Uint8Array
+ |
+
+ + No + | + + +
| Name | -Type | -Optional | -
| data | -
- Uint8Array
- |
-
- - No - | - - -
| Name | +Type | +Optional | +
| data | +
+ Uint8Array
+ |
+
+ + No + | + + +
| + + + Private + buffer + + + | +
+ Type : Uint8Array
+
+ |
+
+ Default value : new Uint8Array(128)
+ |
+
| + + | +
| + + + Private + bufferLength + + + | +
+ Type : number
+
+ |
+
+ Default value : 0
+ |
+
| + + | +
| + + + Private + bytesHashed + + + | +
+ Type : number
+
+ |
+
+ Default value : 0
+ |
+
| + + | +
| + + + Private + state + + + | +
+ Type : Int32Array
+
+ |
+
+ Default value : new Int32Array(8)
+ |
+
| + + | +
| + + + Private + temp + + + | +
+ Type : Int32Array
+
+ |
+
+ Default value : new Int32Array(64)
+ |
+
| + + | +
| Name | -Type | -Optional | -
| from | -
- Uint32Array
- |
-
- - No - | - - -
| bytesHashed | -
- number
- |
-
- - No - | - - -
void
-
- | Name | +Type | +Optional | +
| from | +
+ Uint32Array
+ |
+
+ + No + | + + +
| bytesHashed | +
+ number
+ |
+
+ + No + | + + +
void
+
+ | Name | -Type | -Optional | -
| out | -
- Uint32Array
- |
-
- - No - | - - -
void
-
- | Name | +Type | +Optional | +
| out | +
+ Uint32Array
+ |
+
+ + No + | + + +
void
+
+ Uint8Array
+ Uint8Array
- | Name | -Type | -Optional | -
| out | -
- Uint8Array
- |
-
- - No - | - - -
| Name | +Type | +Optional | +
| out | +
+ Uint8Array
+ |
+
+ + No + | + + +
| Name | -Type | -Optional | -Default value | -
| data | -
- Uint8Array
- |
-
- - No - | - -- | - -
| dataLength | -
- number
- |
-
- - No - | - -
- data.length
- |
-
-
| Name | +Type | +Optional | +Default value | +
| data | +
+ Uint8Array
+ |
+
+ + No + | + ++ | + +
| dataLength | +
+ number
+ |
+
+ + No + | + +
+ data.length
+ |
+
+
calcHash(valueToHash: string, algorithm: string)
| Name | -Type | -Optional | -
| valueToHash | -
- string
- |
-
- - No - | - - -
| algorithm | -
- string
- |
-
- - No - | - - -
Promise<string>
-
- | Name | +Type | +Optional | +
| valueToHash | +
+ string
+ |
+
+ + No + | + + +
| algorithm | +
+ string
+ |
+
+ + No + | + + +
Promise<string>
+
+
- NullValidationHandler
+ NullValidationHandler
NullValidationHandler
+ NullValidationHandler
NullValidationHandler:11
+ NullValidationHandler:11
| Name | -Type | -Optional | -
| validationParams | -
- ValidationParams
- |
-
- - No - | - - -
Promise<boolean>
-
- | Name | +Type | +Optional | +
| validationParams | +
+ ValidationParams
+ |
+
+ + No + | + + +
Promise<boolean>
+
+ NullValidationHandler
+ NullValidationHandler
NullValidationHandler:8
+ NullValidationHandler:8
| Name | -Type | -Optional | -
| validationParams | -
- ValidationParams
- |
-
- - No - | - - -
Promise<any>
-
- | Name | +Type | +Optional | +
| validationParams | +
+ ValidationParams
+ |
+
+ + No + | + + +
Promise<any>
+
+ | Name | -Type | -Optional | -
| validationParams | -
- ValidationParams
- |
-
- - No - | - - -
Promise<boolean>
-
- | Name | +Type | +Optional | +
| validationParams | +
+ ValidationParams
+ |
+
+ + No + | + + +
Promise<boolean>
+
+ | Name | -Type | -Optional | -
| validationParams | -
- ValidationParams
- |
-
- - No - | - - -
Promise<any>
-
- | Name | +Type | +Optional | +
| validationParams | +
+ ValidationParams
+ |
+
+ + No + | + + +
Promise<any>
+
+
- OAuthEvent
+ OAuthEvent
- OAuthEvent
+ OAuthEvent
debug(message?: any, ...optionalParams: any[])
| Name | -Type | -Optional | -
| message | -
- any
- |
-
- - Yes - | - - -
| optionalParams | -
- any[]
- |
-
- - No - | - - -
void
-
- | Name | +Type | +Optional | +
| message | +
+ any
+ |
+
+ + Yes + | + + +
| optionalParams | +
+ any[]
+ |
+
+ + No + | + + +
void
+
+ error(message?: any, ...optionalParams: any[])
| Name | -Type | -Optional | -
| message | -
- any
- |
-
- - Yes - | - - -
| optionalParams | -
- any[]
- |
-
- - No - | - - -
void
-
- | Name | +Type | +Optional | +
| message | +
+ any
+ |
+
+ + Yes + | + + +
| optionalParams | +
+ any[]
+ |
+
+ + No + | + + +
void
+
+ info(message?: any, ...optionalParams: any[])
| Name | -Type | -Optional | -
| message | -
- any
- |
-
- - Yes - | - - -
| optionalParams | -
- any[]
- |
-
- - No - | - - -
void
-
- | Name | +Type | +Optional | +
| message | +
+ any
+ |
+
+ + Yes + | + + +
| optionalParams | +
+ any[]
+ |
+
+ + No + | + + +
void
+
+ log(message?: any, ...optionalParams: any[])
| Name | -Type | -Optional | -
| message | -
- any
- |
-
- - Yes - | - - -
| optionalParams | -
- any[]
- |
-
- - No - | - - -
void
-
- | Name | +Type | +Optional | +
| message | +
+ any
+ |
+
+ + Yes + | + + +
| optionalParams | +
+ any[]
+ |
+
+ + No + | + + +
void
+
+ warn(message?: any, ...optionalParams: any[])
| Name | -Type | -Optional | -
| message | -
- any
- |
-
- - Yes - | - - -
| optionalParams | -
- any[]
- |
-
- - No - | - - -
void
-
- | Name | +Type | +Optional | +
| message | +
+ any
+ |
+
+ + Yes + | + + +
| optionalParams | +
+ any[]
+ |
+
+ + No + | + + +
void
+
+ | Name | -Type | -Optional | -
| err | -
- HttpResponse<any>
- |
-
- - No - | - - -
Observable<any>
-
- | Name | +Type | +Optional | +
| err | +
+ HttpResponse<any>
+ |
+
+ + No + | + + +
Observable<any>
+
+ handleError(err: HttpResponse)
| Name | -Type | -Optional | -
| err | -
- HttpResponse<any>
- |
-
- - No - | - - -
Observable<any>
-
- | Name | +Type | +Optional | +
| err | +
+ HttpResponse<any>
+ |
+
+ + No + | + + +
Observable<any>
+
+ getItem(key: string)
| Name | -Type | -Optional | -
| key | -
- string
- |
-
- - No - | - - -
string | null
-
- | Name | +Type | +Optional | +
| key | +
+ string
+ |
+
+ + No + | + + +
string | null
+
+ removeItem(key: string)
| Name | -Type | -Optional | -
| key | -
- string
- |
-
- - No - | - - -
void
-
- | Name | +Type | +Optional | +
| key | +
+ string
+ |
+
+ + No + | + + +
void
+
+ setItem(key: string, data: string)
| Name | -Type | -Optional | -
| key | -
- string
- |
-
- - No - | - - -
| data | -
- string
- |
-
- - No - | - - -
void
-
- | Name | +Type | +Optional | +
| key | +
+ string
+ |
+
+ + No + | + + +
| data | +
+ string
+ |
+
+ + No + | + + +
void
+
+
- OAuthEvent
+ OAuthEvent
validateAtHash(validationParams: ValidationParams)
Validates the at_hash in an id_token against the received access_token.
+Validates the at_hash in an id_token against the received access_token.
| Name | -Type | -Optional | -
| validationParams | -
- ValidationParams
- |
-
- - No - | - - -
Promise<boolean>
-
- | Name | +Type | +Optional | +
| validationParams | +
+ ValidationParams
+ |
+
+ + No + | + + +
Promise<boolean>
+
+ validateSignature(validationParams: ValidationParams)
Validates the signature of an id_token.
+Validates the signature of an id_token.
| Name | -Type | -Optional | -
| validationParams | -
- ValidationParams
- |
-
- - No - | - - -
Promise<any>
-
- | Name | +Type | +Optional | +
| validationParams | +
+ ValidationParams
+ |
+
+ + No + | + + +
Promise<any>
+
+ | Name | -Type | -Optional | -
| k | -
- string
- |
-
- - No - | - - -
string
-
- | Name | +Type | +Optional | +
| k | +
+ string
+ |
+
+ + No + | + + +
string
+
+ | Name | -Type | -Optional | -
| v | -
- string
- |
-
- - No - | - - -
any
-
- | Name | +Type | +Optional | +
| v | +
+ string
+ |
+
+ + No + | + + +
any
+
+ | Name | -Type | -Optional | -
| k | -
- string
- |
-
- - No - | - - -
string
-
- | Name | +Type | +Optional | +
| k | +
+ string
+ |
+
+ + No + | + + +
string
+
+ | Name | -Type | -Optional | -
| v | -
- string
- |
-
- - No - | - - -
string
-
- | Name | +Type | +Optional | +
| v | +
+ string
+ |
+
+ + No + | + + +
string
+
+ Successfully tested with Angular 4.3 to Angular 16 and its Router, PathLocationStrategy as well as HashLocationStrategy and CommonJS-Bundling via webpack.
-At server side we've used IdentityServer (.NET / .NET Core), Redhat's Keycloak (Java), and Auth0 (Auth0 is officially supported since version 10 of this lib). For Auth0, please have a look into the respective documentation page here.
+On the server-side we've used IdentityServer (.NET / .NET Core), Redhat's Keycloak (Java), and Auth0 (Auth0 is officially supported since version 10 of this lib). For Auth0, please have a look into the respective documentation page here.
For using this library with Azure Active Directory (Azure AD), we recommend an additional look to this blog post and the example linked at the end of this blog post.
Also, the Okta community created some guidelines on how to use this lib with Okta. See the links at the end of this page for more information.
+Angular 19: Use 19.x versions of this library (should also work with older Angular versions!).
Angular 18: Use 18.x versions of this library (should also work with older Angular versions!).
Angular 17: Use 17.x versions of this library (should also work with older Angular versions!).
Angular 16: Use 16.x versions of this library (should also work with older Angular versions!).
@@ -82,7 +134,7 @@The issues contain some ideas for PRs and enhancements (see labels)
If you want to contribute to the docs, you can do so in the docs-src folder. Make sure you update summary.json as well. Then generate the docs with the following commands:
npm install -g @compodoc/compodoc
+Example :npm install -g @compodoc/compodoc
npm run docs
Features
@@ -123,9 +175,9 @@ Sample-Auth-Server
localhost:[4200-4202]/silent-refresh.html
Installing
-npm i angular-oauth2-oidc --save
Option 1: Standalone APIs
+Example :npm i angular-oauth2-oidc --save
Option 1: Standalone APIs
If you use Standalone Components introduced with Angular 14, you can use our standalone API (call to provideOAuthClient) in your main.ts to setup the OAuthClient:
-// main.ts -- Angular 15+ version
+Example :// main.ts -- Angular 15+ version
import { bootstrapApplication } from '@angular/platform-browser';
import { provideHttpClient } from '@angular/common/http';
@@ -139,7 +191,7 @@ Installing
provideOAuthClient()
]
});
As Angular 14 does have Standalone Components but no Standalone API for its HttpClient, you need to go with the traditional HttpClientModule in this version:
-// main.ts -- Angular 14 version
+Example :// main.ts -- Angular 14 version
import { bootstrapApplication } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
@@ -155,7 +207,7 @@ Installing
]
});
The provideOAuthClient function takes the same parameters as the forRoot function of the OAuthModule that is still in place for the sake of compatibility with existing code bases.
Option 2: Using NgModules
-import { HttpClientModule } from '@angular/common/http';
+Example :import { HttpClientModule } from '@angular/common/http';
import { OAuthModule } from 'angular-oauth2-oidc';
// etc.
@@ -178,7 +230,7 @@ Option 2: Using NgModules
}
Logging in
Since Version 8, this library supports code flow and PKCE to align with the current draft of the OAuth 2.0 Security Best Current Practice document. This is also the foundation of the upcoming OAuth 2.1.
To configure your solution for code flow + PKCE you have to set the responseType to code:
- import { AuthConfig } from 'angular-oauth2-oidc';
+Example : import { AuthConfig } from 'angular-oauth2-oidc';
export const authCodeFlowConfig: AuthConfig = {
// Url of the Identity Provider
@@ -207,24 +259,35 @@ Option 2: Using NgModules
showDebugInformation: true,
};
After this, you can initialize the code flow using:
-this.oauthService.initCodeFlow();
There is also a convenience method initLoginFlow which initializes either the code flow or the implicit flow depending on your configuration.
-this.oauthService.initLoginFlow();
Also -- as shown in the readme -- you have to execute the following code when bootstrapping to make the library to fetch the token:
-this.oauthService.configure(authCodeFlowConfig);
+Example :this.oauthService.initCodeFlow();
There is also a convenience method initLoginFlow which initializes either the code flow or the implicit flow depending on your configuration.
+Example :this.oauthService.initLoginFlow();
Also -- as shown in the readme -- you have to execute the following code when bootstrapping to make the library to fetch the token:
+Example :this.oauthService.configure(authCodeFlowConfig);
this.oauthService.loadDiscoveryDocumentAndTryLogin();
Logging out
The logOut method clears the used token store (by default sessionStorage) and forwards the user to the auth servers logout endpoint if one was configured (manually or via the discovery document).
-this.oauthService.logOut();
If you want to revoke the existing access token and the existing refresh token before logging out, use the following method:
-this.oauthService.revokeTokenAndLogout();
Skipping the Login Form
+Example :this.oauthService.logOut();
If you want to revoke the existing access token and the existing refresh token before logging out, use the following method:
+Example :this.oauthService.revokeTokenAndLogout();
Skipping the Login Form
If you don't want to display a login form that tells the user that they are redirected to the identity server, you can use the convenience function this.oauthService.loadDiscoveryDocumentAndLogin(); instead of this.oauthService.loadDiscoveryDocumentAndTryLogin(); when setting up the library.
This directly redirects the user to the identity server if there are no valid tokens. Ensure you have your issuer set to your discovery document endpoint!
Calling a Web API with an Access Token
You can automate this task by switching sendAccessToken on and by setting allowedUrls to an array with prefixes for the respective URLs. Use lower case for the prefixes.
-OAuthModule.forRoot({
+Example :OAuthModule.forRoot({
resourceServer: {
allowedUrls: ['http://www.angular.at/api'],
sendAccessToken: true
}
})
If you need more versatility, you can look in the documentation how to setup a custom interceptor.
-Token Refresh
+In case you are in a standalone application, you have to use provideHttpClientwithdefaultOAuthInterceptor`.
+Example :bootstrapApplication(App, {
+ providers: [
+ provideOAuthClient({
+ resourceServer: {
+ allowedUrls: ['http://www.angular.at/api'],
+ sendAccessToken: true
+ }
+ }),
+ provideHttpClient(withInterceptors([defaultOAuthInterceptor]))
+ ]
+})
Token Refresh
Routing
If you use the PathLocationStrategy (which is on by default) and have a general catch-all-route (path: '**') you should be fine. Otherwise look up the section Routing with the HashStrategy in the documentation.
@@ -234,9 +297,11 @@ More Documentation (!)
See the documentation for more information about this library.
Breaking Change in Version 9
With regards to tree shaking, beginning with version 9, the JwksValidationHandler has been moved to a library of its own. If you need it for implementing implicit flow, please install it using npm:
-npm i angular-oauth2-oidc-jwks --save
After that, you can import it into your application by using this:
-import { JwksValidationHandler } from 'angular-oauth2-oidc-jwks';
instead of that:
-import { JwksValidationHandler } from 'angular-oauth2-oidc';
Please note, that this dependency is not needed for the code flow, which is nowadays the recommended flow for single page applications. This also results in smaller bundle sizes.
+Example :
+npm i angular-oauth2-oidc-jwks --save
+
After that, you can import it into your application by using this:
+Example :import { JwksValidationHandler } from 'angular-oauth2-oidc-jwks';
instead of that:
+Example :import { JwksValidationHandler } from 'angular-oauth2-oidc';
Please note, that this dependency is not needed for the code flow, which is nowadays the recommended flow for single page applications. This also results in smaller bundle sizes.
Breaking change in 9.1.0
The use of encodeURIComponent on the argument passed to initImplicitFlow and its Code Flow counterparts was mandatory before this version.
Since that was considered a bug, the need to do so was removed.
@@ -322,6 +387,19 @@
No results matching "
+
+
diff --git a/docs/injectables/DefaultHashHandler.html b/docs/injectables/DefaultHashHandler.html
index 746587c6..4d70c06f 100644
--- a/docs/injectables/DefaultHashHandler.html
+++ b/docs/injectables/DefaultHashHandler.html
@@ -12,10 +12,61 @@
-
-
- angular-oauth2-oidc
-
+
+
+
+
+ angular-oauth2-oidc
+
+
calcHash(valueToHash: string, algorithm: string)
| Name | -Type | -Optional | -
| valueToHash | -
- string
- |
-
- - No - | - - -
| algorithm | -
- string
- |
-
- - No - | - - -
Promise<string>
-
- | Name | +Type | +Optional | +
| valueToHash | +
+ string
+ |
+
+ + No + | + + +
| algorithm | +
+ string
+ |
+
+ + No + | + + +
Promise<string>
+
+ | Name | -Type | -Optional | -
| buffer | -
- ArrayBuffer
- |
-
- - No - | - - -
string
-
- | Name | +Type | +Optional | +
| buffer | +
+ ArrayBuffer
+ |
+
+ + No + | + + +
string
+
+ | Name | -Type | -Optional | -
| byteArray | -
- number[]
- |
-
- - No - | - - -
string
-
- | Name | +Type | +Optional | +
| byteArray | +
+ number[]
+ |
+
+ + No + | + + +
string
+
+
+ Properties+ |
+ ||||||||||||
+
|
+ ||||||||||||
|
@@ -129,53 +195,51 @@ | ||||||||||||
|
- Defined in projects/lib/src/types.ts:107
- |
- ||||||||||||
|
+ Defined in projects/lib/src/types.ts:107
+ |
+ ||||||||||||
|
-
- Parameters :
-
-
-
-
-
- Returns :
- string
-
-
-
-
+
+ Parameters :
+
+
+
+ Returns :
+ string
+
+
+
+
|
||||||||||||
|
- Defined in projects/lib/src/types.ts:111
- |
- ||||||||||||
|
+ Defined in projects/lib/src/types.ts:111
+ |
+ ||||||||||||
|
-
- Parameters :
-
-
-
-
-
- Returns :
- void
-
-
-
-
+
+ Parameters :
+
+
+
+ Returns :
+ void
+
+
+
+
|
||||||||||||
|
+ Defined in projects/lib/src/types.ts:115
+ |
+ ||||||||||||
|
- Defined in projects/lib/src/types.ts:115
+
+
+ Parameters :
+
+
+
+ Returns :
+ void
+
+
+
+
|
|
-
-
- Parameters :
-
-
-
-
-
- Returns :
- void
-
-
-
-
+
+
+ Private
+ data
+
+
|
|||||||||
+ Default value : new Map<string, string>()
+ |
+ |||||||||
|
+ Defined in projects/lib/src/types.ts:105
+ |
+
- AuthConfig
+ AuthConfig
assertUrlNotNullAndCorrectProtocol(url: string | undefined, description: string)
| Name | -Type | -Optional | -||||||||||||
| url | -
- string | undefined
- |
+
| Name | +Type | +Optional | +|
| url | +
+ string | undefined
+ |
- - No - | ++ No + | -
| description | -
- string
- |
+ ||
| description | +
+ string
+ |
- - No - | ++ No + | -
void
+ void
- authorizationHeader()
calcTimeout(storedAt: number, expiration: number)
| Name | -Type | -Optional | -||||||||||||
| storedAt | -
- number
- |
+
| Name | +Type | +Optional | +|
| storedAt | +
+ number
+ |
- - No - | ++ No + | -
| expiration | -
- number
- |
+ ||
| expiration | +
+ number
+ |
- - No - | ++ No + | -
number
+ number
- calculatePopupFeatures(options: literal type)
| Name | -Type | -Optional | -||||||
| options | -
- literal type
- |
+
| Name | +Type | +Optional | +|
| options | +
+ literal type
+ |
- - No - | ++ No + | -
string
+ string
- callOnTokenReceivedIfExists(options: LoginOptions)
| Name | -Type | -Optional | -||||||
| options | -
- LoginOptions
- |
+
| Name | +Type | +Optional | +|
| options | +
+ LoginOptions
+ |
- - No - | ++ No + | -
void
+ void
- canPerformSessionCheck()
checkAtHash(params: ValidationParams)
| Name | +Type | +Optional | +
| params | +
+ ValidationParams
+ |
+
+ + No + | + + +
Promise<boolean>
+ | + + + Private + checkLocalStorageAccessable + + + | +||||||||||||
+
+ checkLocalStorageAccessable()
+ |
+
| Name | -Type | -Optional | -
| params | -
- ValidationParams
- |
- - No - | +
|
+ Defined in projects/lib/src/oauth-service.ts:176
+ |
+
Promise<boolean>
+ boolean
+
+ checkSession()
checkSignature(params: ValidationParams)
| Name | -Type | -Optional | -||||||
| params | -
- ValidationParams
- |
+
| Name | +Type | +Optional | +|
| params | +
+ ValidationParams
+ |
- - No - | ++ No + | -
Promise<any>
+ Promise<any>
- clearAccessTokenTimer()
clearAutomaticRefreshTimer()
clearIdTokenTimer()
void
+
+ | + + + Private + clearLocationHash + + + | +||||||||||||||||||||||||||||||||||||||||||||||||
|
- Defined in projects/lib/src/oauth-service.ts:481
+
+ clearLocationHash()
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
+ Defined in projects/lib/src/oauth-service.ts:2887
+ |
+ ||||||||||||||||||||||||||||||||||||||||||||||||
|
+ Clear location.hash if it's present + |
- Protected
+ Protected
configChanged
@@ -1673,27 +1857,27 @@
-
+
|
configChanged()
- |
- Defined in projects/lib/src/oauth-service.ts:209
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:209
+
-
|
|
- Public
+ Public
configure
@@ -1712,66 +1896,64 @@
-
+
|
configure(config: AuthConfig)
- |
- Defined in projects/lib/src/oauth-service.ts:195
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:195
+
- |
Use this method to configure the service +Use this method to configure the service
- Parameters :
-
-
+
-
-
- Returns : void
+
+
+ Returns :
- void
-
-
-
+
+
+
|
- Protected
- Async
+ Protected
+ Async
createChallangeVerifierPairForPKCE
@@ -1791,27 +1973,27 @@
-
+
|
createChallangeVerifierPairForPKCE()
- |
- Defined in projects/lib/src/oauth-service.ts:2740
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2740
+
- |
- Returns :
Promise<>
+
+ Returns :
+ Promise<>
- |
- Protected
- Async
+ Protected
+ Async
createLoginUrl
@@ -1831,122 +2013,120 @@
-
+
|
createLoginUrl(state: string, loginHint: string, customRedirectUri: string, noPrompt, params: object)
- |
- Defined in projects/lib/src/oauth-service.ts:1481
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:1481
+
- |
- Parameters :
-
-
-
+ Returns : Promise<string>
-
-
-
- Returns :
- Promise<string>
-
-
-
-
+
+
+
+
|
- Protected
+ Protected
createNonce
@@ -1965,27 +2145,27 @@
-
+
|
createNonce()
- |
- Defined in projects/lib/src/oauth-service.ts:2629
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2629
+
- |
- Returns :
Promise<string>
+
+ Returns :
+ Promise<string>
- |
- Protected
+ Protected
debug
@@ -2004,59 +2184,57 @@
-
+
|
debug(...args: any[])
- |
- Defined in projects/lib/src/oauth-service.ts:322
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:322
+
- |
- Parameters :
-
-
+
-
-
- Returns : void
+
+ Returns :
- void
-
-
-
+
+
+
+
| ||||||||||||||||||
| - + - Public - fetchTokenUsingGrant - + Private + extractRecognizedCustomParameters + | ||||||||||||||||||||||||||||||||||||||||||||||||
-
- fetchTokenUsingGrant(grantType: string, parameters: object, headers: HttpHeaders)
+
+ extractRecognizedCustomParameters(tokenResponse: TokenResponse)
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
+ Defined in projects/lib/src/oauth-service.ts:2756
+ |
+ ||||||||||||||||||||||||||||||||||||||||||||||||
|
- Defined in projects/lib/src/oauth-service.ts:841
+
+
+ Parameters :
+
+
+
+ Returns :
+ Map<string, string>
+
+
+
+
|
| + + + Private + fetchAndProcessToken + + + | +|||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+ fetchAndProcessToken(params: HttpParams, options: LoginOptions)
+ |
+ |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
+ Defined in projects/lib/src/oauth-service.ts:1873
+ |
+ |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
- Uses a custom grant type to retrieve tokens. -
- Parameters :
-
-
-
+ Returns : Promise<TokenResponse>
-
- headers |
-
- |
+
+ HttpHeaders
-
+
+
+
+
-
-
- Returns : Promise<TokenResponse>
+
+ |
Uses a custom grant type to retrieve tokens. +
+ Parameters :
+
+
+
+ Returns :
- Promise<TokenResponse>
-
-
-
+
+
+
+
|
- Public
+ Public
fetchTokenUsingPasswordFlow
@@ -2193,102 +2519,100 @@
-
+
|
fetchTokenUsingPasswordFlow(userName: string, password: string, headers: HttpHeaders)
- |
- Defined in projects/lib/src/oauth-service.ts:823
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:823
+
- |
Uses password flow to exchange userName and password for an access_token. -
- Parameters :
-
-
-
-
-
- Returns :
+ Promise<TokenResponse>
+ Uses password flow to exchange userName and password for an access_token. +
+ Parameters :
+
+
+
+ Returns :
- Promise<TokenResponse>
-
-
-
+
+
+
|
- Public
+ Public
fetchTokenUsingPasswordFlowAndLoadUserProfile
@@ -2307,108 +2631,106 @@
-
+
|
fetchTokenUsingPasswordFlowAndLoadUserProfile(userName: string, password: string, headers: HttpHeaders)
- |
- Defined in projects/lib/src/oauth-service.ts:724
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:724
+
- |
Uses password flow to exchange userName and password for an + Uses password flow to exchange userName and password for an access_token. After receiving the access_token, this method uses it to query the userinfo endpoint in order to get information about the user in question. When using this, make sure that the property oidc is set to false. -Otherwise stricter validations take place that make this operation +Otherwise, stricter validations take place that make this operation fail.
- Parameters :
-
-
-
-
-
- Returns :
+ Promise<object>
+
+ Parameters :
+
+
+
+ Returns :
- Promise<object>
-
-
-
+
+
+
|
- Public
+ Public
getAccessToken
@@ -2427,29 +2749,29 @@
-
+
|
getAccessToken()
- |
- Defined in projects/lib/src/oauth-service.ts:2378
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2378
+
- |
|
- Public
+ Public
getAccessTokenExpiration
@@ -2468,30 +2790,30 @@
-
+
|
getAccessTokenExpiration()
- |
- Defined in projects/lib/src/oauth-service.ts:2390
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2390
+
- |
|
- Protected
+ Protected
getAccessTokenStoredAt
@@ -2510,27 +2832,100 @@
-
+
|
getAccessTokenStoredAt()
+ |
+ Defined in projects/lib/src/oauth-service.ts:2397
+
+
+ |
+
+ Returns :
+ number
+
+ |
|
- Defined in projects/lib/src/oauth-service.ts:2397
+
+
+ Private
+ getClockSkewInMsec
+
+
|
||||||
+
+ getClockSkewInMsec(defaultSkewMsc: number)
+ |
+ ||||||
|
+ Defined in projects/lib/src/oauth-service.ts:2155
+ |
+ ||||||
| - | ||||||
| - + - Public - getCustomTokenResponseProperty - + Private + getCodePartsFromUrl + | ||||||
-
- getCustomTokenResponseProperty(requestedProperty: string)
+
+ getCodePartsFromUrl(queryString: string)
|
||||||
|
+ Defined in projects/lib/src/oauth-service.ts:1826
+ |
+ ||||||
|
+ Retrieve the returned auth code from the redirect uri that has been called. +If required also check hash, as we could use hash location strategy. +
+ Parameters :
+
+
+
+ Returns :
+ object
+
+
+
+
+ |
+
| + + + Public + getCustomTokenResponseProperty + + + | +||||||||||||
|
- Defined in projects/lib/src/oauth-service.ts:2462
+
+ getCustomTokenResponseProperty(requestedProperty: string)
|
||||||||||||
|
+ Defined in projects/lib/src/oauth-service.ts:2462
+ |
+ ||||||||||||
|
- Retrieve a saved custom property of the TokenReponse object. Only if predefined in authconfig. +Retrieve a saved custom property of the TokenReponse object. Only if predefined in authconfig.
- Parameters :
-
-
+
-
-
- Returns : any
+
+ Returns :
- any
-
-
-
+
+
+
|
- Public
+ Public
getGrantedScopes
@@ -2622,29 +3087,29 @@
-
+
|
getGrantedScopes()
- |
- Defined in projects/lib/src/oauth-service.ts:2353
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2353
+
- |
|
- Public
+ Public
getIdentityClaims
@@ -2663,29 +3128,29 @@
-
+
|
getIdentityClaims()
- |
- Defined in projects/lib/src/oauth-service.ts:2342
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2342
+
- |
Returns the received claims about the user. +Returns the received claims about the user.
- Returns :
Record<string, any>
+
+ Returns :
+ Record<string, any>
- |
- Public
+ Public
getIdToken
@@ -2704,29 +3169,29 @@
-
+
|
getIdToken()
- |
- Defined in projects/lib/src/oauth-service.ts:2364
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2364
+
- |
|
- Public
+ Public
getIdTokenExpiration
@@ -2745,30 +3210,30 @@
-
+
|
getIdTokenExpiration()
- |
- Defined in projects/lib/src/oauth-service.ts:2409
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2409
+
- |
|
- Protected
+ Protected
getIdTokenStoredAt
@@ -2787,27 +3252,27 @@
-
+
|
getIdTokenStoredAt()
- |
- Defined in projects/lib/src/oauth-service.ts:2401
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2401
+
-
|
|
- Public
+ Public
getRefreshToken
@@ -2826,27 +3291,27 @@
-
+
|
getRefreshToken()
- |
- Defined in projects/lib/src/oauth-service.ts:2382
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2382
+
-
|
|
- Protected
+ Protected
getSessionState
@@ -2865,27 +3330,110 @@
-
+
|
getSessionState()
+ |
+ Defined in projects/lib/src/oauth-service.ts:2142
+
+
+ |
+
+ Returns :
+ string
+
+ |
|
- Defined in projects/lib/src/oauth-service.ts:2142
+
+
+ Private
+ getTokenFromCode
+
+
+ |
+ ||||||||||||||||||||||||||||||||||||||||
+
+ getTokenFromCode(code: string, options: LoginOptions)
|
||||||||||||||||||||||||||||||||||||||||
|
+ Defined in projects/lib/src/oauth-service.ts:1842
+ |
+ ||||||||||||||||||||||||||||||||||||||||
|
+ Get token using an intermediate code. Works for the Authorization Code flow. +
+ Parameters :
+
+
+
+ Returns :
+
+ Promise<object>
-
+
+
|
- Protected
+ Protected
handleLoginError
@@ -2904,71 +3452,69 @@
-
+
|
handleLoginError(options: LoginOptions, parts: object)
- |
- Defined in projects/lib/src/oauth-service.ts:2146
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2146
+
- |
- Parameters :
-
-
+
-
-
- Returns : void
+
+ Returns :
- void
-
-
-
+
+
+
+
|
- Protected
+ Protected
handleSessionChange
@@ -2987,27 +3533,27 @@
-
+
|
handleSessionChange()
- |
- Defined in projects/lib/src/oauth-service.ts:1360
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:1360
+
-
|
|
- Protected
+ Protected
handleSessionError
@@ -3026,27 +3572,27 @@
-
+
|
handleSessionError()
- |
- Defined in projects/lib/src/oauth-service.ts:1405
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:1405
+
-
|
|
- Protected
+ Protected
handleSessionUnchanged
@@ -3065,27 +3611,27 @@
-
+
|
handleSessionUnchanged()
- |
- Defined in projects/lib/src/oauth-service.ts:1355
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:1355
+
-
|
|
- Public
+ Public
hasValidAccessToken
@@ -3104,29 +3650,29 @@
-
+
|
hasValidAccessToken()
- |
- Defined in projects/lib/src/oauth-service.ts:2420
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2420
+
- |
|
- Public
+ Public
hasValidIdToken
@@ -3145,29 +3691,29 @@
-
+
|
hasValidIdToken()
- |
- Defined in projects/lib/src/oauth-service.ts:2441
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2441
+
- |
|
- Public
+ Public
initCodeFlow
@@ -3186,81 +3732,167 @@
-
+
|
initCodeFlow(additionalState: string, params: object)
- |
- Defined in projects/lib/src/oauth-service.ts:2707
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2707
+
- |
Starts the authorization code flow and redirects to user to + Starts the authorization code flow and redirects to user to the auth servers login url.
- Parameters :
-
-
-
+ Returns :
+ void
-
- No
- |
+
+
+
+
+
-
-
- Returns :
+ void
+
+ Parameters :
+
+
+
+ Returns :
- void
-
-
-
+
+
+
|
- Public
+ Public
initImplicitFlow
@@ -3279,94 +3911,92 @@
-
+
|
initImplicitFlow(additionalState: string, params: string | object)
- |
- Defined in projects/lib/src/oauth-service.ts:1635
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:1635
+
- |
Starts the implicit flow and redirects to user to + Starts the implicit flow and redirects to user to the auth servers' login url. You'll find this state in the property
- Parameters :
-
-
+
+ Returns :
- void
-
-
-
+
+
+
|
- Public
+ Public
initImplicitFlowInPopup
@@ -3385,63 +4015,61 @@
-
+
|
initImplicitFlowInPopup(options?: literal type)
- |
- Defined in projects/lib/src/oauth-service.ts:1136
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:1136
+
- |
This method exists for backwards compatibility. + This method exists for backwards compatibility. OAuthService handles both code and implicit flows.
- Parameters :
-
-
-
-
-
- Returns :
+ any
+
+ Parameters :
+
+
+
+ Returns :
- any
-
-
-
+
+
+
- |
- Defined in projects/lib/src/oauth-service.ts:1593
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:1593
+
- |
- Parameters :
-
-
-
-
-
- Returns :
+ void
+
+ Parameters :
+
+
+
+ Returns :
- void
-
-
-
+
+
+
-
+
|
initLoginFlow(additionalState: string, params: object)
- |
- Defined in projects/lib/src/oauth-service.ts:2695
-
+ |
+ Defined in projects/lib/src/oauth-service.ts:2695
+
- |
Start the implicit flow or the code flow, + Start the implicit flow or the code flow, depending on your configuration.
- Parameters :
-
-
-
-
-
- Returns :
+ void
+
+ Parameters :
+
+
+
+ Returns :
- void
-
-
-
+
+
+
|
initLoginFlowInPopup(options?: literal type)
| Name | -Type | -Optional | -
| options | -
- literal type
- |
+