Skip to content

Add access level restriction to auth tokens#24450

Draft
mneudert wants to merge 6 commits into
5.x-devfrom
dev-14508
Draft

Add access level restriction to auth tokens#24450
mneudert wants to merge 6 commits into
5.x-devfrom
dev-14508

Conversation

@mneudert

Copy link
Copy Markdown
Member

Description

Until now, every auth token in Matomo inherited the full permissions of the user who created it. That meant a token shared with a third-party tool, or accidentally leaked, could do anything its owner could do — including superuser actions for superuser accounts. There was no way to hand out a "read-only" or "write-only" token without creating a separate user just for that purpose.

This PR introduces per-token access levels. When creating a new auth token, users can now choose the highest permission level the token is allowed to use: inherit the user's own access (the existing behaviour, and the default), or restrict the token to view, write, or admin. Superusers can also issue superuser-scoped tokens. The dropdown only offers levels the creator is themselves allowed to grant, so an admin user cannot mint a superuser token.

At request time, Matomo enforces the chosen ceiling across all entry points — the reporting API, tracker, and CLI alike. A token marked as write-only will be treated as write-only even if the underlying user account is a superuser, so the worst a leaked token can do is bounded by what was selected when it was created. Existing tokens are unaffected: a NULL access level continues to mean "inherit the user's access", which preserves the previous behaviour for every token created before the upgrade.

Checklist

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

Review

@mneudert mneudert self-assigned this Apr 29, 2026
@mneudert mneudert force-pushed the dev-14508 branch 2 times, most recently from b69ac61 to b99251c Compare May 5, 2026 10:12
@mneudert mneudert added this to the 5.11.0 milestone May 5, 2026
Comment thread plugins/UsersManager/Model.php
@github-actions

Copy link
Copy Markdown
Contributor

If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'.

@github-actions github-actions Bot added the Stale The label used by the Close Stale Issues action label May 20, 2026
@mneudert mneudert added Do not close PRs with this label won't be marked as stale by the Close Stale Issues action and removed Stale The label used by the Close Stale Issues action labels May 20, 2026
@sgiehl sgiehl modified the milestones: 5.11.0, 5.12.0 Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do not close PRs with this label won't be marked as stale by the Close Stale Issues action

Development

Successfully merging this pull request may close these issues.

2 participants