Single Sign-On (OIDC)
Sign in to self-hosted Rustrak with OpenID Connect (OIDC) through Pocket ID, Authentik, Keycloak, Google or any other OIDC provider.
Rustrak can sign people in through an OpenID Connect provider such as Pocket ID, Authentik, Keycloak or Google. Instead of keeping a separate password for Rustrak, people press Continue with Pocket ID on the login page, prove who they are to the provider, and come back signed in.
Why run it this way:
- One login for everything you host. The same account opens Rustrak, Grafana, Immich or anything else connected to the provider.
- One place to remove access. Disable someone at the provider and they can no longer sign in to Rustrak, or to anything else.
- Stronger sign-in for free. Passkeys, two-factor and password rules are the provider’s job, and Rustrak inherits them.
SSO is optional and sits beside password login: both keep working, and
nothing changes until OIDC_ISSUER_URL is set.
How a login works
Browser Rustrak Provider
│ Continue with Pocket ID │ │
│ ─────────────────────────▶ │ state, nonce and PKCE │
│ │ kept in the session cookie │
│ ◀─ redirect to provider ── │ │
│ ───────────────────────────────────────────────────────▶ │ sign in, consent
│ ◀──────────── redirect to /auth/sso/callback?code&state ─ │
│ ─────────────────────────▶ │ ── code + PKCE verifier ──▶ │
│ │ ◀──── signed ID token ───── │
│ │ checks signature, nonce, │
│ │ email; finds the account │
│ ◀── signed in, go to / ─── │ │Each piece guards against something specific:
| Piece | What it prevents |
|---|---|
state | A forged callback that would sign you in to someone else’s session |
nonce | An ID token issued for a different login being replayed into this one |
| PKCE | A stolen authorization code being exchanged by anyone but Rustrak |
| Signature check | A token that did not come from your provider |
All three one-time values live in Rustrak’s encrypted session cookie and are erased as soon as the callback reads them, so a callback URL cannot be used twice.
Rustrak remembers each person by the provider’s issuer and subject, an identifier that never changes. If someone’s email changes at the provider, their next login still reaches the same Rustrak account.
Set up Pocket ID
These steps assume Rustrak is served at https://rustrak.example.com and
Pocket ID at https://id.example.com. Replace both with your own addresses.
1. Create the client in Pocket ID
In Pocket ID go to Settings → Administration → OIDC Clients → Add OIDC Client and fill in:
- Name:
Rustrak. This is what people see on Pocket ID’s consent screen. - Callback URL:
https://rustrak.example.com/auth/sso/callback, exactly. It is the address Rustrak is reached at followed by/auth/sso/callback. - PKCE: on. Rustrak always sends it, so requiring it costs nothing.
Save, then open the client’s Credentials tab and add a client secret. Copy the Client ID and the secret.
2. Let people use the client
Open the client’s Allowed User Groups tab. A new client admits nobody: either choose the groups that may use Rustrak, or press Unrestricted to let every Pocket ID user through. Skipping this step shows “You are not allowed to access this service” on Pocket ID after signing in.
3. Check each user’s email is verified
Rustrak only trusts an email the provider marks as verified. In Pocket ID, open Users, edit each person and use the Mark as verified button next to the email. An unverified email is refused at login (see Troubleshooting).
4. Configure Rustrak
OIDC_ISSUER_URL=https://id.example.com
OIDC_CLIENT_ID=<client-id-from-pocket-id>
OIDC_CLIENT_SECRET=<client-secret-from-pocket-id>
OIDC_REDIRECT_URL=https://rustrak.example.com/auth/sso/callback
OIDC_PROVIDER_NAME="Pocket ID"
# Your Pocket ID decides who has an account, so let new people in.
OIDC_AUTO_PROVISION=trueShellRestart Rustrak. The log confirms it found the provider:
INFO rustrak::auth::oidc] OpenID Connect SSO enabled (Pocket ID)and the login page shows Continue with Pocket ID above the password form. If the provider cannot be reached, Rustrak keeps serving (error ingest and password login do not depend on it) and retries the discovery in the background with backoff. The log says why, and the login page shows the provider button once discovery succeeds, without a restart.
Who can sign in
The first time someone signs in through SSO, one of three things happens.
They are already linked. They go straight in. This is every login after the first.
An account already has their email. This is the usual case: you set up SSO on an instance where people, the administrator at least, already sign in with a password. Rustrak shows a Link your account page and asks for that account’s password once. Given correctly, the SSO identity is attached and from then on the provider alone is enough. Asking for the password proves the account belongs to the person signing in, so this is safe whatever the provider.
Nobody has their email. With OIDC_AUTO_PROVISION=true an account is
created for them as a member who sees nothing until someone gives them a
role. With provisioning off, which is the default, they are
turned away and someone has to invite them first. With
OIDC_ADMIN_GROUPS set the provider decides the role instead; see
Roles from provider groups.
SSO never hands an empty installation to whoever signs in first. Until it has
an owner, SSO only creates accounts for members of OIDC_ADMIN_GROUPS, as
owners, and turns everyone else away. Create the first owner with
CREATE_SUPERUSER or the bootstrap file, or
sign in first as a member of an admin group.
Choosing the switches for your provider
| Provider | OIDC_AUTO_PROVISION | OIDC_ALLOWED_DOMAINS | OIDC_LINK_EXISTING_ACCOUNTS |
|---|---|---|---|
| Your own Pocket ID, Authentik or Keycloak | true | optional | optional |
| Google Workspace or Microsoft Entra | true | your company domain | leave false |
| Public Google accounts | leave false | leave empty | leave false |
OIDC_AUTO_PROVISIONlets in anyone the provider vouches for. That is exactly what you want when you control who has an account at the provider, and exactly what you do not want with a provider anyone can sign up to. Rustrak logs a warning at startup when it is on without a domain allowlist.OIDC_ALLOWED_DOMAINSlimits SSO to emails at the listed domains, for exampleexample.com,subsidiary.example. It applies to every login, including people already linked.OIDC_LINK_EXISTING_ACCOUNTSskips the password question and attaches the identity straight to the matching account, provided the email is verified. Only turn it on with a provider whose users cannot pick an email they do not own. With a provider that lets people choose their address, it would let someone take over an existing account by claiming its email. An account SSO created from an unverified email is never linked this way.
Roles from provider groups
By default SSO never rewrites whether someone is an owner: a new account is a
member and an existing one stays what it was. To let the provider decide, name
the groups that mean owner, which the configuration and the API call admin:
OIDC_ADMIN_GROUPS=rustrak-admins
# OIDC_GROUPS_CLAIM=groupsShellFrom then on every SSO login refreshes that account’s global role: someone
in one of the listed groups becomes an admin, everyone else becomes a
member. Membership is re-read on each login, so adding someone to the group
promotes them the next time they sign in and taking them out demotes them the
same way. Accounts that sign in with a password are never touched.
This setting only decides owner or member. To give members roles from their groups, see Project roles from provider groups.
Worth knowing:
- The first account on the installation (the one
CREATE_SUPERUSERcreated) keeps itsadminrole even when its groups say otherwise. Every other safeguard protects that account from demotion, and this must not be the way around it. - Leaving
OIDC_ADMIN_GROUPSunset leaves every role exactly as it is. - On an installation with no owner yet, a member of an admin group is the only person SSO creates an account for, and that account is the owner. After that, a mapping nobody satisfies leaves only members: keep at least one person in an admin group.
The claim may be a JSON array (["rustrak-admins", "everyone"]) or a
comma-separated string, and group names are compared exactly, including case.
A provider that reports groups in roles, memberOf or anything else needs
OIDC_GROUPS_CLAIM set to that name. Groups are read from the ID token only,
so a provider that puts them in the UserInfo response instead will need to
move them (or use a client scope that copies them into the token).
Rustrak asks for openid email profile by default. If your provider only
releases groups behind a requestable scope, add it to OIDC_SCOPES, for
example OIDC_SCOPES="openid email profile groups"; others need a
provider-specific client scope or claim mapping instead. A claim the provider
does not send is an empty group list. With OIDC_ADMIN_GROUPS set, that
demotes the account to member on its next SSO login. Check the token’s
groups before turning the mapping on.
OIDC_ADMIN_GROUPS is itself comma-separated, so an admin group whose name
contains a comma cannot be named here (the same is true for a single string
claim). That is why only a string claim is split, and array entries never
are: an array entry is one group, whatever it contains.
Project roles from provider groups
OIDC_GROUP_ROLES gives roles from groups, on one project or
on all of them, the way Argo CD maps groups to project roles. Each entry is
<group>=<role name>[@<project slug>], and entries are separated by ;:
OIDC_GROUP_ROLES="shop-team=Viewer@storefront;platform=Developer"ShellHere shop-team holds Viewer on the storefront project only, so that is
the one project its members see, and platform holds Developer on every
project, including later ones. Create the roles first under
Settings → Roles.
Every SSO login syncs the account’s assignments of the roles the mapping names: the ones the current groups match are given, the rest are taken away. Roles the mapping does not name, given by hand in the dashboard, and personal permissions are never touched, and neither are accounts that sign in with a password.
Worth knowing:
- Roles are found by name and projects by slug when someone signs in, so a role or project created later works without a restart. An entry naming one that does not exist is logged and skipped; the login still succeeds.
- A role taken out of the mapping stops being managed: assignments it already gave stay until someone removes them in the dashboard.
- Assignments of a mapped role made by hand, including the ones creating a project extends to it, are replaced on the next SSO login.
- The group ends at the last
=and the project slug starts at the last@, so a group such ascn=devs,ou=groupsor a role name with a comma works. A malformed entry stops Rustrak at startup. - Groups come from the same claim as
OIDC_ADMIN_GROUPS, with the same caveats: ID token only, compared exactly.
Microsoft Entra ID
- In the app registration, Token configuration → Add groups claim, choose
Groups assigned to the application and tick it for the ID token.
Limiting it to assigned groups avoids Entra’s overage, where a user in more
than 200 groups gets no
groupsclaim at all. - Cloud-only groups arrive as object IDs, so the mapping names the GUID:
OIDC_GROUP_ROLES="1f2e3d4c-...=Viewer@storefront". - For readable names, define App roles on the registration, assign groups
to them in the enterprise application, and set
OIDC_GROUPS_CLAIM=roles. - Assignment required on the enterprise application keeps everyone outside the assigned groups from signing in at all.
SSO-only login
OIDC_DISABLE_PASSWORD_LOGIN=true hides the password form and makes
POST /auth/login answer 403, leaving the provider as the only way in.
The first account keeps working with its password as a documented
break-glass. It is the account CREATE_SUPERUSER created, and blocking it too
would leave a provider outage with no way back into the instance. Because the
login page must not advertise which account that is, it offers one generic
Sign in with a password link that reveals the form; every other account
gets 403 from it.
Invitations keep working, because without OIDC_AUTO_PROVISION they are the
only way to create an account. Accepting one creates the account with the
invitation’s role but does not sign the browser in: the invitee then signs in
through the provider. The password they chose is what confirms the link
between their SSO identity and that account, unless
OIDC_LINK_EXISTING_ACCOUNTS links it on the provider’s word.
Rustrak refuses to start when the switch is on without OIDC_ISSUER_URL,
because that combination could not sign anyone in at all.
Other providers
Any provider that supports OpenID Connect discovery works. Register
https://<your-rustrak>/auth/sso/callback as the redirect URI and point
OIDC_ISSUER_URL at the provider’s issuer:
| Provider | OIDC_ISSUER_URL |
|---|---|
| Pocket ID | https://id.example.com |
| Authentik | https://auth.example.com/application/o/<application-slug>/ |
| Keycloak | https://keycloak.example.com/realms/<realm> |
https://accounts.google.com | |
| Zitadel | https://auth.example.com (the instance domain) |
| Cloudflare Access | https://<team>.cloudflareaccess.com/cdn-cgi/access/sso/oidc/<client-id> |
The issuer is the address that serves
/.well-known/openid-configuration. Opening that URL in a browser is a quick
way to check you have the right one: its issuer field must match
OIDC_ISSUER_URL exactly.
Rustrak asks for the openid email profile scopes. The provider has to
return an email claim, and an email_verified claim set to true unless you
set OIDC_REQUIRE_EMAIL_VERIFIED=false.
Audiences besides the client ID
Rustrak signs someone in only when the ID token’s aud claim contains
OIDC_CLIENT_ID. Any other value in aud must be listed in
OIDC_ADDITIONAL_TRUSTED_AUDIENCES, so a token meant for another service is
never enough to sign in. When aud holds more than one value, the token must
also carry an azp claim equal to OIDC_CLIENT_ID.
OIDC_ADDITIONAL_TRUSTED_AUDIENCES=<audience>,<another-audience>ShellEach value is a string, whatever it looks like: a numeric ID, another
client ID or a URI such as api://rustrak. Values are compared exactly,
including case, and spaces around each one are ignored. A value that contains
a comma cannot be listed, because the setting itself is comma-separated.
The values to list are the ones the provider puts into aud next to the
client ID, and the log line for a rejected login names each one. For example:
- Zitadel always adds the project ID and the client ID of every other application in the project. A project of its own for Rustrak keeps the list to the project ID.
- Keycloak adds a value when the client has an Audience mapper with Add to ID token turned on.
Configuration reference
| Variable | Default | Description |
|---|---|---|
OIDC_ISSUER_URL | (disabled) | Provider issuer URL used for discovery. Setting it turns SSO on |
OIDC_CLIENT_ID | (required) | Client ID issued to Rustrak |
OIDC_CLIENT_SECRET | (required) | Client secret issued to Rustrak |
OIDC_REDIRECT_URL | (required) | Exact callback URL, ending in /auth/sso/callback |
OIDC_PROVIDER_NAME | SSO | Label on the login button |
OIDC_SCOPES | openid email profile | Space-separated scopes |
OIDC_AUTO_PROVISION | false | Create an account for someone whose email has none |
OIDC_LINK_EXISTING_ACCOUNTS | false | Link to an existing account without asking for its password |
OIDC_REQUIRE_EMAIL_VERIFIED | true | Refuse identities whose email the provider has not verified |
OIDC_ALLOWED_DOMAINS | (all) | Comma-separated email domains allowed to use SSO |
OIDC_GROUPS_CLAIM | groups | Claim carrying the identity’s groups |
OIDC_ADMIN_GROUPS | (none) | Comma-separated groups that grant the global admin role |
OIDC_GROUP_ROLES | (none) | ;-separated <group>=<role>[@<project slug>] entries; see Project roles from provider groups |
OIDC_ADDITIONAL_TRUSTED_AUDIENCES | (none) | Comma-separated audiences an ID token may carry besides the client ID. See Audiences besides the client ID |
OIDC_DISABLE_PASSWORD_LOGIN | false | Refuse password sign-in; the first account stays as break-glass |
The booleans accept true/false, 1/0, yes/no and on/off. An empty value
means unset. Anything else stops Rustrak at startup instead of silently
falling back to the default.
The issuer and every endpoint it advertises must use HTTPS. The one exception
is a provider on the same machine (localhost, 127.0.0.1 or ::1), which
may use plain HTTP.
Troubleshooting
When an SSO login fails, the login page only says it failed, so it tells a
stranger nothing about your accounts. The reason is in Rustrak’s log, on a
line that starts with SSO browser callback failed:.
| Log message | Cause | Fix |
|---|---|---|
SSO provider did not verify the email address | The provider did not send email_verified: true | Verify the email at the provider. In Pocket ID: Users → edit → Mark as verified |
No Rustrak account is linked to this SSO identity | Nobody has this email and provisioning is off | Invite the person, or set OIDC_AUTO_PROVISION=true |
Rustrak has no owner yet | The installation has no account and the person is in no OIDC_ADMIN_GROUPS group | Create the first owner with CREATE_SUPERUSER or the bootstrap file, or sign in first as a member of an admin group |
Email domain is not allowed to use SSO | The email is outside OIDC_ALLOWED_DOMAINS | Add the domain, or use an account at an allowed one |
SSO provider did not supply an email address | The provider returned no email claim | Make sure OIDC_SCOPES includes email and the provider releases it |
SSO session expired; please try again | The callback arrived without the values /auth/sso/start stored | See below |
SSO callback state did not match | The callback belongs to a different login attempt | Start again from the login page |
SSO authorization was denied | The provider returned an error, for example the person declined consent | Try again, and check the provider’s own log |
SSO authentication failed | The provider refused the code exchange, usually a wrong client secret | Check OIDC_CLIENT_ID and OIDC_CLIENT_SECRET. A line starting OIDC code exchange failed carries the provider’s answer |
SSO identity token is invalid | The ID token failed its checks: wrong audience, issuer or signature | Check OIDC_CLIENT_ID and that OIDC_ISSUER_URL matches the issuer in the discovery document. A line OIDC ID token validation failed: Invalid audiences: ... is not a trusted audience names an audience Rustrak does not trust, and its azp claim must be the client ID means a token with several audiences was issued to another client: see Audiences besides the client ID |
Account is disabled | The matching Rustrak account is deactivated | Reactivate it in Rustrak |
Password login is disabled; sign in through SSO | OIDC_DISABLE_PASSWORD_LOGIN=true and the account is not the first one | Sign in through the provider; the first account is the break-glass |
OIDC_DISABLE_PASSWORD_LOGIN is on, but SSO is not configured (at startup) | OIDC_DISABLE_PASSWORD_LOGIN=true without OIDC_ISSUER_URL | Configure SSO, or turn the switch off |
OIDC discovery failed, retrying in ...s | The provider is unreachable or its discovery document is invalid | Rustrak keeps serving and retries with backoff; check the URL and reachability. See below |
SSO is not configured or unreachable (404 from /auth/sso/*) | SSO is off, or discovery has not succeeded yet | Wait for discovery, or check the log line above |
SSO session expired almost always means the browser did not send
Rustrak’s session cookie back on the callback. Check that:
OIDC_REDIRECT_URLuses the same host you open Rustrak on. A dashboard opened athttp://127.0.0.1:8080with a redirect tohttp://localhost:8080/...loses the cookie, because the browser treats them as different sites.SESSION_SECRET_KEYis set. Without it Rustrak makes a new key at every start, and a restart between leaving for the provider and coming back invalidates the cookie.- The link was not opened twice. A callback URL works exactly once.
Errors shown by the provider, not by Rustrak:
- “You are not allowed to access this service” (Pocket ID): the client has no allowed user groups. See step 2.
- “Invalid redirect URI” or similar: the callback URL registered at the
provider differs from
OIDC_REDIRECT_URL. They must match character for character, includinghttpversushttpsand any trailing slash.
Rustrak will not start:
OIDC_CLIENT_ID is required when OIDC_ISSUER_URL is configured: set all four ofOIDC_ISSUER_URL,OIDC_CLIENT_ID,OIDC_CLIENT_SECRETandOIDC_REDIRECT_URL, or none of them.Invalid OIDC issuer URL, ormust use HTTPSfor the issuer URL: it is malformed, or plain HTTP on a host other thanlocalhost. The issuer is validated before the server starts, since no retry can fix it.OIDC_DISABLE_PASSWORD_LOGIN is on, but SSO is not configured: setOIDC_ISSUER_URLtoo, or turn the switch off. Password login would be the only way in and it is off.
SSO is not offered on the login page:
OIDC discovery failed, retrying in ...s: Rustrak could not read<OIDC_ISSUER_URL>/.well-known/openid-configuration, or a discovery attempt timed out. It keeps serving ingest and password login, and retries with a growing delay (30 seconds, then up to 15 minutes), so the provider coming back needs no restart. Check the URL and that the Rustrak container can reach the provider over the network; the log line repeats until it succeeds./auth/sso/configreportsenabled: falsewhile discovery is failing, and the login page hides the provider button.OIDC SSO is off: ... must use HTTPS: the provider advertises a plain-HTTP authorization or token endpoint. This is checked during discovery, after startup, so Rustrak keeps running with SSO off; the entry is logged once and not retried, because no retry can fix it. Fix the provider, then restart.
Try it locally
You can run the whole flow on your machine with Pocket ID in Docker. Plain
HTTP is accepted because both run on localhost.
docker run -d --name pocket-id -p 1411:1411 \
-e APP_URL=http://localhost:1411 \
-e ENCRYPTION_KEY=$(openssl rand -hex 32) \
-v pocket-id-data:/app/data \
ghcr.io/pocket-id/pocket-idShell- Open
http://localhost:1411/setupand create the first Pocket ID user. You can skip adding a passkey:docker exec pocket-id /app/pocket-id one-time-access-token <username>prints a one-time sign-in link whenever you need one. - Follow Set up Pocket ID with
http://localhost:8080/auth/sso/callbackas the callback URL. - Start Rustrak with
OIDC_ISSUER_URL=http://localhost:1411,OIDC_REDIRECT_URL=http://localhost:8080/auth/sso/callbackand the client ID and secret, then openhttp://localhost:8080/login. Uselocalhost, not127.0.0.1, for the reason in Troubleshooting.
To remove it afterwards: docker rm -f pocket-id && docker volume rm pocket-id-data.