@presencelearning/auth
Angular library wrapping angular-auth-oidc-client with signal-based state, ready-to-use guards, an auth interceptor, and an OAuth callback route.
Features
Section titled “Features”- Signal-Based State —
AuthServiceexposesisAuthenticated,currentUser, andaccessTokenas Angular signals. No subscriptions needed. - Single-Call Setup —
provideAuth()+withAuthInterceptor()configure everything inapp.config.ts - Smart Interceptor — Attaches Bearer tokens only to configured
secureRoutes. Automatically logs out on 401. - Route Guards —
authGuardandcreateGroupsGuard()protect routes with minimal boilerplate - OAuth Callback Route —
createAuthCallbackRoute()returns a pre-wiredRouteobject - Impersonation — RFC 8693 token exchange via
createStartImpersonationRoute()andcreateEndImpersonationRoute(). No consumer wiring required. - SSR-Safe Storage —
localStorage/sessionStoragewrappers that fall back gracefully in non-browser environments - Token Utilities — Parse, validate, and inspect JWTs without a full OIDC round-trip
Installation
Section titled “Installation”npm install @presencelearning/authQuick Start
Section titled “Quick Start”1. Configure your app
Section titled “1. Configure your app”import { ApplicationConfig } from '@angular/core';import { provideRouter } from '@angular/router';import { provideHttpClient } from '@angular/common/http';import { provideAuth, withAuthInterceptor } from '@presencelearning/auth';import { routes } from './app.routes';
export const appConfig: ApplicationConfig = { providers: [ provideRouter(routes), provideHttpClient(withAuthInterceptor()), provideAuth({ issuerUrl: environment.auth.issuerUrl, clientId: environment.auth.clientId, }), ],};2. Add the callback route
Section titled “2. Add the callback route”import { Routes } from '@angular/router';import { authGuard, createAuthCallbackRoute } from '@presencelearning/auth';
export const routes: Routes = [ createAuthCallbackRoute(), { path: 'dashboard', canActivate: [authGuard], loadComponent: () => import('./dashboard/dashboard.component'), },];3. Use auth state in components
Section titled “3. Use auth state in components”import { Component, inject } from '@angular/core';import { AuthService } from '@presencelearning/auth';
@Component({ template: ` @if (auth.isAuthenticated()) { <p>Welcome, {{ auth.currentUser()?.name }}</p> <button (click)="auth.logout()">Log out</button> } @else { <button (click)="auth.login()">Log in</button> } `,})export class AppComponent { protected auth = inject(AuthService);}Requirements
Section titled “Requirements”- Angular 18+
angular-auth-oidc-client≥ 18- RxJS 7+
Non-Goals
Section titled “Non-Goals”- No session polling —
angular-auth-oidc-clienthandles silent token renewal via refresh tokens - No cross-tab sync — Each tab runs its own OIDC check on load
Source: packages/auth