Sign-in
The web interface signs users in through any OpenID Connect provider. There are no local passwords for the web interface. IMAP, POP3 and DAV use per-device app passwords instead; see Mail clients and Calendar, contacts and tasks.
Configuration
Set these variables on the server (they are read from the environment in
config/runtime.exs):
| Variable | Meaning |
|---|---|
OIDC_ISSUER | issuer URL of the provider |
OIDC_CLIENT_ID | client id registered at the provider |
OIDC_CLIENT_SECRET | client secret |
OIDC_REDIRECT_URI | callback URL registered at the provider |
OIDC_ADMIN_GROUP | optional group claim value that makes a user an administrator |
OIDC_CACERTFILE | optional CA certificate file for a provider with a private CA |
The redirect URI must match exactly, for example
https://mail.example.com/auth/callback.
When the issuer, client id, client secret or redirect URI is missing, the
login routes answer 503 and the rest of the application, including /health,
keeps working. OIDC is optional so that a server can be prepared before its
provider is connected.
The sign-in flow
GET /auth/loginredirects the browser to the provider. An optionalreturn_toparameter sends the user back to a safe local path afterwards.GET /auth/callbackfinishes the flow. The provider'ssubandemailclaims are required; the display name comes fromnameorpreferred_username, falling back to the email. A user row is created on first sign-in and updated on later sign-ins.POST /auth/logoutclears the session.
A user whose email changes at the provider keeps the same account, because
the account is keyed by the sub claim, not by the email. The email is
stored but is never used to attach a mailbox: an administrator attaches
mailboxes explicitly.
A disabled account is refused with 403. An account suspended through the provisioning API, or whose domain is, gets the same 403 with a message that says it is suspended and that nothing was deleted.
A user the provisioning API invited has no sub yet: the first sign-in whose email
claim is theirs and whose email_verified claim is true links it. A provider that
reports unverified emails as verified would let anyone who can register that address
take the invitation, so only use invitations with a provider that verifies emails. If OIDC_ADMIN_GROUP is set and the
user's group claims contain that value, the account becomes an administrator
and can open the admin pages at /admin.
Ending a person's sessions
A browser session is a signed cookie that lives 12 hours. Kantoor keeps one cut-off per
person, sessions_valid_after: a session that started before it is worth nothing, at the
next request and at the next page mount, and the person's open pages are disconnected at
once. The cut-off is set when
- an administrator disables the person (enabling again does not bring the old sessions back; they sign in anew),
- the identity provider tells Kantoor that the person logged out there (back-channel logout, below), or
- an operator runs
bin/kantoor rpc 'Kantoor.Release.sign_out_everywhere("name@example.com")'(on the running node: also disconnects open pages at once; withevalthe sessions end at their next request).
Each is written to the audit log (user.sessions_revoked, or the user.disable of the
admin page).
Back-channel logout
POST /auth/oidc/backchannel-logout (OpenID Connect Back-Channel Logout 1.0) takes the
provider's logout_token (form field). It has no session and no CSRF token: the token is
the proof. Kantoor checks its signature against the provider's keys (RS/ES/PS algorithms
only, never none or HMAC), the issuer, that the audience is Kantoor's client id, that
iat is within five minutes, that the logout event is present and that there is no nonce.
Then the account with that sub is signed out everywhere. A subject Kantoor does not know is
answered 200 too (the provider tells every application it knows); a token that does not
verify is 400; without a provider 503; more than 120 calls a minute from one address
429.
The check uses the provider's published keys (a set: the one the token's kid names, or
every key when the token has none). Authentik's token carries both sub and sid; a token
with only a sid and no sub is answered 400, because Kantoor looks the account up by
sub. There is no jti replay check: a replayed token can only sign the same person out
again, which is accepted.
What an end of sessions does not reach: IMAP, POP3, SMTP submission and DAV sign-in with app passwords, which are separate from browser sessions. Signing out everywhere and back-channel logout leave them alone; disabling the person (or suspending through the provisioning API) stops them, and an administrator can revoke a person's app passwords (Users, "Revoke all").
Set KANTOOR_TRUSTED_PROXIES to the proxy in front of Kantoor, or every caller of this
endpoint (and of every other rate limit) is counted as the proxy's address and shares one
bucket.
In Authentik the provider of Kantoor needs Logout URI
https://<kantoor host>/auth/oidc/backchannel-logout and Logout method Back-channel.
Authentik sends the notice when a person's session there is deleted; deactivating a person
alone does not delete sessions, so an operator who disables someone also deletes their
Authentik sessions.
Throttling
/auth/login and /auth/callback are throttled per client address: 20
requests in 60 seconds by default. The 429 response carries Retry-After.
The client address is the TCP peer unless the peer is inside
KANTOOR_TRUSTED_PROXIES, in which case the last proxy-supplied
X-Forwarded-For address is used. See
Installing Kantoor.
What an administrator can do
Administrators manage domains, mailboxes, users, held mail and the audit log
at /admin. They can attach a mailbox to a user and adjust quotas. A user
who is not an administrator gets 403 on those pages.
App passwords
After signing in, a user creates app passwords at Settings, App
passwords: one per device, each with only the scopes it needs (imap,
pop3, smtp, dav), an optional expiry, and a
label. The secret is shown once. Revoking a password takes effect
immediately, as does disabling the user.