@odx/auth
v14.0.0
Published
[<img src="https://img.shields.io/npm/v/@odx/auth" />](https://npmjs.org/package/@odx/auth) [<img src="https://img.shields.io/npm/dependency-version/@odx/auth/peer/@odx/angular" />](https://npmjs.org/package/@odx/angular)
Downloads
2,354
Readme
@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
- serviceConnectUserProfilePlugin: Auth plugin to load user profile including language settings from service connect
- 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.