NeMo-Relay
NeMo-Relay copied to clipboard
[Enhancement]: Revoke the OIDC tokens at the issuer on auth logout
Affected area
Framework integrations, Documentation or examples
Problem or opportunity
nemo-relay auth logout (#1611) removes the local sign-in file and nothing else. Relay does not tell the issuer, so the refresh token and the access token stay valid there after logout.
The refresh token is the risky one. Anyone who has it can get new access tokens until it expires at the issuer.
Proposed enhancement
- Relay reads
revocation_endpointfrom the issuer's discovery document. - On
auth logout, Relay removes the sign-in file first. Then it revokes the tokens with RFC 7009: the refresh token first, then the access token. Each request sendstoken,token_type_hintandclient_id. - The revocation endpoint must be on the issuer's origin. Relay checks this at logout and not at sign-in, so sign-in still works with a bad endpoint.
- Relay gives up on revocation after 20 seconds in total.
- Logout exits 0 when the sign-in file is removed. It prints what the issuer did:
- the issuer revoked both tokens
- the issuer revoked the refresh token but not the access token, with the reason
- the issuer has no revocation endpoint
- the issuer revoked nothing, with the reason, for example an error or a timeout
Clerk revokes refresh tokens, but answers unsupported_token_type for its JWT access tokens. That is the second case.
Runtime contract and binding impact
N/A. Only the CLI logout changes.
Alternatives considered
- Revoke first, then remove the sign-in file. If the issuer is slow or broken, the file would stay on disk and the user would stay signed in. Removing the file first means logout always works on the machine.
- Exit with an error when revocation fails. The sign-in file is already gone then, so a non-zero exit would be wrong. Relay prints what failed instead.
Acceptance criteria
- On
auth logout, Relay revokes both tokens when the issuer publishesrevocation_endpoint. - Relay removes the sign-in file even when revocation fails, times out, or the endpoint is on another origin.
- Logout prints which tokens the issuer revoked. It never prints a token.
- Tests cover a full revocation, a refresh-only revocation, no endpoint, an issuer error, an issuer that cannot be reached and an endpoint on another origin.
authentication.mdxdescribes the new logout.
LGTM. Tracking the PR.