Authelia
Audited from github.com/authelia/authelia
Authelia is an open-source single sign-on and multi-factor authentication portal that sits in front of web applications, adding LDAP or file-based login, OpenID Connect, WebAuthn passkeys, TOTP and Duo push MFA behind a reverse proxy.
- Language
- Go
- Database
- PostgreSQL
- Hosting
- Docker
- License
- Apache-2.0
- Running for
- 5 years
- Team
- 6-20 People
Why this architecture
A single fasthttp-based Go binary keeps the authentication portal, OIDC provider, and MFA logic in one process with pluggable SQLite/MySQL/PostgreSQL storage, so it can run as a zero-dependency single instance or scale out with a shared database.
Tech stack by layer
10 technologies · audited Sep 17, 2026- ReactBuilds the login/consent/registration portal served by the Go binary (web/package.json, React 19).
- ViteDev server and production bundler for the web portal.
- @simplewebauthn/browserClient-side WebAuthn/passkey ceremonies in the portal.
- i18nextPortal translations, loaded via i18next-http-backend and browser language detection.
- GoThe single authelia binary (cmd/authelia) implements the portal API, OIDC provider, LDAP/file authentication, and MFA.
- fasthttpHTTP server and router (fasthttp/router, valyala/fasthttp) instead of net/http.
- authelia.com/provider/oauth2Authelia's own OAuth2/OpenID Connect provider implementation backing internal/oidc.
- go-webauthn/webauthnServer-side WebAuthn/passkey registration and assertion verification.
- go-ldap/ldapLDAP client used by the LDAP authentication backend (internal/authentication).
- PostgreSQLOne of three first-class storage backends, via the jackc/pgx driver (internal/storage).
- MySQLMySQL/MariaDB storage backend via go-sql-driver/mysql.
- SQLiteDefault embedded storage backend for single-instance deployments, via mattn/go-sqlite3.
- RedisSession/notification cache backend; go-redis and redis/go-redis clients are present in the dependency graph.
- GitHub ActionsCodeQL, OpenSSF Scorecard, SLSA provenance, and contributor-stats workflows.
- VitestPortal unit tests with coverage instrumentation (VITE_COVERAGE env, vite-plugin-istanbul).
- lefthookGit hook runner installed via the portal package.json `prepare` script.
Authelia architecture diagram
Open SVGDiagram as text
- Browser (protected app user) → Reverse proxy (forward auth): request
- Reverse proxy (forward auth) → authelia binary (Go · fasthttp): verify
- Login portal (React · WebAuthn) → authelia binary (Go · fasthttp): portal API
- authelia binary (Go · fasthttp) → OIDC provider (internal/oidc): OIDC flows
- authelia binary (Go · fasthttp) → Storage (SQLite / MySQL / Postgres): pgx / sqlite
- authelia binary (Go · fasthttp) → Session cache (Redis (optional)): sessions
- authelia binary (Go · fasthttp) → User backend (LDAP or file): authenticate
- authelia binary (Go · fasthttp) → MFA (TOTP · WebAuthn · Duo): second factor
Key architectural decisions
5 decisions- 01
One Go binary is the full authentication portal, OIDC provider, and MFA server
cmd/authelia is the single entrypoint; internal/authentication, internal/authorization, internal/oidc, internal/webauthn, internal/totp, internal/duo, and internal/session all compile into one binary rather than separate services, so a deployment is one process plus its chosen storage/session backend.
- 02
Storage is pluggable across SQLite, MySQL, and PostgreSQL by design
go.mod directly requires mattn/go-sqlite3, go-sql-driver/mysql, and jackc/pgx/v5 together, and internal/storage implements a common interface over all three, so the same binary supports a zero-dependency single-instance setup (SQLite) or a shared database for multi-replica deployments (MySQL/PostgreSQL).
- 03
fasthttp instead of the Go standard library net/http
go.mod requires github.com/fasthttp/router and github.com/valyala/fasthttp as core dependencies for internal/server, trading some stdlib-idiomatic ergonomics for the lower allocation overhead fasthttp is designed for, which matters because Authelia sits in front of every request to the protected applications.
- 04
Authelia built its own OAuth2/OIDC provider instead of adopting an off-the-shelf library
go.mod requires authelia.com/provider/oauth2, a fork/derivative maintained under the Authelia org, which internal/oidc builds on to implement the OpenID Certified provider described in the README, giving the project direct control over spec compliance and the post-quantum-cryptography-ready claims.
- 05
The web portal is a separate pnpm project embedded in the same repository
web/package.json is its own pnpm workspace (pnpm 12, Node >=22.22) built with Vite and React 19; internal/server serves its production build as static assets, keeping the Go binary self-contained without a separate frontend deployment.
How Authelia is built
How Authelia is structured
The repository root is a Go module (github.com/authelia/authelia/v4) with cmd/authelia as the binary entrypoint and the bulk of the logic under internal/: authentication (LDAP and file backends), authorization (access-control rules), oidc (the OpenID Connect provider), webauthn, totp, duo, session, storage, notification, regulation (brute-force protection), and server/middlewares for the HTTP layer. web/ is a separate pnpm project holding the React portal that users see when they authenticate, and docs/ is a third, independent pnpm/Docusaurus-adjacent project for the authelia.com documentation site (its own pnpm-lock.yaml, pnpm-workspace.yaml, and netlify.toml). cmd/authelia-gen and cmd/authelia-scripts are internal developer tooling for generating documentation and running the test suites defined in cmd/authelia-suites.
Frontend
The portal in web/ is React 19 with TypeScript, built by Vite 8 (web/vite.config.ts) and styled with Tailwind CSS 4 via @tailwindcss/vite. @base-ui/react supplies headless UI primitives, class-variance-authority and clsx/tailwind-merge manage component variants, and lucide-react provides icons. Passkey registration and login run through @simplewebauthn/browser, qrcode.react renders TOTP QR codes, and zxcvbn scores password strength client-side. Internationalization uses i18next with i18next-browser-languagedetector and an HTTP backend for translation files, coordinated with the project's Crowdin integration (crowdin.yml).
Backend & APIs
internal/server builds on fasthttp and fasthttp/router rather than the Go standard library's net/http, and internal/middlewares layers session, security-header, and logging middleware around it. Authentication itself is pluggable: internal/authentication implements both an LDAP backend (go-ldap/ldap/v3) and a file backend, selected through the YAML configuration parsed by koanf (knadh/koanf/v2 and its YAML/env/posflag providers). internal/oidc implements a full OpenID Connect provider on top of the Authelia-maintained authelia.com/provider/oauth2 library, and the repository publishes api/openapi.yml describing the resulting REST API.
Data & persistence
internal/storage abstracts over three SQL backends, each pulled in as a direct Go dependency: SQLite (mattn/go-sqlite3) for a zero-dependency default, MySQL/MariaDB (go-sql-driver/mysql), and PostgreSQL (jackc/pgx/v5). This is where user sessions, regulation (failed-login) records, WebAuthn credentials, TOTP secrets, and OIDC consent are persisted. Redis client libraries (go-redis/redis/v8 and redis/go-redis/v9) are present in the dependency graph and back the optional Redis session/notification cache used in multi-replica deployments.
Build, test & deploy
The Go side is tested with the standard go test toolchain plus stretchr/testify and go.uber.org/mock; .golangci.yml configures linting and .lefthook.yml wires pre-commit hooks shared between the Go and web projects. .buildkite/pipeline.yml drives the primary CI pipeline, running unit, integration, and end-to-end suites defined via cmd/authelia-suites and orchestrated by .buildkite/steps. .github/workflows covers CodeQL analysis, OpenSSF Scorecard, SLSA provenance attestation (slsa.yml), and contributor-stats automation, while releases are cut with .goreleaser.yml. The web portal runs its own Vitest suite (test, test:watch) with coverage instrumented through vite-plugin-istanbul.
Self-hosting notes
Authelia ships an official multi-arch Docker image built from Dockerfile, plus Dockerfile.dev for local development and Dockerfile.coverage for instrumented test builds. Non-Docker installs are supported through authelia.service/authelia@.service systemd units, authelia.sysusers.conf/authelia.tmpfiles.conf, and bootstrap.sh. config.template.yml documents every configuration key, and examples/compose provides ready-to-use Docker Compose stacks pairing Authelia with a reverse proxy. Because it is designed to sit in front of other services, self-hosting always involves configuring a proxy (Traefik, nginx, Caddy, or similar) to forward auth requests to Authelia.
What to copy (and what not to)
The pluggable storage layer (SQLite for a zero-dependency default, MySQL/PostgreSQL for scale-out) is a strong pattern for any self-hosted tool that wants a low-friction single-instance mode without giving up multi-replica deployments later. Maintaining a forked OAuth2/OIDC provider library (authelia.com/provider/oauth2) is a heavier commitment that only makes sense for a project whose entire value proposition is identity/auth correctness — most projects should reach for an established OIDC library instead of forking one. Splitting the Go backend, the React portal, and the documentation site into three independently versioned pnpm/Go projects inside one repository is worth copying for keeping each toolchain's dependencies isolated, as long as your CI is set up (as Authelia's Buildkite pipeline is) to build and test them independently.
Sources & repo audit
- Audited
- Sep 17, 2026
- Commit
- 8da42b2
- License
- Apache-2.0
- go.mod (fasthttp, authelia.com/provider/oauth2, go-webauthn, ldap, pgx, go-sql-driver/mysql, go-sqlite3)
- web/package.json (React 19, Vite, @simplewebauthn/browser, i18next, Vitest)
- Dockerfile, Dockerfile.dev, Dockerfile.coverage
- .buildkite/pipeline.yml (CI pipeline definition)
- internal/ (authentication, authorization, oidc, webauthn, storage, session, totp, duo directories)
Independent analysis of repository at github.com/authelia/authelia. Spotted an inaccuracy? Use the claim form to request a correction.
Show this stack on your README or website
[](https://stackitfast.com/project/authelia)Paste it into your README. It shows your current stack and links to this page.
Scaffold it with your agent
Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Authelia's architecture.
- 1Copy the promptThe full markdown spec, with every layer and decision.
- 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
- 3Paste and scaffoldUse it as the first instruction; review before you ship.
# MISSION: Scaffold "Authelia" 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 **Authelia**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Authelia
- **What It Does**: Authelia is an open-source single sign-on and multi-factor authentication portal that sits in front of web applications, adding LDAP or file-based login, OpenID Connect, WebAuthn passkeys, TOTP and Duo push MFA behind a reverse proxy.
- **Domain & Category**: Authentication & SSO Proxy Companion
- **Production Scale**: 6-20 People
- **Development Mode**: CLASSIC
- **Architectural Rationale**: A single fasthttp-based Go binary keeps the authentication portal, OIDC provider, and MFA logic in one process with pluggable SQLite/MySQL/PostgreSQL storage, so it can run as a zero-dependency single instance or scale out with a shared database.
- **Live Website Reference**: https://www.authelia.com
- **Source Repository**: https://github.com/authelia/authelia
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: Go, React, TypeScript, Vite, PostgreSQL, MySQL, SQLite, LDAP, WebAuthn, Redis
- **Primary Language(s)**: Go, TypeScript
- **License of the reference repo**: Apache-2.0
- **Frontend**: React — Builds the login/consent/registration portal served by the Go binary (web/package.json, React 19).; Vite — Dev server and production bundler for the web portal.; @simplewebauthn/browser — Client-side WebAuthn/passkey ceremonies in the portal.; i18next — Portal translations, loaded via i18next-http-backend and browser language detection.
- **Backend & APIs**: Go — The single authelia binary (cmd/authelia) implements the portal API, OIDC provider, LDAP/file authentication, and MFA.; fasthttp — HTTP server and router (fasthttp/router, valyala/fasthttp) instead of net/http.; authelia.com/provider/oauth2 — Authelia's own OAuth2/OpenID Connect provider implementation backing internal/oidc.; go-webauthn/webauthn — Server-side WebAuthn/passkey registration and assertion verification.; go-ldap/ldap — LDAP client used by the LDAP authentication backend (internal/authentication).
- **Data & persistence**: PostgreSQL — One of three first-class storage backends, via the jackc/pgx driver (internal/storage).; MySQL — MySQL/MariaDB storage backend via go-sql-driver/mysql.; SQLite — Default embedded storage backend for single-instance deployments, via mattn/go-sqlite3.; Redis — Session/notification cache backend; go-redis and redis/go-redis clients are present in the dependency graph.
- **Infrastructure & deploy**: Docker — Official image plus a coverage-instrumented and a dev variant (Dockerfile, Dockerfile.coverage, Dockerfile.dev).; Buildkite — Primary CI pipeline (build, integration/e2e suites) defined outside GitHub Actions.
- **Tooling, testing & ops**: GitHub Actions — CodeQL, OpenSSF Scorecard, SLSA provenance, and contributor-stats workflows.; Vitest — Portal unit tests with coverage instrumentation (VITE_COVERAGE env, vite-plugin-istanbul).; lefthook — Git hook runner installed via the portal package.json `prepare` script.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/authelia/authelia @ 8da42b2)
1. **One Go binary is the full authentication portal, OIDC provider, and MFA server**: cmd/authelia is the single entrypoint; internal/authentication, internal/authorization, internal/oidc, internal/webauthn, internal/totp, internal/duo, and internal/session all compile into one binary rather than separate services, so a deployment is one process plus its chosen storage/session backend.
2. **Storage is pluggable across SQLite, MySQL, and PostgreSQL by design**: go.mod directly requires mattn/go-sqlite3, go-sql-driver/mysql, and jackc/pgx/v5 together, and internal/storage implements a common interface over all three, so the same binary supports a zero-dependency single-instance setup (SQLite) or a shared database for multi-replica deployments (MySQL/PostgreSQL).
3. **fasthttp instead of the Go standard library net/http**: go.mod requires github.com/fasthttp/router and github.com/valyala/fasthttp as core dependencies for internal/server, trading some stdlib-idiomatic ergonomics for the lower allocation overhead fasthttp is designed for, which matters because Authelia sits in front of every request to the protected applications.
4. **Authelia built its own OAuth2/OIDC provider instead of adopting an off-the-shelf library**: go.mod requires authelia.com/provider/oauth2, a fork/derivative maintained under the Authelia org, which internal/oidc builds on to implement the OpenID Certified provider described in the README, giving the project direct control over spec compliance and the post-quantum-cryptography-ready claims.
5. **The web portal is a separate pnpm project embedded in the same repository**: web/package.json is its own pnpm workspace (pnpm 12, Node >=22.22) built with Vite and React 19; internal/server serves its production build as static assets, keeping the Go binary self-contained without a separate frontend deployment.
---
## 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 Vite 6 with TanStack Router for fully type-safe routing. Manage server state and caching via TanStack Query v5 with optimistic UI updates.
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 (PostgreSQL, MySQL, SQLite, Redis): 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.Frequently asked about Authelia
What is Authelia built with?
Authelia is a single Go binary (cmd/authelia) using fasthttp for its HTTP server, a self-maintained OAuth2/OpenID Connect provider library, and go-webauthn for passkeys. Its web portal is a separate React 19 + Vite + TypeScript project (web/) served as static assets by the Go binary.
Does Authelia need a backend database?
Not necessarily. Authelia supports a bundled SQLite database for single-instance deployments (mattn/go-sqlite3 in go.mod), or MySQL/MariaDB and PostgreSQL for multi-replica deployments where the storage layer needs to be shared, all through the same internal/storage abstraction.
Can I self-host Authelia?
Yes, self-hosting is the primary use case. The repository publishes an official Docker image (Dockerfile) plus systemd unit files (authelia.service, authelia@.service) for running it directly on Linux, and config.template.yml documents the YAML configuration for authentication backends, storage, and notification providers.
How does Authelia handle multi-factor authentication?
internal/webauthn (backed by go-webauthn/webauthn) implements FIDO2/WebAuthn passkeys, internal/totp implements TOTP one-time codes, and internal/duo integrates with Duo Security push notifications through duosecurity/duo_api_golang, all invoked from the same authentication flow in internal/handlers.
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.
Similar architectures
- GiteaClassicLightweight Self-Hosted Git Service · 20+ peopleShares Go · TypeScript · SQLite
- VaultwardenClassicLightweight Self-Hosted Password Vault · Solo / 2-5 peopleShares SQLite · PostgreSQL · MySQL
- GotifyClassicSelf-Hosted Real-Time Push Server · 2-5 PeopleShares Go · TypeScript · React
- Apache AnswerClassicQ&A & Developer Knowledge Community · 6-20 PeopleShares Go · TypeScript · React
- NocoDBHybridSmart Database Spreadsheet · 6-20 peopleShares TypeScript · PostgreSQL · MySQL
- PrismaClassicNext-Generation Node.js & TypeScript ORM · 1M+ MAUShares TypeScript · PostgreSQL · MySQL