Simple identity and access management platform
  • Go 85.4%
  • HTML 8.2%
  • CSS 4.3%
  • JavaScript 1.8%
  • Dockerfile 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Kamil Marut 6732709547
All checks were successful
Push Docker Image / test (push) Successful in 2m38s
Push Docker Image / push (push) Successful in 1m2s
refactor(access): extract access grant commands to separate file
2026-11-26 18:58:10 +01:00
.forgejo/workflows Control application access per user with transactional OIDC checks 2026-10-18 00:50:47 +02:00
assets Add transparent and vector Thermopylae hoplite artwork 2026-09-27 21:47:03 +02:00
cmd/thermopylae feat(server): let in-flight requests finish before closing the server 2026-11-09 12:24:53 +01:00
internal refactor(access): extract access grant commands to separate file 2026-11-26 18:58:10 +01:00
.dockerignore ci: Add package deploy workflow 2026-10-16 11:23:20 +02:00
.gitignore Finish v1 2026-10-16 11:02:12 +02:00
AGENTS.md docs: keep README concise 2026-10-18 14:08:34 +02:00
Dockerfile build: copy CA bundle files in Docker image 2026-11-09 11:33:31 +01:00
go.mod feat(auth): support WebAuthn passkeys (#14) 2026-11-14 10:57:48 +01:00
go.sum feat(auth): support WebAuthn passkeys (#14) 2026-11-14 10:57:48 +01:00
Makefile Finish v1 2026-10-16 11:02:12 +02:00
README.md feat(account): change the name on your account 2026-11-14 11:55:16 +01:00
sqlc.yaml Create app boilerplate 2026-09-29 21:58:25 +02:00

Thermopylae

Thermopylae

An OpenID Connect provider. Users sign in once with email, password and TOTP; your apps log in through it.

Setup

Variable Default
THERMOPYLAE_ISSUER — Required. Public base URL, e.g. https://auth.example.com.
THERMOPYLAE_SECRET — Required. 32+ random bytes. Changing it invalidates TOTP and keys.
THERMOPYLAE_LISTEN :8080 Listen address.
THERMOPYLAE_DATA_DIR data SQLite database directory.
MADO_DSN — Mado project DSN. Reports 5xx errors, panics and error logs.
THERMOPYLAE_TRUSTED_PROXIES — Comma-separated proxy CIDRs, e.g. 172.18.0.0/16. Set this behind a reverse proxy, which must append to X-Forwarded-For, or sessions show the proxy's IP.

Mado events carry only the error, stack, request method and route template.

Run behind TLS; cookies are Secure for https:// issuers. http://localhost works for development.

export THERMOPYLAE_ISSUER=http://localhost:8080
export THERMOPYLAE_SECRET=$(head -c 32 /dev/urandom | base64)

make run
go run ./cmd/thermopylae admin create you@example.com   # prints an invite link

Open the invite link, set a password and scan the TOTP code. Manage users and apps at /admin.

Connecting an app

Create an application in /admin and give the app its client ID and secret (shown once). Discovery is at ${THERMOPYLAE_ISSUER}/.well-known/openid-configuration. PKCE (S256) is required; scopes are openid, email, profile and roles.

Redirect URIs match byte for byte and must be either:

  • http:// or https:// with a host, no credentials or fragment; or
  • a native callback on a lowercase, reverse-domain scheme with an absolute path, e.g. app.immich:///oauth-callback (RFC 8252 §7.1). No authority, query, fragment, dot segments or percent-encoding.

Native apps still authenticate to /token with the client secret, so this suits apps like Immich that get it from their own server.

Roles are assigned per application in /admin and returned as a roles array claim when the roles scope is requested.

Passkeys

Add a passkey in /account to sign in with a security key (YubiKey with FIDO2) or a Bitwarden passkey instead of a password and TOTP code. Browsers must support the WebAuthn JSON helpers (Chrome 129+, Firefox 119+, Safari 18.4+).

  • Choose Add a passkey, name it, and follow the browser prompt. For a YubiKey, set a FIDO2 PIN first; the key asks for it at every sign-in. For Bitwarden, pick Bitwarden in the browser prompt.
  • Adding or removing a passkey asks for your password and a fresh TOTP code unless a passkey sign-in or password and TOTP succeeded in the last 5 minutes. Changing your password doesn't count. Add a second passkey, or keep the password and TOTP, as a backup.
  • Password and TOTP stay a complete sign-in. If a passkey is lost, sign in with them and remove it; removing a passkey signs out the sessions it started. An admin's password reset or 2FA reset removes all of the user's passkeys.
  • Passkeys need THERMOPYLAE_ISSUER to be the exact public https:// origin (or http://localhost). The issuer's host is the relying party ID and its origin the only accepted origin. Changing the host orphans existing passkeys.
  • Passkey sign-in starts are limited to 20 a minute per client and 1000 pending at once; over the limit gets a 429.
  • Every passkey sign-in requires user verification (PIN or biometric). Authenticators that can't verify the user can't be registered.

Application access

Administrators can use every application. Other users can use only the applications ticked when they're created or later via their access link in /admin. Roles don't grant access.

Users without access get a 403. Access is rechecked at /token and /userinfo, so revoking it blocks new sign-ins and existing access tokens. It can't end the application's own session or recall ID tokens (valid up to an hour); sign the user out there too.

Set your name in /account. Applications receive it in the name claim.

Sessions

/account lists your signed-in devices; administrators see each user's on their /admin page. Revoke a device you don't recognize.

Revoking signs that device out and cancels its authorization codes and access tokens, and ends any impersonation running in it. Codes and access tokens issued before session tracking was enabled can't be tied to a device: they stay valid until they expire (access tokens up to an hour), and a code unredeemed at upgrade (up to 60 seconds) can still be exchanged for a new hour-long token. Rely on device revocation to cover all tokens only 61 minutes after upgrading. It can't end the application's own session or recall ID tokens (valid up to an hour); sign out there too. Replace the password as well if it may be known.

Impersonation

Administrators can sign in to applications as another user: open the user in /admin and choose Start impersonation. Applications get that user's identity, access and roles for up to 30 minutes. Thermopylae keeps treating you as yourself, shows a banner with End impersonation, and records starts, ends and sign-ins in /admin/impersonations. The user sees nothing in Thermopylae, and their sessions and sign-in history don't change. The log hides records about the administrator viewing it, so an administrator target can't see them; other administrators can.

  • Only new sign-ins are affected. Sign out of an application before starting, and again after ending: Thermopylae can't switch or end the application's own session.
  • Ending revokes the impersonation's codes and access tokens. ID tokens already issued can't be recalled; they expire no later than the impersonation.
  • Applications may send their own sign-in notices.
  • A sign-in still in progress when you start or end is refused; start it again from the application.
  • After a timeout or lost access, this browser's sign-ins are refused until you choose Return to administrator sign-in.

Deployment

Pushes to main publish git.marut.network/exler/thermopylae:latest; v1.2.3 tags publish 1.2.3 and 1.2. CI needs the REGISTRY_USER variable and REGISTRY_TOKEN secret.

services:
    thermopylae:
        image: git.marut.network/exler/thermopylae:latest
        restart: unless-stopped
        ports: ["8080:8080"]
        environment:
            THERMOPYLAE_ISSUER: https://auth.example.com
            THERMOPYLAE_SECRET: ${THERMOPYLAE_SECRET}
            MADO_DSN: ${MADO_DSN:-}
        volumes:
            - thermopylae-data:/data
volumes:
    thermopylae-data:
docker compose exec thermopylae thermopylae admin create you@example.com

The container runs as UID 10001; bind-mounted /data must be writable by it.

Development

make test
make sql    # regenerate internal/db (needs sqlc)