Skip to content

Delete project bot when token is revoked

Serena Fang requested to merge revoke-token-delete-project-bot into master

What does this MR do?

When using Project Access Tokens a bot user is created to hold the access token. If the token is revoked, the bot user is converted to a ghost user and then blocked. After the revoke is complete the bot user is never actually deleted, which leads to a bunch of accounts lying around. So, this MR fully deletes the bot user after revoking the token and converting to a ghost user.

Considered using Users::DestroyService, as it migrates the user to a ghost user as well as deletes the user from database, but I don't think we can use Users::DestroyService because a regular user can create a project access token if can?(current_user, :admin_project, resource), but Users::DestroyService checks for Ability.allowed?(current_user, :destroy_user, user) and a regular user can't destroy another user.

Closes #244545 (closed)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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
Edited by Serena Fang

Merge request reports

Loading