Fetch tenant policy
Call `/api/auth/policy` (optionally with `tenantDomain`) to discover login choices, second factor rules, and approval requirements.
System diagrams
Each diagram maps the AuthCore hooks, APIs, and services you stitch together in production. Zoom in on the authentication journey below, then explore additional flows for passwordless access, tenant onboarding, and recovery.
Authentication Journey
Session minting, policy checks, and lifecycle hooks radiate from this hub to your product surfaces.
End-user initiates login from your product surface.
Credential, device, and policy checks run inside the authorization service.
Webhooks and business rules fire to trigger audits, MFA, or downstream automation.
ID & Access tokens include tenant metadata, scopes, and TOTP state.
ID · AccessYour UI consumes the session, renders protected views, and calls APIs.
Forms pull tenant policy data and pivot into credentials, magic links, or 2FA without custom glue code.
Call `/api/auth/policy` (optionally with `tenantDomain`) to discover login choices, second factor rules, and approval requirements.
Toggle credentials versus magic link UI so it mirrors `enableMagicLinkLogin` and related policy flags.
When sign-in returns `SECOND_FACTOR_REQUIRED`, swap the UI to TOTP or email OTP using the provided `channels` payload.
Surface the returned `steps` array so people verify email, enroll MFA, or wait on approval without guesswork.
Email-first sign-in that upgrades the session with a single verified click.
Client UI calls `useMagicLink` to POST `/api/auth/magic-link`, recording an expiring token and metadata.
Server injects tenant branding, signs the link, and hands delivery to Nodemailer, Resend, or custom providers.
Callback endpoint verifies integrity, enforces policy, and clears the single-use token.
NextAuth mints the session cookie and redirects the visitor to the requested origin.
Invite, accept, and provision tenant administrators without manual role wiring.
Tenant admins call `useOrganization().inviteMember` to persist a signed invite token with role metadata.
Email template ships tenant branding, expiry, and an `/auth/accept-invite` CTA.
Accept endpoint verifies the token, creates the member, or merges roles into an existing account.
Refresh the session so `useAuth().isTenantAdmin()` immediately reflects the new role.
Recover locked-out accounts and rotate secrets when a device goes missing.
Users hit `/auth/restore` to request a signed restore token after lockout checks.
Restore endpoint evaluates backup codes, rate limits, or approvals based on policy flags.
Successful challenge rotates the password and regenerates TOTP secrets with fresh backup codes.
Revoke device tokens with `useUserDevices().revokeDevice` so every client re-authenticates.