Identity & Access Management

Enterprise SSO Implementation

Duration: ~15 hours Date: February 2026 Status: Production
TL;DR

Set up single sign-on across my homelab — one login for everything from the documentation wiki to the code editor. Authentik validates credentials against Active Directory, then issues a session cookie the reverse proxy checks on every request. Log in once; everything just works after that.

Key Achievement: Self-hosted apps behind one login. Adding a new app takes about 5 minutes — a proxy provider, an application entry, and a few nginx lines.
$ cat results.txt
logins
one AD login for every protected app
new app
~5 minutes to put behind SSO
auth failures
none since going live
audit
every login attempt logged in Authentik

The Problem

What I Started With

Why This Sucks

The Solution

How It Works

First Time Visiting an App:

  1. You type in the URL: https://docs.homelab.local
  2. Reverse proxy (like a security guard) stops you: "Show me your session cookie"
  3. You don't have one yet, so it redirects you to the login page
  4. You enter your username/password (which gets checked against Active Directory)
  5. Login works → You get a session cookie → Redirected back to the app
  6. Now the security guard sees your cookie and lets you through

Every Time After That:

The Tech Stack

What I Actually Built

The Main Pieces

Active Directory (The User Database)

Authentik (The Login System)

Nginx Proxy Manager (The Security Gate)

Docker (How It All Runs)

Key Technical Decisions

Why Forward Auth vs Native OIDC/SAML
▼
  • Forward auth works with any HTTP(S) application — no changes to the app itself
  • Application never sees credentials
  • Auth enforced at the network edge before requests reach the app
  • Same pattern applies to any app you add later
  • Trade-off: Double authentication if the app has its own native auth (acceptable here)
Why Separate Authentik Outpost
▼
  • Performance isolation (auth validation vs login flows, LDAP queries, UI)
  • Separation of concerns (auth validation vs identity management)
  • Mirrors enterprise IdP architecture (e.g., Okta agents)

The Challenges

Challenge 1: Wrong Username Format for LDAP
▼

What Went Wrong:

Error: LDAP bind failed - Invalid credentials

The Problem:

  • I was using email format: admin@domain.local
  • LDAP doesn't understand email format - it needs a specific path
  • Required format: CN=Admin,OU=Users,DC=domain,DC=local

The Fix:

Used the full Distinguished Name (DN) path instead of email/UPN format.

Lesson Learned:

LDAP has its own addressing format. Email-style usernames won't work for bind operations.

Challenge 2: nginx auth_request Returns Wrong Status
▼

What Went Wrong:

401 Unauthorized (even after successful login)

The Problem:

  • nginx's auth_request only accepts 2xx as "allow"
  • Authentik was returning 401 for "not logged in" (correct)
  • But nginx wasn't properly handling the redirect flow

The Fix:

Configured proper error_page 401 = @authentik handling and set up the redirect location block correctly.

Lesson Learned:

HTTP status codes have specific meanings in auth flows. Need to understand how nginx interprets subrequest responses.

Challenge 3: Session Cookies Not Persisting
▼

What Went Wrong:

Login works, but redirected back to login immediately

The Problem:

  • Cookies have domain restrictions
  • Cookie set for auth.domain.local wasn't being sent to app.domain.local
  • Browser security feature, not a bug

The Fix:

Configured Authentik to set cookies for the parent domain .domain.local so they're sent to all subdomains.

Lesson Learned:

When login involves redirects between subdomains, you have to understand cookie policies. This took reading browser documentation and testing different settings.

Results

  • Every protected app behind one login
  • One set of AD credentials for everything — no per-app passwords
  • ~5 minutes to add a new application to SSO
  • No authentication failures since going live
  • Every login attempt logged in Authentik

Reusable Pattern

Adding SSO to a new application takes ~5 minutes:

  1. In Authentik: Create Proxy Provider + Application (3 clicks)
  2. In Authentik: Assign application to outpost (1 click)
  3. In NPM: Add auth_request location blocks to proxy host (paste config)
  4. Test: Access app → redirect to login → authenticate → access granted

Currently protected by this pattern:

  • Documentation platform (Bookstack)
  • Web IDE (code-server)
  • Earlier: a dashboard (Glance) and a backup tool (Duplicati), both retired in October 2026

And works for any future HTTP(S) application without touching the app itself.

The Short Version

I was running a set of self-hosted applications with independent user management — password fatigue, reused credentials, no centralized audit trail. The goal was to implement SSO that would work across everything, including apps without native SSO support. I deployed Authentik as the identity provider backed by a 2-DC Active Directory environment, then placed authentication at the reverse proxy layer so every HTTP request gets validated before it reaches the application. That's the same architecture Cloudflare Access uses — auth enforced at the edge, apps never see credentials directly.

The hard parts were protocol-level: LDAP bind operations require Distinguished Name format (CN=Admin,OU=Users,DC=domain,DC=local), not the UPN email format I first tried. nginx's auth_request only treats 2xx responses as "allow," which required correctly wiring the error_page 401 = @authentik redirect flow. And session cookies set on auth.domain.local don't propagate to app.domain.local without explicitly scoping them to the parent domain. Once those three pieces clicked, the rest was just configuration — and the pattern now takes about 5 minutes to apply to any new application.