Single sign-on (OpenID Connect)
OpenTodo can let people sign in with an identity provider you already run: Authentik, Keycloak, Authelia, Zitadel, Pocket ID, Kanidm, or a hosted login service. Any provider that supports OpenID Connect discovery and the authorization-code flow with PKCE works. Nothing is needed to run OpenTodo without it: the feature is off until you configure a provider.
On this page
What it does:
- Adds Sign in with <name> to the sign-in screen, next to the password form.
- Signs in the account linked to that identity. On the first sign-in, an identity whose provider says the email is verified is linked to the member account with that email, if that account's address was confirmed: through the emailed link of a sign-up or an email change, or by an earlier sign-on with the same verified address. The owner, admins, accounts with two-factor authentication or a passkey, and accounts whose address was never confirmed are never linked by email alone: they sign in as usual and link the provider in Settings → Account → Security → Linked accounts.
- Optionally creates a
memberaccount for someone who has no account yet (Allow new accounts via SSO), or when open sign-up is on. - Optionally requires single sign-on for everyone except the owner (SSO only).
- Optionally signs people out of the provider when they sign out of OpenTodo.
Network: when, and only when, a provider is configured, the server contacts the issuer's discovery document (<issuer>/.well-known/openid-configuration) and the token and key endpoints it lists. Requests time out after 10 seconds, do not follow redirects and go directly to the issuer: the HTTP_PROXY and HTTPS_PROXY environment variables are not used. Nothing else is contacted.
1. Set the public URL#
Providers only accept the exact redirect URI you register. Set OPENTODO_BASE_URL to the URL people use, with https:
OPENTODO_BASE_URL=https://todo.example.com
The redirect URI is then https://todo.example.com/api/v1/auth/oidc/callback. Settings → People → Single sign-on always shows the exact value; without OPENTODO_BASE_URL it is derived from the address in your browser and the panel warns you.
2. Create a client at the provider#
Create an OpenID Connect client ("application", "relying party"):
| Setting | Value |
|---|---|
| Client type | Confidential (a client secret). Public clients without a secret also work, PKCE is always used |
| Grant type | Authorization code |
| Redirect URI | https://todo.example.com/api/v1/auth/oidc/callback |
| Post-logout redirect URI | https://todo.example.com/ (only for provider sign-out) |
| Scopes | openid email profile |
| Signing algorithm | RS256, PS256, ES256 or EdDSA (RS256 is the usual default) |
| Client authentication | client_secret_basic or client_secret_post |
Make sure the provider sends email and email_verified in the identity token. Without a verified email an identity cannot be linked to an existing account or create one. For a provider that sends no email_verified at all, see Providers without email_verified.
Provider notes:
- Authentik: Applications → Providers → OAuth2/OpenID Provider. The issuer is
https://auth.example.com/application/o/<application-slug>/. - Keycloak: create a client with Client authentication on and Standard flow on. The issuer is
https://sso.example.com/realms/<realm>. Users need Email verified set for linking. - Authelia: add a client under
identity_providers.oidc.clientswithredirect_uris,scopes: [openid, email, profile]andrequire_pkce: true. The issuer is your Authelia URL. - Zitadel / hosted services: use a Web application with PKCE and the code flow; the issuer is shown on the application page.
- Synology SSO Server (DSM 7.4): add an application under Application List with the redirect URI above. The issuer is the Well-known URL without
/.well-known/openid-configuration. It sends noemail_verified, so a first sign-in is refused until you choose one of the two ways in Providers without email_verified.
3. Configure OpenTodo#
Open Settings → People → Single sign-on as the owner:
- Enter the Issuer URL, Client ID, Client secret and a Button label (for example "Home SSO").
- Click Test connection. OpenTodo fetches the discovery document and shows the sign-in and token hosts. An issuer that is not https, unreachable, or reports a different issuer is refused and nothing changes.
- Click Save. The sign-in screen now offers Sign in with Home SSO.
- Link your own account to check it: signed in as the owner, open Settings → Account → Security → Linked accounts and connect the provider. The owner account is never linked by email alone, so a provider account with your email cannot take it over.
Saving needs a recent sign-in, as for other sensitive settings; if your session is older than ten minutes you are asked for your password or a code first.
Configuration through the environment#
Infrastructure-as-code setups can set these optional variables instead. Each one overrides the value from Settings and locks that field in the panel:
| Variable | Purpose |
|---|---|
OPENTODO_OIDC_ISSUER |
Issuer URL (https) |
OPENTODO_OIDC_CLIENT_ID |
Client id |
OPENTODO_OIDC_CLIENT_SECRET |
Client secret |
OPENTODO_OIDC_DISPLAY_NAME |
Button label |
OPENTODO_OIDC_SSO_ONLY |
true or false; overrides the SSO-only switch (also the emergency switch, see below) |
The other switches (new accounts via SSO, provider sign-out, profile pictures, scopes) are set in the panel.
Profile pictures from the provider#
Use profile pictures from … (off by default) makes the server fetch, at each sign-in or link through the provider, the picture the identity token names in its picture claim (sent with the profile scope) and store it as the person's profile picture: cropped to a square, scaled to 256×256 and re-encoded as JPEG, so nothing but the pixels is kept. The rules:
- A picture someone uploaded themselves in Settings → Account → Profile is never replaced.
- An address that was already synced is not fetched again; a picture the person removed is not fetched again from the same address. A new address at the provider is picked up at the next sign-in.
- The fetch follows the server's outbound rules (http or https, no private network addresses unless Settings → Integrations → Webhooks allows them, 5 seconds, 2 MB, PNG, JPEG or GIF). A picture that cannot be fetched changes nothing; the sign-in completes either way.
Leave the switch off if the provider's picture addresses point to a host you do not want the server to contact.
Accounts and linking#
- An identity is recognised by its issuer and subject (
sub), never by email once linked. Changing your email at the provider keeps you on the same OpenTodo account, and a changed email cannot take over another account. - A first-time identity with a verified email that matches a member account whose address was confirmed is linked to it. The owner, admins, accounts with two-factor authentication or a passkey, and accounts whose address nobody confirmed (sign-up or email change without outgoing email) are refused (
oidc_link_required) and link only from Settings while signed in, so the provider can never stand in for their own second factor. An unverified or missing email is refused (oidc_email_unverified) and nothing is created, except that a provider sending noemail_verifiedat all may create a new account when you allow it (Providers without email_verified). - When nothing matches, a
memberaccount is created only if Allow new accounts via SSO is on orOPENTODO_ALLOW_SIGNUP=true. Otherwise the person sees "There is no account for this identity yet" and you can invite them. - Accounts created this way have no password. They can add a passkey in Settings → Account → Security.
- Everyone can link or unlink the provider in Settings → Account → Security → Linked accounts. Linking a new identity needs a sign-in in the last ten minutes; from an older session the app asks for your password or a code first, then sends you to the provider again. Unlinking is refused when it would leave the account with no way to sign in.
- Going through the provider again with an identity that is already linked counts as confirming it's you, so accounts without a password can still make changes that ask for a recent sign-in (the dialog offers Confirm with …).
- A provider sign-in counts as two-factor: someone with an authenticator app is not asked for a code, because the provider applies its own policy. If the owner requires two-factor for everyone (Settings → People → Access policies → Two-factor policy), accounts without an authenticator are still asked to enrol one.
Providers without email_verified#
Some providers, such as Synology SSO Server, send an email address but no email_verified claim. OpenTodo can't tell whether the address belongs to the person, so by default it refuses their first sign-in (oidc_email_unverified). There are two ways in:
- Link by hand (works for everyone, nothing to switch on). Create the person's account with a password, or invite them. They sign in with it once, then link the provider in Settings → Account → Security → Linked accounts. From then on the provider signs them in.
- Accept new accounts without a confirmed email. Turn this on in Settings → People → Single sign-on, together with Allow new accounts via SSO (or open sign-up). A sign-in without any
email_verifiedclaim can then create a new account. It never links to an existing account, whoever has that address: such an account still links by hand. An explicitemail_verified: falseis still refused, and the new account's address doesn't count as confirmed: until the person confirms it (an email change confirmed through a mailed link), adding that address to a project or workspace sends a placeholder invitation the account never sees, an invite link made for that address doesn't accept it, and OpenTodo sends no email to that address (no digest, reminders by email, password resets or invitations) except the one that confirms it.
Warning: turn the switch on only for a provider you control, where people cannot set their own address (for example DSM accounts whose address only the NAS administrator can set). Anywhere people can type any address, someone could create an account under another person's address. An account created under someone else's address also keeps the real holder from signing up or signing in with it: delete that account in Settings → People → Users and invitations. While the switch is on, the panel shows a warning and the server logs one at every start.
SSO only#
Require single sign-on refuses password and passkey sign-in, and password registration, for every account except the owner. Members see only the provider button. API tokens and the ot CLI keep working, because a token is already a delegated credential.
SSO-only mode only applies while a provider is configured: clearing the issuer turns it off too, so members are never locked out by removing the provider.
Break-glass access for the owner#
The owner always keeps their password (and passkeys):
- Open
https://todo.example.com/?owner=1to get the password form while SSO-only is on. - If the provider is down or misconfigured and you need to turn SSO-only off without signing in, set
OPENTODO_OIDC_SSO_ONLY=falseand restart the server. That environment value wins over the stored setting until you remove it. - If you also lost your owner password's second factor, see
opentodo mfa-resetin SECURITY.md.
Signing out#
Signing out of OpenTodo always ends the OpenTodo session only. With Sign out of <name> too on (and a provider that publishes an end_session_endpoint), people who signed in through the provider are then sent to the provider's sign-out page with an id_token_hint, and back to OpenTodo's sign-in screen afterwards. Register https://todo.example.com/ as a post-logout redirect URI at the provider for that.
In the Android and iPhone apps#
In the Android app and the iPhone app, Sign in with <name> opens the provider's page in the system's sign-in sheet (a Custom Tab on Android, Safari's sheet on iPhone) shows a page naming the account with Continue and Cancel, and brings the person back to the app signed in once they tap Continue. The tap keeps another app on the phone from finishing a sign-in silently. The sheet shares the browser's cookies, so someone already signed in to the provider there only picks the account. This is what lets providers that refuse sign-in inside an app work, Google among them ("Error 403: disallowed_useragent"). Linking the provider from Settings → Account → Security → Linked accounts in an app works the same way, and links it to the account signed in in the app.
Nothing needs configuring: the redirect URI stays the one above, and the server tells the apps it supports this in its health answer. Behind a reverse proxy, let /api/v1/health through. A server older than this (or one whose health answer the apps can't read) keeps the provider's page inside the app's web view, where such providers still refuse.
Offline#
An installed app that signed in through the provider opens offline from its cached account, like any other session; the provider is only contacted when someone signs in.
Troubleshooting#
| Symptom | Cause |
|---|---|
| The provider says the redirect URI is invalid | OPENTODO_BASE_URL is unset or differs from the registered redirect URI; copy the value from the panel |
| "Signing in with … did not work" | The code exchange or token check failed. The server log (level=WARN msg="oidc sign-in failed") names the step: wrong client secret, audience, clock skew over 60 seconds, unsupported signing algorithm |
| "did not confirm a verified email address" | The provider sends no email_verified: true; enable email verification or the email scope. A provider that sends no email_verified at all (Synology SSO Server): see Providers without email_verified |
| "This account is not linked to … yet" | The email belongs to the owner, an admin or an account with two-factor authentication or a passkey: sign in with the password (and code) and link the provider in Settings → Account → Security → Linked accounts |
| "There is no account for this identity yet" | Provisioning is off: invite the person, or turn on Allow new accounts via SSO |
| "That sign-in took too long or was started in another tab" | The 10-minute sign-in window passed, or the server restarted during the sign-in; start again |
Security notes#
- The flow uses PKCE (S256), a single-use
stateand anonce, kept in a signed,HttpOnly,SameSite=Lax, 10-minute cookie. The signing key is random per process. - Identity tokens are verified with the provider's published keys (refreshed when an unknown key id appears, at most every 10 seconds). Only RS256, PS256, ES256 and EdDSA are accepted;
noneand HMAC are refused; issuer, audience, expiry, issued-at and nonce are checked with 60 seconds of leeway. - The client secret is stored in
<data>/secrets/oidc.json(mode 0600), not in the database, so database backups do not contain it. Backups exclude the secrets directory: after restoring onto a new host, enter the secret again (or setOPENTODO_OIDC_CLIENT_SECRET).