How luviensoft/luvien-auth works
@luvien/auth is a NestJS authentication and identity library. An application initiates login through the Nest service; the core service creates OIDC state and PKCE data, redirects to an identity provider, then processes the callback into a mapped identity, local principal, and optional server session. Nest guards resolve sessions and enforce roles. The README also documents JWKS token validation, identity linking, and provider capabilities. The tree supports these subsystems, but unsampled implementation details and some wiring are not inferred.
Main entry points: authentication.service.ts Authentication service · auth.module.ts Auth module · auth.service.ts Auth service · in-memory-session.manager.ts In-memory session manager
Components 26
NestJS Integration
- Auth module
src/nest/auth.module.ts - Auth service
src/nest/auth.service.ts - Authentication guard
src/nest/guards/authentication.guard.ts - Authorization guard
src/nest/guards/authorization.guard.ts - Current user decorator
src/nest/decorators/current-user.decorator.ts - Role decorator
src/nest/decorators/require-roles.decorator.ts
Authentication Core
- Authentication service
src/core/application/authentication.service.ts - Principal and identity
src/core/domain/identity.ts - Provider capabilities
src/core/domain/capability.ts - OIDC provider port
src/core/port/oidc-provider.port.ts - Identity repository port
src/core/port/identity-repository.port.ts - Session manager port
src/core/port/session-manager.port.ts - State store port
src/core/port/state-store.port.ts - User resolver port
src/core/port/user-resolver.port.ts
OIDC Provider
- PKCE and state
src/protocols/oidc/oidc.pkce.ts - Generic OIDC provider
src/providers/generic-oidc/generic-oidc.provider.ts - Claim and role mapping
src/providers/generic-oidc/claim-mapper.ts - OIDC discovery
src/protocols/oidc/oidc.discovery.ts - JWKS token validation
Identity And Sessions
- Session model
src/core/domain/session.ts
In-memory Adapters
- In-memory identity repository
src/persistence/in-memory/in-memory-identity.repository.ts - In-memory session manager
src/persistence/in-memory/in-memory-session.manager.ts - In-memory state store
src/persistence/in-memory/in-memory-state.store.ts
Other components
- Application
- External identity provider
- Application user resolver
Connections 35
- Application → Auth service: starts login
- Application → Auth service: submits callback
- Auth service → Authentication service: delegates
- Auth service → In-memory session manager: reads and destroys
- Authentication service → PKCE and state: generates PKCE
- Authentication service → OIDC provider port: requests authorization
- Authentication service → State store port: saves and consumes
- Authentication service → OIDC provider port: handles callback
- Authentication service → Claim and role mapping: extracts roles
- Authentication service → Identity repository port: finds and writes
- Authentication service → User resolver port: resolves user
- Authentication service → Session manager port: creates session
- Generic OIDC provider → External identity provider: redirects and exchanges
- Generic OIDC provider → OIDC discovery: loads metadata
- Generic OIDC provider → JWKS token validation: validates tokens
- OIDC discovery → External identity provider: fetches metadata
- JWKS token validation → External identity provider: fetches JWKS
- Authorization guard → Role decorator: reads requirements
- Authentication guard → In-memory session manager: loads session
- Authentication guard → Application: sets principal
- Authorization guard → Authentication guard: checks principal
- Current user decorator → Application: exposes principal
- In-memory identity repository → Identity repository port: implements
- In-memory session manager → Session manager port: implements
- In-memory state store → State store port: implements
- In-memory session manager → Session model: stores
- Auth module → Generic OIDC provider: registers
- Auth module → In-memory identity repository: registers
- Auth module → In-memory session manager: registers
- Auth module → In-memory state store: registers
- Auth module → Authentication service: constructs
- Auth module → Auth service: registers
- Auth module → Authentication guard: registers
- Auth module → Authorization guard: registers
- Application → Application user resolver: provides implementation