POST /oauth/revoke - OAuth 2.0 Token Revocation (RFC 7009).
A client presents a credential it issued and asks the authorization
server to invalidate it. This controller owns the HTTP framing (require_https,
no-store cache headers, client authentication, and RFC 6749 §5.2 challenge
rendering) and delegates token revocation and :token_revoked event
construction to AttestoPhoenix.AuthorizationServer.Revocation.
Client authentication (RFC 7009 §2.1, RFC 6749 §2.3)
The revocation endpoint applies the same client-authentication rules as the
token endpoint. A confidential client authenticates with its exact registered
method, using the configured secret, private-key JWT, mTLS, or attestation
verification policy. A registered public client uses none and supplies its
client_id, as required by RFC 7009. Resolution is fail-closed: unknown,
revoked, or confidential clients cannot use the public path, and a request
that names no client is rejected invalid_client. Per RFC 6749 §5.2, a failed
Authorization header attempt returns HTTP 401 with the matching challenge;
body-only and absent credentials return HTTP 400 without a challenge.
The resolved client_id is then threaded into revocation so one client cannot
revoke another client's tokens (RFC 7009 §2.1).
No-existence oracle (RFC 7009 §2.2)
Once the client is authenticated, the response is always HTTP 200 with
an empty body, whether or not the presented token existed, was expired,
or was already revoked.
Refresh tokens only (RFC 7009 §2.1)
This endpoint revokes refresh tokens. Revoking one revokes its whole refresh family, so no later refresh can succeed. Access tokens are self-contained signed JWTs that resource servers verify without a lookup, and the endpoint keeps no per-token denylist for them:
- A presented access token is treated like any other token the server does
not hold: the response is
200and the access token stays valid until itsexp. RFC 7009 §2.2.1 definesunsupported_token_typefor this case; the endpoint answers200instead because common clients revoke the access token before the refresh token and stop at the first error, which would leave the refresh token live. - Revoking a refresh token does not invalidate access tokens already issued from its family. RFC 7009 §2.1 asks for that only from a server that supports access-token revocation.
Keep :access_token_ttl short so an access token outlives its refresh family
by at most that lifetime. A resource server that needs immediate access-token
revocation checks the token's jti (or the family claim named by
:authorization_grant_id_claim) against a host-maintained denylist.
Caching (RFC 6749 §5.1)
Every response carries Cache-Control: no-store and Pragma: no-cache,
so an intermediary never caches a revocation result.
Configuration
Built on AttestoPhoenix.Config. The callbacks this controller reads:
:load_client- resolve an OAuth client byclient_id.:verify_client_secret- constant-time client-secret comparison.:client_auth_method- the trusted registered authentication method.:on_eventor:event_sink(optional) - audit/telemetry hook; receives a:token_revokedAttestoPhoenix.Eventafter a successful revocation request.
The configured AttestoPhoenix.Config is read from
conn.private[:attesto_phoenix_config], placed there by the host's
router pipeline. The Attesto.RefreshStore revocation runs over defaults
to the package's Ecto-backed store; a host pipeline may override it by
putting a module under conn.private[:attesto_phoenix_refresh_store].
Summary
Functions
Handle POST /oauth/revoke (RFC 7009 §2.1).
Functions
@spec create(Plug.Conn.t(), map()) :: Plug.Conn.t()
Handle POST /oauth/revoke (RFC 7009 §2.1).
Authenticates the client, then revokes the presented refresh token and
its family. Always responds 200 once the client is authenticated,
regardless of whether the token existed.