Audit changes to an OAuth application's declared granular scopes
What does this MR do and why?
The declaring service replaces the whole set of fine-grained permissions an OAuth application declares, but nothing recorded that change. The oauth_application_created event lists only the legacy scopes.
This MR emits oauth_application_granular_scopes_updated from Authz::OauthApplicationGranularScopes::DeclareService when the declared set changes. The event details hold the previous and the new set, so you can see what the application could hand out before and after.
- Saving the same set again emits nothing, and neither does a refused declaration.
- A group-owned application records the event on its group. Instance and user-owned applications record it on the acting user, like the other OAuth application events.
- Both sets are listed in a stable order. W3.4: Revoke consent grants and tokens when an ... (#633690) will compare the same signature to decide whether to revoke consent grants.
Creating an application with a declared set now records two events: this one, then oauth_application_created.
Everything is behind the granular_oauth_tokens feature flag, so there is no changelog entry.
References
- W3.5: Emit an audit event when an OAuth applica... (#633689 - closed)
- Granular OAuth tokens for the MCP server: remai... (#630327)
Screenshots or screen recordings
No UI change.
How to set up and validate locally
I checked this with specs only and did not run it in a local instance. To check it by hand, on an instance with an Ultimate license:
-
In the Rails console, enable the flag:
Feature.enable(:granular_oauth_tokens) -
As an administrator, create an instance application with a declared set:
curl --request POST \ --header "PRIVATE-TOKEN: <admin_token>" \ --header "Content-Type: application/json" \ --data '{"name": "Audit test", "redirect_uri": "http://localhost/callback", "scopes": "api", "granular_scopes": [{"access": "user", "permissions": ["execute_mcp_tool"]}]}' \ --url "http://gdk.test:3000/api/v4/applications" -
Go to Admin > Monitoring > Audit events. The list has two new events for the application:
OAuth application granular scopes updatedandOAuth application added.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.