Skip to content

Add Revoke buttons to the PAT tab of the Group credentials inventory

What does this MR do?

This MR adds the ability to revoke personal access tokens (PATs) from within the managed group credentials inventory. The PATs shown are only those created from within a managed group. PATs created outside the group are only revokable by an admin on the instance-level.

This change is behind a feature flag for now.

Screenshots

Confirming that the admin revoke still works as expected

admin-revoke

Group revoke in action

group-revoke

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Testing this requires setting up SAML first and enabling the feature flags noted in the documentation. Thereafter, you should see the Security & Compliance > Credentials menu option on your managed group.

To add new PAT tokens to your group, I would suggest the following:

  1. Connect to rails console in your terminal: rails console
  2. Run the following commands:
FactoryBot.definition_file_paths = [Rails.root.join('ee', 'spec', 'factories')]

FactoryBot.find_definitions

group = Group.find(ADD_YOUR_MANAGED_GROUPS_ID)

user = FactoryBot.create(:user, :group_managed, managing_group: group)

FactoryBot.create(:personal_access_token, user: user)
  1. You should now see the PAT(s) in the credentials inventory but cannot revoke
  2. Back in the console run Feature.enable(:revoke_managed_users_token, group)
  3. Refresh the credentials inventory and you should see the revoke button
  4. You can now try revoking the PAT(s) 😄

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team

Relates #214811 (closed)

Edited by Robert Hunt

Merge request reports