From a1bf073e6e0c5c7d2ab863fc3be11587c054ebac Mon Sep 17 00:00:00 2001 From: Nicolas Frizzarin Date: Wed, 19 Mar 2025 14:05:21 +0100 Subject: [PATCH] refactor(lib): use defaultInterceptor function instead the DefaultInterceptor Class --- README.md | 33 +- docs/changelog.html | 74 +- docs/classes/AbstractValidationHandler.html | 462 +- docs/classes/AuthConfig.html | 123 +- docs/classes/DateTimeProvider.html | 118 +- docs/classes/HMAC.html | 392 +- docs/classes/Hash.html | 662 +- docs/classes/HashHandler.html | 184 +- docs/classes/JwksValidationHandler.html | 256 +- docs/classes/LoginOptions.html | 74 +- docs/classes/NullValidationHandler.html | 238 +- docs/classes/OAuthErrorEvent.html | 76 +- docs/classes/OAuthEvent.html | 74 +- docs/classes/OAuthInfoEvent.html | 76 +- docs/classes/OAuthLogger.html | 624 +- docs/classes/OAuthModuleConfig.html | 74 +- .../OAuthNoopResourceServerErrorHandler.html | 156 +- docs/classes/OAuthResourceServerConfig.html | 74 +- .../OAuthResourceServerErrorHandler.html | 160 +- docs/classes/OAuthStorage.html | 356 +- docs/classes/OAuthSuccessEvent.html | 76 +- docs/classes/ReceivedTokens.html | 74 +- docs/classes/ValidationHandler.html | 254 +- docs/classes/WebHttpUrlEncodingCodec.html | 402 +- docs/coverage.html | 344 +- docs/dependencies.html | 102 +- docs/images/coverage-badge-documentation.svg | 2 +- docs/index.html | 122 +- docs/injectables/DefaultHashHandler.html | 348 +- docs/injectables/MemoryStorage.html | 389 +- docs/injectables/OAuthService.html | 6533 ++++++++++------- docs/injectables/SystemDateTimeProvider.html | 128 +- docs/injectables/UrlHelperService.html | 246 +- .../interceptors/DefaultOAuthInterceptor.html | 385 +- docs/interfaces/OidcDiscoveryDoc.html | 74 +- docs/interfaces/ParsedIdToken.html | 74 +- docs/interfaces/TokenResponse.html | 74 +- docs/interfaces/UserInfo.html | 74 +- docs/interfaces/ValidationParams.html | 74 +- docs/js/libs/bootstrap-native.js | 3 +- docs/js/libs/es6-shim.min.js | 21 +- docs/js/libs/tablesort.min.js | 6 +- docs/js/libs/tablesort.number.min.js | 4 +- docs/js/libs/vis.min.js | 2 +- docs/js/menu-wc.js | 104 +- docs/js/menu-wc_es5.js | 40 +- docs/js/menu.js | 55 - docs/js/search/search.js | 127 +- docs/js/search/search_index.js | 4 +- docs/license.html | 74 +- docs/miscellaneous/functions.html | 1177 +-- docs/miscellaneous/typealiases.html | 74 +- docs/miscellaneous/variables.html | 74 +- docs/modules.html | 74 +- docs/modules/OAuthModule.html | 196 +- docs/overview.html | 74 +- docs/properties.html | 76 +- docs/styles/compodoc.css | 19 +- .../interceptors/default-oauth.interceptor.ts | 166 +- projects/lib/src/oauth-service.ts | 4 +- .../quickstart-demo/src/app/app.module.ts | 9 +- projects/sample/src/app/app.module.ts | 17 +- 62 files changed, 10417 insertions(+), 6044 deletions(-) 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 [mabdelaal86](https://github.com/mabdelaal86)[nhance](https://github.com/nhance)[Razzeee](https://github.com/Razzeee)[maxisam](https://github.com/maxisam)[ismcagdas](https://github.com/ismcagdas) [Toxicable](https://github.com/Toxicable)[ManuelRauber](https://github.com/ManuelRauber)[vdveer](https://github.com/vdveer)[jeroenheijmans](https://github.com/jeroenheijmans)[manfredsteyer](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 @@ - -