@odx/auth
TypeScript icon, indicating that this package has built-in type declarations

13.1.0 • Public • Published

@odx/auth

Install 🚀

npm install @odx/auth

Library structure

  • @odx/auth: main entry point
    • provideAuth: Main provider factory to enable authentication for an Angular application
    • AuthModule: Angular module which bundles all components and directives for the UI
    • AuthService: Service to perform different tasks regarding authentication and authorization
    • authGuard: Angular guard to protect routes that require authentication or authorization
    • unauthGuard: Angular guard to protect routes that don't require authentication or authorization
    • ...
  • @odx/auth/plugins/service-connect: main entry point for service connect auth plugins
    • serviceConnectRightsPlugin: Auth plugin to load user rights from service connect
    • serviceConnectRightsGuard: Auth guard to check for service connect user rights
    • ServiceConnectRightsDirective: Auth directive to check for service connect user rights
    • ...

Usage

Import the AuthModule from @odx/auth and add it to the application imports, to configure it use the provideAuth function.

provideAuth({
  environment: 'dev',
  clientId: '<oktaClientId>',
});

The configuration object has the following interface:

interface AuthConfig {
  environment: AuthEnvironment;
  clientId: string;
  issuer?: string;
  redirectPath: string;
  allowedUrls: Array<string | RegExp>;
  timeoutFactor: number;
  maxOfflineTime: number;
  loadUserProfile: boolean;
  postLogoutRedirectUrl?: string;
  scopes?: string[];
  discoveryUrl?: string;
  errorHandler: AuthErrorHandlerFn;
  createInitials: CreateInitialsFn;
  resolveEmail: ResolveEmailFn;
  resolveUsername: ResolveUsernameFn;
  storage?: OAuthStorage;
  plugins: AuthPluginFactory[];
  defaultAuthorizedHandler?: AuthorizedHandler | null;
  enableLoadingScreen: boolean;
  refreshTokenOnInit?: boolean;
  loadingScreenMessage?: DynamicTextContent | null;
  userProfileUrl?: string;
  requireSignIn?: boolean;
  requireSignInForRequests?: boolean;
  waitForTokenInMs?: number;
  showDebugInformation?: boolean;
}

In order to add the UI for signing in and out, add the odx-auth component to the odx-header:

<odx-header>
  <odx-auth>
    <!-- custom content -->
  </odx-auth>
</odx-header>

Use the LocalizationService.setLanguage method from @odx/angular/localization to change the language.

/@odx/auth/

    Package Sidebar

    Install

    npm i @odx/auth

    Weekly Downloads

    356

    Version

    13.1.0

    License

    SEE LICENSE IN LICENSE

    Unpacked Size

    358 kB

    Total Files

    115

    Last publish

    Collaborators

    • breeze_ds
    • michael23
    • kevin.wardenga