Repository navigation
feat(api): let an api token revoke itself via /api/v1/users/me/api-tokens/current/ (FOSS-835) - #60
Merged
Conversation
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
askii-access:<grant_id>. When the grant is revoked, the agent holds only that token and no session. Today/api/users/api-tokens/<pk>/is session-only and/api/v1has no token endpoint, so the agent cannot delete the token.apps/api/plane/api/views/user.pyaddsCurrentAPITokenEndpoint, served atDELETE /api/v1/users/me/api-tokens/current/:It reads
X-Api-Keyitself and uses no authentication class. Holding the key is enough to destroy it, so a token that is expired or inactive, or whose user is deactivated, can still be revoked. If that row stayed live, it would start working again once the user was reactivated.The revoke is a single soft-delete statement with no Celery cascade:
The response is 204 if a row changed. Otherwise it is 401 with
WWW-Authenticate: ApiKey realm="api".Only personal tokens with no dependents qualify. Bot tokens and tokens referenced by an Importer or WorkspaceIntegration get 401 and stay live; they keep using the session route and its cascade. The OpenAPI description says so.
This is the only
/api/v1route that answers a rejected key with 401 rather than 403. The OpenAPI description documents it.apps/api/plane/api/rate_limit.pyaddsApiKeyRevocationRateThrottle:api_keythrottle on this route.Retry-Afterheader are documented.apps/api/plane/api/urls/user.pyandviews/__init__.pyadd the route (DELETE only) and the export.Testing
plane/tests/contract/api/test_current_api_token.py(14 tests) and the existing key-auth and api-token suites:contract/api/test_authentication.py,contract/app/test_api_token.pyandunit/api/test_authentication_order.py. These ran against throwaway Postgres, Valkey and RabbitMQ containers./api/v1/users/me/.contract/apiandunitshow 14 failures on both this branch and untouchedfoss-sandbox. They are 429s on the shared fixture token and are unrelated to this change.ruff checkandruff format --checkare clean, and the OpenAPI schema generates without warnings.AI disclosure