# sso-authorization-oidc-client

> single-signe-on Authorization library for angular

Latest version **3.1.1** (published 2020-09-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install sso-authorization-oidc-client
pnpm add sso-authorization-oidc-client
yarn add sso-authorization-oidc-client
bun add sso-authorization-oidc-client
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.1 |
| Published | 2020-09-08 |
| First published | 2018-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 428.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | avtandil kavrelishvili |
| Maintainers | avto_key |
| Keywords | angular, authorization, oidc-client, identityserver |

## Links

- npm: https://www.npmjs.com/package/sso-authorization-oidc-client
- npm.io page: https://npm.io/package/sso-authorization-oidc-client

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 3.1.1 (latest) — 2020-09-08
- 3.1.0 — 2020-09-08
- 3.0.0 — 2020-09-01
- 2.0.1 — 2019-01-30
- 2.0.0 — 2019-01-25
- 1.0.0 — 2018-11-03
- 0.0.5 — 2018-11-03
- 0.0.4 — 2018-11-03
- 0.0.3 — 2018-11-03
- 0.0.2 — 2018-11-03
- 0.0.1 — 2018-11-03

## README

## Simple Single sign-on Authorization using oidc-client and Identity Server /ავტორიზაცია oidc-client-ის გამოყენებით

angular 6 

Benefits:
1. Built in APP_INITILIZER, when angular application starts, It checks auhtorization.
2. After authorization redirects to start URL. for example: If you aren't authorized and enter to this route http://localhost:4200/test , after authorization redirects same URL
3. Interseptor which checks errors 401 from backend.
4. Automaticaly attach bearer token each request
5. Flexible to use main oidc-client funtions
6. Authomatic SigneOut, when user signe out one site all site which use this library authomiaticaly SigneOut
7. Easy Config management

Library contains/ბიბლიოთეკას მოყვება:  
a. AuthorizationInterceptor - build in auhtorization interseptor, which checks error code 401  /ეს თვითონ მოდულშია ჩაშებული, ამოწმებს 401-ზე და არედირექტებს Identity-ს URL-ზე, რომელიც კონფიგში იქნება გაწერილი.  
b. AuthorizationGuardService - Route guard / პროექტში უნდა route-ებში უნდა გაიწეროს ეს Guard-ი.  
c. AuthorizationService - Usable oidc-client library and custom functions / აქ არის მეთოდები რომელსაც იყენებს მოდული.

### Usage/მოხმარების წესი:
1. Import Library and pass config file. install oidc-client /დააიმპორტეთ ბიბლიოთეკა და გადაეცით კონფიგი, დააინსტალირეთ oidc-client-ი
```javascript
import { AuthorizationModule } from 'sso-authorization-oidc-client';
//OR
import { AuthorizationModule } from 'sso-authorization-oidc-client/src/lib/authorization.module';

@NgModule({
  declarations: [
    AppComponent,
    ....
  ],
  imports: [
    BrowserModule,
    AuthorizationModule.forRoot(`assets/config${environment.production ? '.prod' : ''}.json`)
    .....
  ],
  providers: [
      ...
  ]
  bootstrap: [AppComponent]
})
export class AppModule {}

```
2. Config example /კონფიგი (config.json) უნდა გამოიყურებოდეს ასე:
```json
{
  ....
"authorization": {
    "stsAuthority": "https://demo.identityserver.io/",
    "clientId": "implicit",
    "clientRoot": "http://localhost:4200/",
    "clientScope": "openid profile",
    "responseType": "id_token token",
    "scope": "openid profile",
    "htmlFilePath": "assets",
	"accessTokenExpiringNotificationTime": 100,
	"clockSkew": 500,
	"needAutoLogout": false,
	"autoLogoutTime": 900, //  in seconds
	"checkStorageTime": 10 //  in seconds
  }
  ....
}
```
3. assets folder must contains this .js file with name - "oidc-client.js" /assets უნდა ეგდოს .js ფაილი "oidc-client.js" - რომელიც შეგიძლიათ წამოიღოთ:
https://cdnjs.cloudflare.com/ajax/libs/oidc-client/1.5.2/oidc-client.js

4. assets folder must contains 2 HTML files /assets ფოლდერში (ან შეგიძლიათ შეცვალოთ კონფიგში ფოლდერის სახელი - "htmlFilePath") უნდა არსებობდეს 2 ცალი HTML ფაილი:

      a. signin-callback.html
      ```html
      <script src="oidc-client.js"></script>
      <script>
          new Oidc.UserManager();
        var mgr = new Oidc.UserManager().signinRedirectCallback().then(function (user) {
              window.location.href = user.state;
          }, error => {
              console.error(error);
          });
      </script>
      ```

      b. silent-callback.html
      ```html
      <script src="oidc-client.js"></script>
      <script>
          var mgr = new Oidc.UserManager();
        mgr.signinSilentCallback().catch(error => {
              console.error(error);
          });
      </script>
      ```

---
_Source: https://npm.io/package/sso-authorization-oidc-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
