Skip to content

Add Rake task to show/edit token expiration info

Stan Hu requested to merge sh-rake-task-analyze-tokens into master

What does this MR do and why?

This merge request adds two Rake tasks:

  • gitlab:tokens:analyze
  • gitlab:tokens:edit

Both tasks give a readout to the admin about:

There should be a strong correlation with the migration dates and the expiration dates. Seeing both of them together helps focus on the tokens that were assigned an expires_at field in the background migration.

The second task allows admins to easily update the groups to either extend or remove the expiration date entirely.

Relates to #467313 (closed) and #467416 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

rake gitlab:tokens:analyze

image

rake gitlab:tokens:edit

image

How to set up and validate locally

I seed my database this way:

expiry = Date.parse('2024-06-14')
user = User.find(1)

1_000_000.times.each do |index|
  token = PersonalAccessToken.new(name: "random-#{index}", expires_at: expiry, user: user, scopes: ["api"])
  token.save
end

Then run gitlab rake gitlab:tokens:edit.

Edited by Adil Farrukh

Merge request reports