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

How to set up and validate locally

  1. 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'))
  2. As a Developer of that project, with a PAT that has the api scope:

    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>"}]}'
  3. Go to Secure > Audit events for the project. The event shows client_name, token_count and outcomes, 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.

Merge request reports

Loading
Loading