Skip to content

ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications.

License

Notifications You must be signed in to change notification settings

aitiotekt/oidc-client-rx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo
OIDC-CLIENT-RX
build-status npm-version

ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications.

Quick Start

Choose a reflection lib such as @abraham/reflection or reflect-metadata or core-js/es7/reflect, then install:

pnpm add oidc-client-rx injection-js reflect-metadata
# or npm
npm install oidc-client-rx injection-js reflect-metadata
# or yarn
yarn add oidc-client-rx injection-js reflect-metadata
import 'reflect-metadata'; // or '@abraham/reflection' | 'core-js/es7/reflect'
import { type Injector, ReflectiveInjector } from 'injection-js';
import { LogLevel, OidcSecurityService, provideAuth, withDefaultFeatures } from 'oidc-client-rx';

const injector = ReflectiveInjector.resolveAndCreate(
  provideAuth(
    {
      config: {
        authority: '<your-authority>',
        redirectUrl: `${window.location.origin}/auth/callback`,
        postLogoutRedirectUri: window.location.origin,
        clientId: '<your-client-id>',
        scope: 'openid profile email offline_access',
        responseType: 'code',
        silentRenew: true,
        useRefreshToken: true,
        logLevel: LogLevel.Debug,
        ...
      },
    },
    withDefaultFeatures()
  )
) as Injector;

const oidcSecurityService = injector.get(OidcSecurityService);

oidcSecurityService.checkAuth().subscribe((result) => {
  console.debug('checkAuth result: ', result);
});

const isAuthenticated$ = oidcSecurityService.isAuthenticated$;

More Examples

License

MIT

About

ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published