Reference

Architecture Overview

A deep dive into Idenplane's system design, module structure, authentication flows, and extensibility.

System Design

Idenplane is a single NestJS server that also serves its React admin console, backed by one PostgreSQL database:

🌐
Web Clients
React / Vue / Next.js
📱
Mobile Clients
Native / Hybrid
⚙️
Services
Express / NestJS

Idenplane Server (NestJS)

REST API

350+ endpoints

OIDC Engine

RFC 6749 + OIDC 1.0

SAML 2.0

IdP + Metadata

Admin Console

React SPA served

Prisma ORM

Type-safe queries

Metrics

Prometheus

PostgreSQL 16+

90+ Prisma models

Module Structure

Idenplane's NestJS backend is divided into 70+ focused modules. Here are some of the most important:

AuthModule

Login, logout, token issuance, session management

RealmsModule

Multi-tenant realm creation and configuration

UsersModule

User CRUD, profile, email verification, password reset

ClientsModule

OAuth/OIDC client registration and secrets

RolesModule

Realm and client roles, role mappings, role-based access

GroupsModule

User groups and group-to-role assignments

OAuthModule

Authorization Code (+PKCE), Client Credentials, Device, and Refresh Token flows

SamlModule

SAML 2.0 IdP (Idenplane is the IdP), service-provider registration, assertion generation, metadata

UserFederationModule

LDAP/AD federation and user sync

MfaModule

TOTP and recovery codes (SMS and WebAuthn live in their own modules)

SessionsModule

Active session listing and revocation

TokensModule

Introspection, revocation, userinfo, logout and back-channel logout

Authentication Flow

The standard Authorization Code + PKCE flow used by most web applications:

  1. 1

    Authorization Request

    The client redirects the user to Idenplane's /auth endpoint with a code_challenge (PKCE).

  2. 2

    User Authentication

    Idenplane presents the login page. The user enters credentials. MFA is prompted if enabled on the realm.

  3. 3

    Consent

    If the client has consent enabled (requireConsent), the user is shown a consent screen.

  4. 4

    Authorization Code Redirect

    Idenplane redirects back to the client's redirect_uri with a short-lived authorization code.

  5. 5

    Token Exchange

    The client exchanges the code + code_verifier for an access token, refresh token, and ID token.

  6. 6

    API Access

    The client includes the access token as Authorization: Bearer <token> on every API request.

  7. 7

    Token Refresh

    When the access token expires, the client uses the refresh token to obtain a new access token silently.

Database Schema Overview

Idenplane uses Prisma with 90+ models. The key relationships are:

Model Key Fields Relationships
Realm name, displayName, theme has many Users, Clients, Roles
User email, username, passwordHash, emailVerified belongs to Realm, has many Sessions, Roles
Client clientId, clientSecret, clientType, redirectUris belongs to Realm, has many client Roles, authorization codes
Session expiresAt, ipAddress, userAgent, amr belongs to User, has many RefreshTokens
Role name, description, clientId (client roles) belongs to Realm, has many Users via mapping
Group name, parentId has many Users, Roles; supports nesting

Plugin System

Idenplane can be extended through configuration and a small plugin API (event-listener and token-enrichment plugins). Common extension points:

🔌

Identity Providers & Federation

Configure OIDC, OAuth 2.0 or SAML identity providers for sign-in. Connect an LDAP or Active Directory user directory through federation.

🗺️

Protocol Mappers & Token Enrichment

Map user attributes and custom attributes into token claims with protocol mappers, or write a token-enrichment plugin to add claims in code.

🔐

Custom Auth Flows

Compose login steps (password, LDAP, TOTP, passkey, email code, sign-in link, social) per realm or client. Off by default: needs AUTH_FLOW_RUNTIME_ENABLED and the realm setting authFlowsEnabled.

📡

Event Listeners

Event-listener plugins, webhooks and audit streams receive auth events (login, logout, registration, token issued) to sync external systems.