Skip to content

Admin Token API: Identify Impersonation Tokens

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you can request access to GitLab Duo.

What does this MR do and why?

This MR updates docs and specification of the Admin Token API to reflect that it already supports Impersonation Tokens.

🛠️ with ❤️ at Siemens

References

MR acceptance checklist

checklist

How to set up and validate locally

  1. Enable feature flag via rails c:
Feature.enable(:admin_agnostic_token_finder)
  1. You'll need to create a personal access token to access the token and the impersonation 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 an impersonation token to query. Admin > Users > User-X > Impersonation tokens > Add 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 1.>' \
--header 'Content-Type: application/json' \
--data '{"token": "glpat-token-from-step-1-2"}'
{
	"id": 41,
	"name": "impersonation-token",
	"revoked": false,
	"created_at": "2024-11-27T09:58:50.186Z",
	"scopes": [
		"read_api"
	],
	"user_id": 83,
	"last_used_at": null,
	"active": true,
	"expires_at": "2024-12-27"
}

Related to #506501 (closed)

Edited by Nicholas Wittstruck

Merge request reports

Loading