Skip to content

Configuration ​

Auth Config ​

FieldTypeDefaultDescription
Basestring"/"URL prefix for all auth routes
UI.Titlestring"Sign in"Title shown on login page
UI.Subtitlestring""Text below the title
UI.Iconstring""Logo URL, data URI, inline SVG, or filename in embedded FS
UI.Versionstring""Version text shown in header
UI.ExternalFolderboolfalseUse your own login page instead of embedded UI
UI.SignupFirstboolfalseLand on the signup form instead of login (first-run bootstrap)
UI.Thememap[string]stringnilCSS variable overrides applied to :root at load (e.g. {"btn-bg": "#3b82f6"})
UI.CustomCSSURLstring""URL of a stylesheet appended to the login page for full restyling
CookieNamestring"auth_session"Session cookie name
Cookie.Pathstring"/"Cookie path
Cookie.MaxAgeint0Cookie max-age in seconds
Cookie.Domainstring""Cookie domain
Cookie.Securecookie.SecureModeautoauto (set when the request is HTTPS), always, or never
Cookie.DisableHTTPOnlyboolfalseExpose the cookie to JavaScript. HttpOnly is on by default
Cookie.SameSitehttp.SameSiteLaxCookie SameSite policy
IssuerConfig.AccessTTLtime.Duration15mAccess token lifetime, clamped to RefreshTTL
IssuerConfig.RefreshTTLtime.Duration7dRefresh token and maximum session lifetime
IssuerConfig.DisableRefreshRotationboolfalseTurn off refresh rotation. Rotation is on by default
MFA.CookieNamestring"auth_mfa"Pending-login cookie (only used with WithSecondFactor)
MFA.TTLtime.Duration5mHow long the user has to complete the second factor
MFA.MaxAttemptsint5Wrong codes tolerated before the pending login is destroyed
ProtectedResource*resource.ConfignilPublish RFC 9728 metadata. See Resource Server
DisableRequestAuthboolfalseTurn off request-credential auth in Require(), restoring cookie-only gating

Cookie.Secure defaults to auto: the Secure attribute is set when the request arrived over TLS, directly or via X-Forwarded-Proto. That protects real deployments without breaking http://localhost. Pin it to always when TLS terminates upstream and the proxy forwards no protocol hint.

OAuth2 Config ​

FieldTypeDefaultDescription
IssuerURLstring""OIDC issuer URL for auto-discovery
ClientIDstringrequiredOAuth2 client ID
ClientSecretstringrequiredOAuth2 client secret
Scopes[]string[]Requested scopes
AuthURLstringautoAuthorization endpoint
TokenURLstringautoToken endpoint
UserInfoURLstringautoUserInfo endpoint
RevocationURLstringautoToken revocation endpoint
LogoutURLstringautoEnd-session endpoint
JWKSURLstringautoKey set used to verify the id_token signature
AudiencestringClientIDValue required in the id_token aud claim
ClockSkewtime.Duration60sTolerance applied to exp / nbf
DisablePKCEboolfalseDisable PKCE (not recommended)
DisableNonceboolfalseOmit the OIDC nonce (not recommended)
SkipIDTokenVerifyboolfalseAccept an unverified id_token. Do not set this
PasswordFlowboolfalseEnable resource owner password flow
AuthHeaderStyleint0 (Basic)0=Basic, 1=Bearer, 2=Params

ID token verification ​

An id_token, when present, is always verified: RS/PS/ES/EdDSA signature against the IdP's JWKS, then iss, aud, exp, nbf and nonce.

Claims are taken from UserInfoURL when it is configured, otherwise from the verified id_token. With neither — no userinfo endpoint and no reachable key set — the login fails rather than falling back to an unverified payload. SkipIDTokenVerify exists for the single case of an IdP that publishes no key set on a trusted channel; it turns the id_token into an unauthenticated assertion of whatever the caller wants.

JWKS keys are cached. A successful fetch starts the normal one-minute refresh cooldown used to prevent unknown-key requests from amplifying traffic to the IdP. A failed fetch instead uses a bounded two-second retry backoff, so a brief provider outage does not suppress retries for a full minute. Concurrent misses share one refresh, while lookups of cached keys continue without waiting for the IdP. JWKS requests use the caller or configured client timeout, with a 30-second fallback only when neither supplies a deadline. An ID token with no kid is accepted only when the JWKS has exactly one usable key; with multiple keys it fails immediately as ambiguous without another fetch.

State, nonce and the PKCE verifier live together in one HttpOnly cookie (auth_flow_<name>), cleared after a single use. Override its attributes with Options.FlowCookie if the callback lands on a different subdomain.

Routes ​

With default Base: "/":

MethodPathDescription
GET/login/Login UI (embedded Svelte or external folder)
GET/login/infoJSON: title, subtitle, icon, version, strategies
GET/login/meCurrent user's Identity as JSON
GET/POST/login/pass/{strategy}Initiate or submit login
POST/login/register/{strategy}Create an account (strategy must implement Registerer)
GET/login/callback/{strategy}OAuth2 redirect callback
POST/login/refreshForce-refresh access token
POST/login/mfaComplete a second factor (only with WithSecondFactor)
POST/logoutRevoke session and clear cookie
GET/login/statusStatus iframe (for popup flow)
GET/.well-known/oauth-protected-resource[/…]RFC 9728 metadata, only when ProtectedResource is set. Mounted at the origin, not under Base, and never behind Require()

Request body limits ​

Auth endpoints enforce the following request-body caps:

RequestLimit
Local login and registration64 KiB
LDAP login64 KiB
Magic-link request64 KiB
OAuth2 password form64 KiB
TOTP second factor16 KiB
Passkey login begin or finish128 KiB

An oversized body receives JSON 413 Content Too Large with error code body_too_large; its message includes the applicable byte limit. The body is rejected before JSON or form parsing, so it is not misreported as malformed input.

POST /login/refresh rotates the server-side token pair and returns {"identity": ...}. It no longer returns session_id; the opaque session ID remains confined to the HttpOnly cookie and clients must not expect it in the JSON response.