Delete project bot when token is revoked
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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