Skip to content

Use format_with_prefix, ensure_prefix options of token auth strategy

Tianwen Chen requested to merge 385590-simplify-token-prefix-validation into master

What does this MR do and why?

As titled, this MR aims at:

  • support format_with_prefix option to specify the method name for token format instead of overriding the format_#{token_field} method, and change Ci::Build, Project, Group and PersonalAccessToken to use the new format option
  • use ensure_prefix to replace prefix to reduce the naming confusion for Project and Group

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

For personal access token:

  1. Go to User Settings -> Personal Access Tokens
  2. Fill in the name and choose a scope
  3. Click Create personal access token button
  4. Reveal the newly created personal access token and see if it's prefixed with glpat-

For group/project runners token:

  1. Create a group or project
  2. Go to CI/CD Settings
  3. Expand Runners section
  4. See if the runners registration token starts with GR1348941

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #385590 (closed)

Edited by Tianwen Chen

Merge request reports