Skip to content

[5.x] Implement SMTP OAuth Client Credentials flow (frontend) - #25890

Merged
chippison merged 2 commits into
5.x-devfrom
dev-21041-smtp-oauth-settings-ui-5x
Dec 1, 2026
Merged

chippison merged 2 commits into
5.x-devfrom
dev-21041-smtp-oauth-settings-ui-5x

Conversation

@chippison

@chippison chippison commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

Backport of #25724 to 5.x-dev, for 5.14.4. Stacked on #25889 and has to be merged after it.

Changes from the original: leaves out the 6.x-only CoreAdminHome.mailSettingsUpdated event, adds the General_InvalidValueForParameter text 5.x lacked, and moves the Vue specs from vitest to jest. vue/dist is rebuilt by the 5.x build action.

DEV-21041
DEV-21051

Second half of the SMTP OAuth 2.0 work. It is stacked on #25889 (backend and [mail] config settings) and should be merged after it. This PR adds the OAuth fields to the email server settings form, so an admin no longer has to edit the config file.

Changes (Administration > System > General settings)

  • New "OAuth 2.0" entry in the authentication method dropdown. It shows the token URL, client ID, client secret and scope fields in place of the password field.
  • The admin picks how Matomo signs in: with a client secret or with a certificate.
  • The save is rejected when a required OAuth field is empty or the token URL is not a valid https:// URL.
  • Saving with OAuth 2.0 removes the stored SMTP password, because it is no longer used.
  • Saving forgets the cached access token, so changed settings apply to the next email.
  • The fields are regrouped: server (address, port, encryption), sender (from address, from name), login (method, username, password or OAuth fields).

Client secret

  • The page only ever gets *****, never the secret itself.
  • A stored secret is only kept when the SMTP server, token URL, client ID and scope stay the same. This way it is never sent to a newly entered address.
  • Saving with the certificate removes the stored secret. Switching back to the client secret later needs the secret entered again.

Certificate

  • The certificate path, key path and key password can only be set in config/config.ini.php. The form shows the certificate path but never changes or removes these settings.
  • While a certificate is set up, the SMTP server address is read-only in the form, and a save that changes it is rejected. It has to be changed in the config file, next to the certificate.
  • Only the server address is locked, because it decides who receives the access token. The token URL, client ID and scope stay editable: the private key is never sent anywhere, and the signed request to the token URL can't be reused by another endpoint.
  • The port and encryption stay editable too. They change how Matomo connects to the server from the config file, not which server gets the token.
Before After
image image

Testing

  • Controller integration tests and Vue component tests for the form.
  • Tested locally against a fake token endpoint and a small SMTP relay that only accepts AUTH XOAUTH2.
  • Not yet tested against a real Microsoft 365 tenant. A test tenant has been requested.

Checklist
[✔] I have understood, reviewed, and tested all AI outputs before use
[✔] All AI instructions respect security, IP, and privacy rules

tzi
tzi previously approved these changes Dec 1, 2026
Base automatically changed from dev-21041-smtp-oauth-client-credentials-5x to 5.x-dev December 1, 2026 20:32
@chippison
chippison dismissed tzi’s stale review December 1, 2026 20:32

The base branch was changed.

chippison and others added 2 commits December 2, 2026 09:33
Backport of #25724. Leaves out the 6.x-only mailSettingsUpdated event, adds the General_InvalidValueForParameter text 5.x lacked, and moves the specs to jest.
@chippison
chippison force-pushed the dev-21041-smtp-oauth-settings-ui-5x branch from 4761881 to ff55e15 Compare December 1, 2026 20:33
@chippison
chippison requested a review from tzi December 1, 2026 21:14
@chippison
chippison merged commit 3031e1c into 5.x-dev Dec 1, 2026
655 of 661 checks passed
@chippison
chippison deleted the dev-21041-smtp-oauth-settings-ui-5x branch December 1, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants