Skip to main content
Version: v1.24.0

Auth & sessions

Two packages cover this ground: pkg/auth handles authentication (sessions, passwords, JWT, the backend chain) and pkg/authz handles authorization (role-based access control). This section splits them by the question you are actually asking:

  • Your first login — the complete worked slice: a users table, a UserProvider, POST /login through the authentication chain, session, logout, CSRF. Start here if you are building sign-in for your own application.
  • RBAC & the middleware chain — the default-deny policy gate, and why your first session-authenticated route answered 403. Read this one before adding more middleware.
  • Sessions & passwords — session stores, cookie defaults, RenewToken/Destroy, bcrypt hashing.
  • JWT — stateless auth, from a single secret to a rotating keyset with a public JWKS endpoint.
  • Backends & federated sign-in — the ordered auth_backends chain, LDAP, writing your own backend, the conformance suite, and OIDC/SAML identity providers.

Which mechanism is which

You wantUsePage
Sign in users of your app against your tableauth.UserProvider + the chainYour first login
Sign in against a corporate directoryauth_backends: [ldap, local]Backends
"Sign in with …" via an identity providerauth_federated (OIDC/SAML)Backends → Federated
Stateless tokens for APIs and servicesJWTManagerJWT
Decide who may reach which routepkg/authz policy gateRBAC & middleware
Admin accounts for the orbit panelnucleus createuserorbit

Identity travels through the request context as auth.Claims (auth.ContextWithClaims to inject, auth.ClaimsFromContext to read); the RBAC gate, log attribution and your handlers all read the same claims.