Skip to content

Name the granted and requested scopes in the authorization activity, PG-5168 - #44

Merged
snake14 merged 7 commits into
5.x-devfrom
PG-5168-activity-log-scopes
Jul 31, 2026
Merged

Name the granted and requested scopes in the authorization activity, PG-5168#44
snake14 merged 7 commits into
5.x-devfrom
PG-5168-activity-log-scopes

Conversation

@snake14

@snake14 snake14 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to #43. The authorization decision was already recorded with both the granted scope and the scopes the client requested, but the activity log described only the client, so neither could be seen without reading the stored payload. The description now names them, which is what makes the audit trail useful at a glance.

While in there, the activity descriptions are now translatable. Every description in this plugin was built in English with sprintf, unlike the activity classes in ActivityLog and the other plugins, so they could never be translated. Each variant is one complete sentence per translation key rather than assembled fragments, so the wording can be reordered when translated.

Decisions recorded before the scopes were stored keep describing the client on its own, since there is nothing else to show for them. That case is covered by a test so it cannot regress into printing empty parentheses.

No version bump: 5.3.0 has not shipped yet, so this goes in the same release section.

Issue No

PG-5168

Steps to Replicate the Issue

  1. Authorize an OAuth client, choosing a scope on the consent screen.
  2. Open Administration → Activity Log.
  3. Before this PR the entry reads "allowed OAuth 2.0 authorization request for client X" with no mention of scopes.
  4. With this PR it reads "… with scope matomo:write, requested matomo:read, matomo:write, matomo:admin". Denying instead names only the requested scopes, since nothing was granted.

Checklist

  • [✔] Tested locally or on demo2/demo3?
  • [✔] New test case added/updated?
  • [✔] Are all newly added texts included via translation?
  • [✔] Are text sanitized properly? (Eg use of v-text v/s v-html for vue)
  • [NA] Version bumped?
  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules
  • [NA] Documentation updated?

🤖 Generated with Claude Code

snake14 and others added 5 commits July 30, 2026 10:48
The authorization decision was recorded with both the granted scope and
the scopes the client requested, but the activity log described the client
only, so the scopes could not be seen without reading the stored payload.
The description now names them.

The descriptions go through translation keys, as the activity classes in
ActivityLog and the other plugins do, with one complete sentence per key
so the wording can be reordered when translated.

Decisions recorded before those scopes were stored keep describing the
client on its own, as there is nothing else to show for them.

Refs PG-5168

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The create, update, delete, rotate secret and pause or resume activities
still built their descriptions in English with sprintf, so they could
never be translated. They now use translation keys like the authorization
activity and like the activity classes in ActivityLog and the other
plugins.

The test covers every description in the plugin now, so it is named after
that rather than after the one activity it started with.

Refs PG-5168

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The activity classes extend one from ActivityLog, so the tests covering
their descriptions cannot load the classes at all unless that plugin is
installed, which it is not in CI by default.

The generator comment did not list the dependent plugins either, so
regenerating the workflow would have dropped the existing one as well.

Refs PG-5168

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The dependent plugin was declared but the workflow never passed a token,
so the checkout of the private repository was unauthenticated and skipped,
leaving the activity tests without the class they extend. The other
matomo-org plugins that depend on an innocraft plugin pass this token.

Refs PG-5168

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The workflow already passed this token, so adding it again left two
identical keys in the same step and the workflow file was rejected. The
checkout of ActivityLog failed for a different reason, which the duplicate
did nothing to address.

Refs PG-5168

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@snake14 snake14 added the Needs Review For pull requests that need a code review. label Jul 30, 2026
@snake14
snake14 requested a review from a team July 30, 2026 22:15
lachiebol
lachiebol previously approved these changes Jul 31, 2026

@lachiebol lachiebol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Few codex comments but not blocking

Blocking

  1. The new translation keys are not alphabetically ordered in lang/en.json:5. For example, UpdateClientActivity precedes DeleteClientActivity, and ResumeClientActivity precedes PauseClientActivity. This violates matomo-i18n-development-rules; reorder
    the new keys before merging.

Medium

  1. Two compatibility branches in Activity/AuthorizeClient.php:51 lack coverage: an allowed activity with a granted scope but no requestedScopes, and a historical denied activity without requestedScopes. tests/Integration/ActivityDescriptionsTest.php:43
    covers the other three paths. Adding these cases would protect rendering of stored historical entries.

snake14 and others added 2 commits July 31, 2026 12:50
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@snake14
snake14 merged commit 155c41b into 5.x-dev Jul 31, 2026
9 checks passed
@snake14
snake14 deleted the PG-5168-activity-log-scopes branch July 31, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review For pull requests that need a code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants