Skip to content

feat(dovecot): accept OIDC access tokens - #311

Draft
DavidePrincipi wants to merge 1 commit into
mainfrom
feat-8080
Draft

DavidePrincipi wants to merge 1 commit into
mainfrom
feat-8080

Conversation

@DavidePrincipi

@DavidePrincipi DavidePrincipi commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Let webmail applications and mail clients log in to the mail server with single sign-on (SSO), sending an OpenID Connect (OIDC) access token instead of a password, as part of NethServer/dev#8080. Roundcube needs this to log in to IMAP and SMTP for an SSO user.

When OIDC is configured, Dovecot also accepts the XOAUTH2 and OAUTHBEARER login mechanisms, and asks the provider whether each token is valid. Password logins keep working as before. Without OIDC settings nothing changes. For now the settings are written by hand: discovery of the provider comes later.

  • reload-config adds the token mechanisms, and writes the token check settings with the provider address and the client credentials
  • The password backends accept only the password mechanisms, so a rejected token is never tried as an LDAP password
  • Settings in state/oidc.env (OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, optional OIDC_INTROSPECTION_URL), mode 0600 and included in the backup, documented in the README

How to test

  • Register a client for the mail module with the register-client action of the idp module, without redirect URIs, and write its credentials to state/oidc.env as the README shows
  • Restart Dovecot and check that doveconf accepts the configuration
  • Log in to IMAP with XOAUTH2 or OAUTHBEARER and a token whose audience includes the mail module client: the login succeeds, while an altered token is refused
  • Check that password logins still work, and that a token sent as a password is refused

See also


Generated by Claude Code:claude-opus-5-5 with nethserver-pr

When the oidc.env file of the module state holds the issuer and the
client credentials, Dovecot accepts the XOAUTH2 and OAUTHBEARER
mechanisms, and validates the tokens with the introspection endpoint
of the provider. Webmail applications can then log in to IMAP and SMTP
with the SSO token of the user.

The password backends are restricted to the password mechanisms, so a
rejected token is not retried as an LDAP password, where failures
could count toward an account lockout.

The settings are written manually for now: provider discovery comes
later. The file is part of the backup, because it holds the client
secret.

Assisted-by: Claude Code:claude-opus-5-5
@DavidePrincipi DavidePrincipi self-assigned this Oct 2, 2026
@DavidePrincipi DavidePrincipi changed the title Dovecot: accept OIDC access tokens feat(dovecot): accept OIDC access tokens Oct 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant