RFC 7009 — OAuth 2.0 Token Revocation

Implemented (apiauth/RevocationHandler)

RFC 7009 — OAuth 2.0 Token Revocation

Status: Standards Track
Published: 2013-08
L-tier / T-tier: L2 · T8 (lifecycle)
OneAuth coverage: Implemented (apiauth/RevocationHandler)
See also: RFC_7662.md · RFC_9700.md · LANDSCAPE.md

In one sentence

Token revocation gives clients (and servers) a way to invalidate tokens
before their natural expiry — the “Disconnect app” / “Log out everywhere”
mechanism.

What problem does it solve?

Without 7009 With 7009
Refresh tokens last days/weeks/months; revoking requires custom vendor APIs One standardized endpoint; one form parameter
User logs out but their tokens stay valid until expiry — leaked-credential window Tokens dead immediately on revoke
Refresh-token rotation reuse detection needs a place to land the “burn the family” action Revocation cascades cleanly through token families
Compliance/security teams can’t audit token lifecycle endpoints — they don’t exist Standardized audit point for revocation events

7009 is the simplest L2 RFC. Two pages of normative text. The endpoint
returns 200 OK whether or not the token was found (per §2.2). Clients
don’t get error feedback about why a revocation may have failed, by
design (don’t leak token existence).

Relatable example

You’re using a third-party calendar integration on your phone. You uninstall
the app. The app’s last lifecycle hook fires, and the app calls:

POST /oauth/revoke HTTP/1.1
Host: calendar-api.example.com
Authorization: Basic <client-creds>
Content-Type: application/x-www-form-urlencoded

token=long-lived-refresh-abc123&token_type_hint=refresh_token

Server returns 200 OK. The refresh token is now dead. Any access tokens
still descended from it (token family) are also revoked. Even if a backup
of the device leaks the token six months later, it’s already dead at the
server.

The “Disconnect this app” buttons in every IdP’s dashboard are 7009 calls
under the hood.

Key concepts

  1. Two parameters: token and token_type_hint. The hint is
    access_token or refresh_token; AS uses it for lookup ordering but
    doesn’t require accuracy. AS searches its token store and revokes
    whichever it finds. OneAuth checks the refresh store first and then
    tries the token as an access token, whatever the hint says.
  2. 200 OK is the only success response. Per §2.2, ASes MUST return
    200 OK regardless of whether the token was found, already revoked,
    or never existed. This is a deliberate information-leak defense.
    §2.1 also has the AS check that the token was issued to the calling
    client. OneAuth answers 400 invalid_request for a token issued to
    another client (ErrRevokeNotOwner), as Keycloak does, and 400 for a
    request with no token (0.1.45).
  3. Caller authentication required. Same as introspection — only
    authorized parties (clients revoking their own tokens, or admin
    tooling) should be able to revoke.
  4. Revoking a refresh token revokes the family. §2.1 says revoking a
    refresh token SHOULD also invalidate the access tokens issued from the
    same grant. OneAuth records each access token’s jti and expiry on
    the refresh token it was issued with (RefreshTokenStore.RecordAccessToken),
    so revoking any member of the family revokes the whole family and
    blacklists every unexpired access token it minted: the one from login
    and every one from refreshing since. That needs OneAuthConfig.Blacklist;
    without one the refresh tokens die and the access tokens run out their
    lifetime (issue 436).
  5. Idempotent. Revoke twice == revoke once. Safe to retry.

Wire example

POST /oauth/revoke HTTP/1.1
Host: as.example.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic czZCaGRSa3F0Mzo3RmpmcDBaQnIxS3REUmJuZlZkbUl3

token=2YotnFZFEjr1zCsicMWpAA&token_type_hint=refresh_token
HTTP/1.1 200 OK

Empty body. That’s the entire happy path. Errors (failed caller
authentication) get JSON error responses per §2.2.1 — but the token not
found / already revoked / wrong type
cases all return success.
In OneAuth a missing token and a token issued to another client are also
errors, each a 400 invalid_request.

Where it lands on the OAuth abstraction

  • L2 lifecycle. Revocation is the write side; introspection is the
    read side.
  • T8 (lifecycle event). Refresh / revoke / logout — the post-flow
    cleanup phase.
  • Couples tightly with RFC 9700 §4.14 (refresh token rotation with
    reuse detection). The family-revoke on reuse is exactly the operation
    this endpoint exposes for explicit invocation.

OAuth 2.0 status

Part of the 2.0 ecosystem from 2013. Widely deployed; every major IdP ships
a revocation endpoint. Often advertised as part of OIDC RP-Initiated
Logout flows.

OAuth 2.1 status

Not changed by 2.1. The revocation endpoint stays put with the same
semantics. 2.1’s contribution to lifecycle is requiring refresh-token
rotation with reuse detection (RFC 9700 §4.14) — and the reuse-detection
path uses revocation internally via the family-revoke action.

OneAuth status

7009 surface Status Where (grep-verified) Notes
POST /oauth/revoke endpoint Implemented apiauth/revocation.go RevocationHandler.ServeHTTP, built by OneAuth.RevocationHTTPHandler RFC 7009 §2 compliant. The reference server mounts it at the advertised /oauth/revoke since 0.1.51
token + token_type_hint parsing Implemented RevocationHandler.ServeHTTP A missing token is 400 invalid_request (0.1.45). Every token type is searched whatever the hint: tokenRevoker.Revoke (apiauth/token_revoker.go) checks the refresh store, then the access token (0.1.45)
200 OK for not-found, invalid and already-revoked tokens Implemented RevocationHandler.okResponse Doesn’t leak token existence
Caller may revoke only its own tokens (§2.1) Implemented tokenRevoker.Revoke returns ErrRevokeNotOwner (apiauth/interfaces.go) 400 invalid_request, matching Keycloak (0.1.45). TestKeycloakCompare_Revocation in tests/keycloak/revocation_interop_test.go pins the cross-client and missing-token answers against Keycloak (0.1.54)
Access tokens verified before blacklisting Implemented tokenRevoker.revokeAccessToken runs TokenRevokerConfig.Validator before blacklisting the jti A forged token naming another token’s jti revokes nothing. Without a validator or blacklist, access tokens are not blacklisted (0.1.45)
Caller authentication via HTTP Basic Implemented RevocationHandler.ServeHTTP rejects unauthenticated callers with 401 invalid_client; WWW-Authenticate: Basic realm="revocation" —
Refresh-token revocation, with its access tokens (§2.1) Implemented tokenRevoker.Revoke calls RefreshTokenStore.RevokeTokenFamily and blacklists the access tokens it returns Every grant that issues a refresh token (password, authorization code, device code, refresh) records its access token on it with RecordAccessToken. Access tokens are blacklisted only with OneAuthConfig.Blacklist. Contract suite in refreshtokentest, run by FS, GORM and GAE (issue 436)
Reused authorization codes Implemented apiauth/authorize_granter.go authorizationCodeGranter.refuseReuse A second redemption blacklists the code’s access token (with OneAuthConfig.Blacklist) and revokes its refresh family (0.1.57, issue 429)
Idempotency Implemented Revocation is state-set, not state-toggle Safe to retry

When NOT to use it

You will always ship a revocation endpoint on a production AS. The carve-out:

  • Pure access-token-only deployments (no refresh tokens, short-lived
    access tokens, no client logout UX) can skip revocation — tokens expire
    fast enough. Rare in practice.
  • RFC 7662 — Introspection; the read side of token state
  • RFC 9700 — §4.14 ties revocation to refresh rotation
  • RFC 6749 — the framework whose tokens this revokes
  • RFC 8628 — Device flow; revocation revokes device-flow tokens too
  • OIDC RP-Initiated Logout 1.0 — uses 7009 under the hood for token cleanup on logout