docs: first add docs and license
This commit is contained in:
parent
6a03a2bd62
commit
eacbbb2815
3
.gitignore
vendored
3
.gitignore
vendored
@ -32,7 +32,6 @@ speed-measure-plugin*.json
|
||||
.history/*
|
||||
|
||||
# misc
|
||||
/.angular/cache
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage
|
||||
@ -55,4 +54,4 @@ debug.log
|
||||
/playwright-report/
|
||||
/blob-report/
|
||||
/playwright/.cache/
|
||||
/.vitest
|
||||
/.vitest
|
||||
|
212
README.md
212
README.md
@ -1,209 +1,17 @@
|
||||
# Angular Lib for OpenID Connect & OAuth2
|
||||
<h1 align="center">
|
||||
<img src="./assets/logo-512.png" height="150" alt="OUTPOSTS">
|
||||
<div style="color: #232848; font-weight: 700;">OIDC-CLIENT-RX</div>
|
||||
<div align="center">
|
||||
<img src="https://img.shields.io/badge/status-work--in--progress-blue" alt="status-badge" />
|
||||
</div>
|
||||
</h1>
|
||||
|
||||
TODO
|
||||
<p align="center">ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications.</p>
|
||||
|
||||
 [](https://www.npmjs.com/package/oidc-client-rx) [](https://www.npmjs.com/package/oidc-client-rx) [](https://www.npmjs.com/package/oidc-client-rx) [](https://github.com/prettier/prettier) [](https://coveralls.io/github/damienbod/oidc-client-rx?branch=main)
|
||||
## Quick Start
|
||||
|
||||
<p align="center">
|
||||
<a href="https://oidc-client-rx.com/"><img src="https://raw.githubusercontent.com/damienbod/oidc-client-rx/main/.github/angular-auth-logo.png" alt="" width="350" /></a>
|
||||
</p>
|
||||
|
||||
Secure your Angular app using the latest standards for OpenID Connect & OAuth2. Provides support for token refresh, all modern OIDC Identity Providers and more.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
This library is <a href="http://openid.net/certification/#RPs">certified</a> by OpenID Foundation. (RP Implicit and Config RP)
|
||||
|
||||
<p align="center">
|
||||
<a href="http://openid.net/certification/#RPs"><img src="https://damienbod.files.wordpress.com/2017/06/oid-l-certification-mark-l-rgb-150dpi-90mm.png" alt="" width="400" /></a>
|
||||
</p>
|
||||
|
||||
## Features
|
||||
|
||||
- [Code samples](https://oidc-client-rx.com/docs/samples/) for most of the common use cases
|
||||
- Supports schematics via `ng add` support
|
||||
- Supports all modern OIDC identity providers
|
||||
- Supports OpenID Connect Code Flow with PKCE
|
||||
- Supports Code Flow PKCE with Refresh tokens
|
||||
- [Supports OpenID Connect Implicit Flow](http://openid.net/specs/openid-connect-implicit-1_0.html)
|
||||
- [Supports OpenID Connect Session Management 1.0](http://openid.net/specs/openid-connect-session-1_0.html)
|
||||
- [Supports RFC7009 - OAuth 2.0 Token Revocation](https://tools.ietf.org/html/rfc7009)
|
||||
- [Supports RFC7636 - Proof Key for Code Exchange (PKCE)](https://tools.ietf.org/html/rfc7636)
|
||||
- [Supports OAuth 2.0 Pushed authorisation requests (PAR) draft](https://tools.ietf.org/html/draft-ietf-oauth-par-06)
|
||||
- Semantic releases
|
||||
- Github actions
|
||||
- Modern coding guidelines with prettier, husky
|
||||
- Up to date documentation
|
||||
- Implements OIDC validation as specified, complete client side validation for REQUIRED features
|
||||
- Supports authentication using redirect or popup
|
||||
|
||||
## Installation
|
||||
|
||||
### Ng Add
|
||||
|
||||
You can use the schematics and `ng add` the library.
|
||||
|
||||
```shell
|
||||
ng add oidc-client-rx
|
||||
```
|
||||
|
||||
And answer the questions. A module will be created which encapsulates your configuration.
|
||||
|
||||

|
||||
|
||||
### Npm / Yarn
|
||||
|
||||
Navigate to the level of your `package.json` and type
|
||||
|
||||
```shell
|
||||
npm install oidc-client-rx
|
||||
```
|
||||
|
||||
or with yarn
|
||||
|
||||
```shell
|
||||
yarn add oidc-client-rx
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
[Read the docs here](https://oidc-client-rx.com/)
|
||||
|
||||
## Samples
|
||||
|
||||
[Explore the Samples here](https://oidc-client-rx.com/docs/samples/)
|
||||
|
||||
## Quickstart
|
||||
|
||||
For the example of the Code Flow. For further examples please check the [Samples](https://oidc-client-rx.com/docs/samples/) Section.
|
||||
|
||||
> If you have done the installation with the schematics, these modules and files should be available already!
|
||||
|
||||
### Configuration
|
||||
|
||||
Import the `AuthModule` in your module.
|
||||
|
||||
```ts
|
||||
import { NgModule } from '@angular/core';
|
||||
import { AuthModule, LogLevel } from 'oidc-client-rx';
|
||||
// ...
|
||||
|
||||
@NgModule({
|
||||
// ...
|
||||
imports: [
|
||||
// ...
|
||||
AuthModule.forRoot({
|
||||
config: {
|
||||
authority: '<your authority address here>',
|
||||
redirectUrl: window.location.origin,
|
||||
postLogoutRedirectUri: window.location.origin,
|
||||
clientId: '<your clientId>',
|
||||
scope: 'openid profile email offline_access',
|
||||
responseType: 'code',
|
||||
silentRenew: true,
|
||||
useRefreshToken: true,
|
||||
logLevel: LogLevel.Debug,
|
||||
},
|
||||
}),
|
||||
],
|
||||
// ...
|
||||
})
|
||||
export class AppModule {}
|
||||
```
|
||||
|
||||
And call the method `checkAuth()` from your `app.component.ts`. The method `checkAuth()` is needed to process the redirect from your Security Token Service and set the correct states. This method must be used to ensure the correct functioning of the library.
|
||||
|
||||
```ts
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { OidcSecurityService } from 'oidc-client-rx';
|
||||
|
||||
@Component({
|
||||
/*...*/
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
private readonly oidcSecurityService = inject(OidcSecurityService);
|
||||
|
||||
ngOnInit() {
|
||||
this.oidcSecurityService
|
||||
.checkAuth()
|
||||
.subscribe((loginResponse: LoginResponse) => {
|
||||
const { isAuthenticated, userData, accessToken, idToken, configId } =
|
||||
loginResponse;
|
||||
|
||||
/*...*/
|
||||
});
|
||||
}
|
||||
|
||||
login() {
|
||||
this.oidcSecurityService.authorize().subscribe();
|
||||
}
|
||||
|
||||
logout() {
|
||||
this.oidcSecurityService
|
||||
.logoff()
|
||||
.subscribe((result) => console.log(result));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Using the access token
|
||||
|
||||
You can get the access token by calling the method `getAccessToken()` on the `OidcSecurityService`
|
||||
|
||||
```ts
|
||||
const token = this.oidcSecurityService.getAccessToken().subscribe(...);
|
||||
```
|
||||
|
||||
And then you can use it in the HttpHeaders
|
||||
|
||||
```ts
|
||||
import { HttpHeaders } from '@ngify/http';
|
||||
|
||||
const token = this.oidcSecurityServices.getAccessToken().subscribe((token) => {
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({
|
||||
Authorization: 'Bearer ' + token,
|
||||
}),
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
You can use the built in interceptor to add the accesstokens to your request
|
||||
|
||||
```ts
|
||||
AuthModule.forRoot({
|
||||
config: {
|
||||
// ...
|
||||
secureRoutes: ['https://my-secure-url.com/', 'https://my-second-secure-url.com/'],
|
||||
},
|
||||
}),
|
||||
```
|
||||
|
||||
```ts
|
||||
providers: [
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
|
||||
],
|
||||
```
|
||||
|
||||
## Versions
|
||||
|
||||
Current Version is Version 19.x
|
||||
|
||||
- [Info about Version 18](https://github.com/damienbod/oidc-client-rx/tree/version-18)
|
||||
- [Info about Version 17](https://github.com/damienbod/oidc-client-rx/tree/version-17)
|
||||
- [Info about Version 16](https://github.com/damienbod/oidc-client-rx/tree/version-16)
|
||||
- [Info about Version 15](https://github.com/damienbod/oidc-client-rx/tree/version-15)
|
||||
- [Info about Version 14](https://github.com/damienbod/oidc-client-rx/tree/version-14)
|
||||
- [Info about Version 13](https://github.com/damienbod/oidc-client-rx/tree/version-13)
|
||||
- [Info about Version 12](https://github.com/damienbod/oidc-client-rx/tree/version-12)
|
||||
- [Info about Version 11](https://github.com/damienbod/oidc-client-rx/tree/version-11)
|
||||
- [Info about Version 10](https://github.com/damienbod/oidc-client-rx/tree/version-10)
|
||||
@TODO Coming Soon
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://choosealicense.com/licenses/mit/)
|
||||
|
||||
## Authors
|
||||
|
||||
- [@DamienBod](https://www.github.com/damienbod)
|
||||
- [@FabianGosebrink](https://www.github.com/FabianGosebrink)
|
||||
|
BIN
assets/logo-512.png
Normal file
BIN
assets/logo-512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
21
licenses/angular-auth-oidc-client.LICENSE
Normal file
21
licenses/angular-auth-oidc-client.LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 damienbod
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
21
licenses/angular.LICENSE
Normal file
21
licenses/angular.LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2010-2025 Google LLC. https://angular.dev/license
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
@ -1,5 +1,7 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
// TODO
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
|
Loading…
Reference in New Issue
Block a user