Skip to content
STACK IT FAST

Kanidm

Curated OSSClassicIdentity Management Platform6-20 people

Audited from github.com/kanidm/kanidm

Kanidm is a simple, secure identity management platform written in Rust: OAuth2/OIDC SSO, passkeys, RADIUS, a read-only LDAPS gateway, SSH key distribution and Linux login integration from one server with embedded storage.

Language
Rust
Database
SQLite
Hosting
Docker
License
MPL-2.0
Running for
7 years
Team
6-20 people

Why this architecture

Kanidm ships every identity protocol from one Rust server with bundled SQLite and built-in replication, renders its UI with Axum, Askama and htmx, and maintains its own WebAuthn, JWT and LDAP crates to keep security-critical code under its control.

Tech stack by layer

11 technologies · audited Oct 2, 2026
Frontend & UI
  • HTMXServer-rendered web UI with htmx interactions through axum-htmx; make run_htmx starts the dev server with the ui_htmx feature.
  • AskamaCompile-time HTML templates for the web UI, rendered into Axum responses through askama_web.
Backend & APIs
  • RustLanguage of the server, CLI tools, Unix integration and RADIUS module (Rust 1.96 minimum).
  • AxumHTTP framework for the kanidmd server (axum 0.8 with axum-extra cookies and axum-htmx guards).
  • WebAuthnPasskeys and attested passkeys via webauthn-rs protocol crates; SSH key attestation via sshkey-attest.
  • LDAPRead-only LDAPS gateway and LDAP/FreeIPA migration tools built on the ldap3 crates.
  • utoipaOpenAPI schema for the REST API, used by the Python client to generate an OpenAPI client.
Data & Persistence
  • SQLiteEmbedded storage through rusqlite with the bundled SQLite build; no external database server is required.
Infrastructure & Deploy
  • DockerSeparate images for kanidmd, the CLI tools and the RADIUS server, built on openSUSE with cargo-auditable and sccache.
  • OpenTelemetryTracing, logs and metrics exported over OTLP from the sketching logging crate.
  • FreeRADIUSrlm_kanidm builds a FreeRADIUS module and kanidm_radiusd for network and VPN authentication on ports 1812 and 1813.
  • Pythonpykanidm client library (pydantic, aiohttp) with a generated OpenAPI client and a Python FreeRADIUS integration.
  • Nixshell.nix provides a development environment.
Tooling, Testing & Ops
  • AGENTS.mdAgent instructions at the repository root; the README also links an AI/LLM usage policy for contributions.

Kanidm architecture diagram

Open SVG
Kanidm architecture diagramWeb UI → kanidmd (HTTPS); Apps and services → kanidmd (OIDC); Linux hosts → kanidmd (resolver); RADIUS → kanidmd (auth); kanidmd → Storage (rusqlite); kanidmd → Replica node (replicate)CLIENTSSERVICESDATA & STORAGEEXTERNALWeb UIAskama · htmxApps and servicesOAuth2 / OIDCLinux hostsPAM · NSSkanidmdRust · AxumRADIUSFreeRADIUS moduleStorageSQLite (bundled)Replica nodereplicationauthHTTPSOIDCresolverrusqlitereplicate
How the main components of Kanidm connect, drawn from the audited repository.
Diagram as text
  • Web UI (Askama · htmx) → kanidmd (Rust · Axum): HTTPS
  • Apps and services (OAuth2 / OIDC) → kanidmd (Rust · Axum): OIDC
  • Linux hosts (PAM · NSS) → kanidmd (Rust · Axum): resolver
  • RADIUS (FreeRADIUS module) → kanidmd (Rust · Axum): auth
  • kanidmd (Rust · Axum) → Storage (SQLite (bundled)): rusqlite
  • kanidmd (Rust · Axum) → Replica node (replication): replicate

Key architectural decisions

5 decisions
  1. 01

    One server for OIDC, LDAP, RADIUS and Unix logins

    The README states the goal of being a complete identity provider so that no other component such as Keycloak is needed. The workspace bundles the server (server/*), a RADIUS module (rlm_kanidm), PAM and NSS modules for Linux (unix_integration/*), LDAP and FreeIPA migration tools and a CLI.

  2. 02

    Embedded SQLite instead of an external database

    The workspace pins rusqlite with the bundled feature, and the README lists two-node high availability through database replication, so a deployment runs as one binary with its own storage and replicates between nodes instead of depending on a SQL server.

  3. 03

    Server-rendered UI with Axum, Askama and htmx

    Cargo.toml depends on axum 0.8, askama with askama_web (axum-0.8 feature) and axum-htmx with guards, and the Makefile has a run_htmx target that builds with the kanidmd_core/ui_htmx feature, so the self-service web UI is rendered on the server with htmx partials rather than a JavaScript SPA.

  4. 04

    Build profiles baked into the binary

    libs/profiles (kanidm_build_profiles) reads a profile at build time, and the Dockerfiles set KANIDM_BUILD_PROFILE to container_generic, so defaults such as paths and features differ between container, distribution and development builds without runtime flags.

  5. 05

    Owning the security-critical dependencies

    The commented [patch.crates-io] table in Cargo.toml points at local checkouts of webauthn-rs, compact-jwt, concread, ldap3, crypto-glue and kanidm-hsm-crypto, showing that the team maintains its WebAuthn, JWT, LDAP and HSM crates alongside the server.

How Kanidm is built

How Kanidm is structured

Kanidm is a Cargo workspace (version 1.12.0-dev, Rust 1.96) that covers the server, its clients and its integrations:

Path Role
server/daemon, server/core, server/lib, server/lib-macros kanidmd: the identity server, HTTP layer, core logic and macros
server/testkit, server/testkit-macros Integration test harness
proto/ kanidm_proto: protocol types shared by server and clients
libs/ Client library, crypto, SCIM types, templating, logging (sketching), build profiles, file permissions, actors
tools/cli, tools/orca, tools/iam_migrations/*, tools/mail_sender Admin CLI, load testing, LDAP and FreeIPA sync, mail sender
unix_integration/* PAM and NSS modules and the resolver daemon for Linux logins
rlm_kanidm/, rlm_python/ FreeRADIUS integration in Rust and Python
pykanidm/ Python client library
book/ mdBook documentation
platform/ Packaging for Debian, Fedora, FreeBSD and openSUSE

Frontend

The self-service web UI is rendered on the server. The workspace depends on Askama templates with askama_web (feature axum-0.8) and on axum-htmx with guards, and the Makefile's run_htmx target runs the dev server with kanidmd_core/ui_htmx. HTML, CSS and a small amount of JavaScript in the language breakdown match this server-rendered approach. deno.json and javascript_lint.yml lint the scripts that do exist.

Backend & APIs

kanidmd runs on Axum 0.8 with axum-extra cookies and axum-macros. It implements:

  • OAuth2 / OIDC for SSO and token exchange (README), with JWTs from the team's compact_jwt crate.
  • Passkeys through webauthn-rs-proto, including attested passkeys, plus SSH key attestation (sshkey-attest, sshkeys) for distributing SSH keys.
  • SCIM types in libs/scim_proto, and a read-only LDAPS gateway on the ldap3 crates.
  • RADIUS through a FreeRADIUS module (rlm_kanidm) and kanidm_radiusd, which expose ports 1812 and 1813 in their container.

The REST API is described with utoipa in kanidm_proto, and pykanidm can generate an OpenAPI client from it (kanidm_openapi_codegen).

Data & persistence

Storage is embedded SQLite through rusqlite with the bundled feature (Cargo.toml), so there is no external database to run. The README lists two-node high availability through database replication. On Linux clients, the resolver in unix_integration supports TPM-protected offline authentication (README), using kanidm-hsm-crypto with a tpm feature in libs/crypto.

Build, test & deploy

  • Container images: server/Dockerfile (kanidmd), tools/Dockerfile (CLI, plus the FIDO metadata tool) and rlm_kanidm/Dockerfile (RADIUS). All build on openSUSE Tumbleweed with sccache and cargo auditable, which embeds the dependency list in the binary. Multi-arch images for amd64 and arm64 are built with docker buildx from the Makefile.
  • Build profiles (libs/profiles, KANIDM_BUILD_PROFILE) bake environment-specific defaults into the binary.
  • GitHub workflows cover rust_build.yml, clippy.yml, windows_build.yml, pykanidm.yml, the container builds, the book (kanidm_book.yml), codespell.yml and Dependabot review and auto-merge.
  • tools/orca is a load-testing tool, and server/testkit drives integration tests against a real server.

Self-hosting notes

examples/ has ready configs: server.toml, server_container.toml, radius.toml, unixd, an sshd-config.conf, Apache OAuth examples and examples/systemd units. Because storage is embedded, a single container with a persistent volume is enough to start. Add a second node for replication when you need high availability.

What to copy (and what not to)

Copy:

  • A server-rendered UI with Axum, Askama and htmx for an admin or self-service interface. There is no SPA build to maintain. This is the same stack as the Axum + htmx + Askama rules.
  • Embedded storage with built-in replication when the dataset is small and operational simplicity matters more than SQL flexibility.
  • cargo auditable builds, which let vulnerability scanners read dependency versions from production binaries.

Don't copy blindly:

  • Maintaining your own WebAuthn, JWT and LDAP crates only makes sense for a security-focused team. Most apps should depend on maintained libraries.
  • Covering every identity protocol in one project is a large scope. Start with OIDC if that is all you need.

Other identity providers in the directory: authentik, which also runs an Axum + Askama server component, and the authentik vs Authelia vs Logto comparison.

Sources & repo audit

Audited
Oct 2, 2026
Commit
40a8b2a
License
MPL-2.0

Independent analysis of repository at github.com/kanidm/kanidm. Spotted an inaccuracy? Use the claim form to request a correction.

Maintainer? Add the architecture badge to your README
architecture: stackitfast
[![Architecture on STACK IT FAST](https://stackitfast.com/badge/kanidm.svg)](https://stackitfast.com/project/kanidm)
Use this stack

Scaffold it with your agent

Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Kanidm's architecture.

  1. 1Copy the promptThe full markdown spec, with every layer and decision.
  2. 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
  3. 3Paste and scaffoldUse it as the first instruction; review before you ship.
use-this-stack.md · 60 lines · 7.3 KB
# MISSION: Scaffold "Kanidm" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Kanidm**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Kanidm
- **What It Does**: Kanidm is a simple, secure identity management platform written in Rust: OAuth2/OIDC SSO, passkeys, RADIUS, a read-only LDAPS gateway, SSH key distribution and Linux login integration from one server with embedded storage.
- **Domain & Category**: Identity Management Platform
- **Production Scale**: 6-20 people
- **Development Mode**: CLASSIC
- **Architectural Rationale**: Kanidm ships every identity protocol from one Rust server with bundled SQLite and built-in replication, renders its UI with Axum, Askama and htmx, and maintains its own WebAuthn, JWT and LDAP crates to keep security-critical code under its control.
- **Live Website Reference**: https://kanidm.com
- **Source Repository**: https://github.com/kanidm/kanidm
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: Rust, Axum, Askama, HTMX, SQLite, Tokio, WebAuthn, OpenTelemetry, Python, Docker, Nix
- **Primary Language(s)**: Rust, Python, HTML, C
- **License of the reference repo**: MPL-2.0
- **Frontend**: HTMX — Server-rendered web UI with htmx interactions through axum-htmx; make run_htmx starts the dev server with the ui_htmx feature.; Askama — Compile-time HTML templates for the web UI, rendered into Axum responses through askama_web.
- **Backend & APIs**: Rust — Language of the server, CLI tools, Unix integration and RADIUS module (Rust 1.96 minimum).; Axum — HTTP framework for the kanidmd server (axum 0.8 with axum-extra cookies and axum-htmx guards).; WebAuthn — Passkeys and attested passkeys via webauthn-rs protocol crates; SSH key attestation via sshkey-attest.; LDAP — Read-only LDAPS gateway and LDAP/FreeIPA migration tools built on the ldap3 crates.; utoipa — OpenAPI schema for the REST API, used by the Python client to generate an OpenAPI client.
- **Data & persistence**: SQLite — Embedded storage through rusqlite with the bundled SQLite build; no external database server is required.
- **Infrastructure & deploy**: Docker — Separate images for kanidmd, the CLI tools and the RADIUS server, built on openSUSE with cargo-auditable and sccache.; OpenTelemetry — Tracing, logs and metrics exported over OTLP from the sketching logging crate.; FreeRADIUS — rlm_kanidm builds a FreeRADIUS module and kanidm_radiusd for network and VPN authentication on ports 1812 and 1813.; Python — pykanidm client library (pydantic, aiohttp) with a generated OpenAPI client and a Python FreeRADIUS integration.; Nix — shell.nix provides a development environment.
- **Tooling, testing & ops**: AGENTS.md — Agent instructions at the repository root; the README also links an AI/LLM usage policy for contributions.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/kanidm/kanidm @ 40a8b2a)
1. **One server for OIDC, LDAP, RADIUS and Unix logins**: The README states the goal of being a complete identity provider so that no other component such as Keycloak is needed. The workspace bundles the server (server/*), a RADIUS module (rlm_kanidm), PAM and NSS modules for Linux (unix_integration/*), LDAP and FreeIPA migration tools and a CLI.
2. **Embedded SQLite instead of an external database**: The workspace pins rusqlite with the bundled feature, and the README lists two-node high availability through database replication, so a deployment runs as one binary with its own storage and replicates between nodes instead of depending on a SQL server.
3. **Server-rendered UI with Axum, Askama and htmx**: Cargo.toml depends on axum 0.8, askama with askama_web (axum-0.8 feature) and axum-htmx with guards, and the Makefile has a run_htmx target that builds with the kanidmd_core/ui_htmx feature, so the self-service web UI is rendered on the server with htmx partials rather than a JavaScript SPA.
4. **Build profiles baked into the binary**: libs/profiles (kanidm_build_profiles) reads a profile at build time, and the Dockerfiles set KANIDM_BUILD_PROFILE to container_generic, so defaults such as paths and features differ between container, distribution and development builds without runtime flags.
5. **Owning the security-critical dependencies**: The commented [patch.crates-io] table in Cargo.toml points at local checkouts of webauthn-rs, compact-jwt, concread, ldap3, crypto-glue and kanidm-hsm-crypto, showing that the team maintains its WebAuthn, JWT, LDAP and HSM crates alongside the server.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
   - Structure as a Turborepo monorepo with strict package boundaries:
     - `apps/web`: Application UI, routing, layouts, and server endpoints.
     - `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
     - `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
     - `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
   - Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
   - Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
   - Utilize HTMX 2.0 with semantic HTML templates. Return partial HTML fragments from backend handlers to update UI reactively without heavy client JavaScript bundles.
4. **Design System & Aesthetics**:
   - Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
   - Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
   - Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
   - Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer (SQLite): client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.
Scaffolded something with this prompt?
Would you pick this stack for a identity management platform project?

Frequently asked about Kanidm

What is Kanidm built with?

Kanidm is written in Rust. The kanidmd server uses Axum, renders its web UI with Askama templates and htmx through axum-htmx, stores data in a bundled SQLite database via rusqlite, and implements passkeys with the webauthn-rs crates.

Does Kanidm need PostgreSQL or another database?

No. Kanidm uses an embedded SQLite database through rusqlite with the bundled feature, and the README lists two-node high availability through its own database replication.

Is Kanidm an alternative to Keycloak?

Yes. The README says the goal is to be a complete identity provider so that components like Keycloak are not needed, covering OAuth2/OIDC SSO, passkeys, RADIUS, a read-only LDAPS gateway, SSH key distribution and Linux login integration.

Does Kanidm use htmx?

Yes. The workspace depends on axum-htmx and askama_web, and the Makefile has a run_htmx target that starts the dev server with the kanidmd_core/ui_htmx feature for the server-rendered web UI.

How do I deploy Kanidm?

The repository builds container images for the kanidmd server, the CLI tools and the RADIUS server, with Dockerfiles under server/, tools/ and rlm_kanidm/, and ships example configs such as examples/server.toml and examples/server_container.toml plus systemd units in examples/systemd.

One email a month: new deep dives and stack trends

New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.

use-this-stack.md