pub async fn revoke(
__arg0: State<ApiState>,
headers: HeaderMap,
__arg2: Json<RevokeRequest>,
) -> ApiResponse<Value>Expand description
POST /api/v1/oauth/revoke — revoke an access or refresh token.
Stores a revocation marker in KV (oauth2_revoked_token:{token},
TTL’d to the refresh token’s own 30-day lifetime – not just the 7
days access-token revocation needs – since this one marker has to
outlive whichever token type was actually revoked) and, for JWT
tokens, also stores a JTI-based marker (revoked_token:{jti}) so
that all authenticated endpoints reject the token immediately. If
the token is a refresh token, also deletes its oauth2_refresh_token:
storage entry outright – handle_refresh_token_grant also checks
the revocation marker directly (failing closed on a storage error
there), so revocation is effective for the marker’s full TTL even if
the delete itself fails.
Only a token this server issued is acted on; anything else is a no-op that answers like
success (RFC 7009 section 2.2) and stores nothing. A token issued to an OAuth client
(it carries a client_id) is revoked only by that client (RFC 7009 section 2.1): a
confidential client authenticates with HTTP Basic or client_id / client_secret in the
body, a public one names itself with client_id; otherwise invalid_client. A token
with no client (a first-party session token) is revoked by whoever holds it.
§Example
let resp = revoke(State(state), HeaderMap::new(), Json(RevokeRequest {
token: "access_token_value".into(),
token_type_hint: Some("access_token".into()),
client_id: None,
client_secret: None,
})).await;
assert!(resp.success);