Skip to content

Admin Token API: Revoke pipeline trigger tokens

What does this MR do and why?

This MR adds support for revocation of pipeline trigger tokens to the Admin token API. In this case, revoation is done by deleting the token.

Issue: #517491 (closed)

🛠️ with ❤️ at Siemens

References

MR acceptance checklist

checklist

How to set up and validate locally

  1. Enable the feature flag with rails c:
Feature.enable(:api_admin_token_revoke)
  1. You'll need to create a personal access token to access the token and the pipeline trigger token that you'd like to query:
    1. Create a personal access token with admin_mode and api capabilities. Preferences > Access Tokens > Add a new token
    2. Create a new pipeline trigger token to query. Project > Settings > CI / CD > Pipeline trigger tokens > Add new token
  2. Now you can retrieve information about this token:
curl -k --request POST \
--url 'https://gdk.test:3443/api/v4/admin/token' \
--header 'Authorization: Bearer <Admin Token from Step 2.>' \
--header 'Content-Type: application/json' \
--data '{"token": "glptt-token-from-step-2-2"}'
  1. Now, revoke the token:
curl -k --request DELETE \
--url 'https://gdk.test:3443/api/v4/admin/token \       
--header 'Authorization: Bearer <Admin Token from Step 1.>' \
--header 'Content-Type: application/json' \
--data '{"token": "glptt-token-from-step-2-2"}'
  1. Query the token again - you should now see that the status changed to Not Found, as the trigger no longer exists. You can also see this is in the Projects > Settings > CI / CD > Pipeline Trigger Tokens.

Related to #517491 (closed)

Edited by Nicholas Wittstruck

Merge request reports

Loading