feat: validate CTE actor token pairing and surface act claim for delegation/impersonation#122
Merged
Merged
Conversation
The act-claim enrichment in custom_token_exchange ran _verify_and_decode_jwt with no error handling, so a present-but-undecodable id_token turned an already-issued exchange into a generic TOKEN_EXCHANGE_FAILED. It also skipped the normalized issuer check the login path applies before trusting claims. Wrap the enrichment so any decode/verify failure leaves act=None instead of failing the exchange, and apply the issuer check before reading the claim. Rewrite the opaque-token test (it never exercised the decode path) and add coverage for the undecodable-id_token and issuer-mismatch cases.
nandan-bhat
reviewed
Jun 23, 2026
…urcing Add local empty/whitespace guards for subject_token_type and actor_token so they fail with a clear INVALID_TOKEN_FORMAT instead of a generic round-trip error from the token endpoint, matching the existing subject_token check. Add tests for both cases. Document that response.act is read from the id_token and that Auth0 writes the same act onto the access token (verified against the platform token dialects), noting the access token may be opaque. Add a comment on the login path noting act reaches the session user via UserClaims. Rename the refresh test to reflect that it pins the state-merge behavior the refresh path uses.
rmad17
reviewed
Jun 24, 2026
rmad17
reviewed
Jun 24, 2026
rmad17
approved these changes
Jun 25, 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.
📋 Changes
This PR completes Custom Token Exchange (CTE) Delegation/Impersonation support (RFC 8693) in auth0-server-python. CTE input validation moves into the exchange methods so callers get typed
CustomTokenExchangeErrors with specific codes, theactor_token/actor_token_typepairing is enforced in both directions, and theactclaim from a delegation/impersonation exchange is surfaced to the developer.✨ Features
custom_token_exchangeandlogin_with_custom_token_exchangenow rejectactor_tokenwithoutactor_token_type(MISSING_ACTOR_TOKEN_TYPE) andactor_token_typewithoutactor_token(MISSING_ACTOR_TOKEN), matching how Auth0 enforces the pair.actclaim surfacing: When an exchange includes an actor token, the SDK verifies the returned ID token and exposes the RFC 8693 §4.1actclaim onTokenExchangeResponse.act(stateless) and on the persisted session user, readable back viaget_user()(session-creating).Bearer-prefixed tokens now raiseCustomTokenExchangeError(INVALID_TOKEN_FORMAT).🔧 API Changes
CustomTokenExchangeErrorCode.MISSING_ACTOR_TOKENTokenExchangeResponse.act: Optional[dict[str, Any]]custom_token_exchange/login_with_custom_token_exchangeand raisesCustomTokenExchangeErrorwith a specific code (INVALID_TOKEN_FORMAT,MISSING_ACTOR_TOKEN_TYPE,MISSING_ACTOR_TOKEN)📖 Documentation
examples/CustomTokenExchange.mdwithactread-back (stateless and session), the refresh-token suppression note, and theMISSING_ACTOR_TOKENerror code🧪 Testing
Contributor Checklist