Add an audit event for raw-token validity checks
What does this MR do and why?
Adds the secret_detection_raw_tokens_verified audit event to the raw-token validity checks API. Each request records one event on the project named by auth_project_id, with the caller's client_name, the number of tokens and the outcome counts by token type.
Token values are never recorded. token_type is caller input, so types the verifiers don't support are counted under unsupported rather than by name. As agreed in the 2026-11-19 sync, the event has no owner information: the endpoint only returns verdicts, and owner details are admin-level data.
The audit event is not required for the Customer Zero rollout, but has to land before the API opens to anyone else.
Resolves https://gitlab.com/gitlab-org/gitlab/-/work_items/637859
References
- Endpoint: !268618 (merged)
- Epic: https://gitlab.com/groups/gitlab-org/-/work_items/24471
- Threat model, T1: https://gitlab.com/gitlab-org/gitlab/-/work_items/637856#note_4223768884
How to set up and validate locally
-
Enable the flag for a project, in the Rails console:
Feature.enable(:validity_checks_raw_token_api, Project.find_by_full_path('gitlab-org/gitlab-test')) -
As a Developer of that project, with a PAT that has the
apiscope:curl --request POST "http://gdk.test:3000/api/v4/secret_detection/validity_checks_raw_token" \ --header "PRIVATE-TOKEN: <your_pat>" --header "Content-Type: application/json" \ --data '{"auth_project_id": "gitlab-org/gitlab-test", "client_name": "local-test", "tokens": [{"id": "1", "token_type": "gitlab_personal_access_token", "raw_token": "<your_pat>"}]}' -
Go to Secure > Audit events for the project. The event shows
client_name,token_countandoutcomes, and no token value.
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.