Skip to content

PoC: add Session Transfer Token (STT) support for impersonation via session transfer#126

Open
kishore7snehil wants to merge 2 commits into
mainfrom
poc/cte-stt-support
Open

PoC: add Session Transfer Token (STT) support for impersonation via session transfer#126
kishore7snehil wants to merge 2 commits into
mainfrom
poc/cte-stt-support

Conversation

@kishore7snehil

@kishore7snehil kishore7snehil commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

📋 Changes

PoC - this is a proof-of-concept for Custom Token Exchange (CTE) Impersonation via Session Transfer in auth0-server-python. It adds the initiator surface and is verified end-to-end against a live tenant. Tests and the auto-source-actor convenience are deliberately deferred (see Scope below).

Custom Token Exchange Release 1 added the act claim for delegation. It adds the Session Transfer Token (STT) path: an application requests a short-lived, single-use STT via CTE, then redirects the agent's browser to a target app's login URL carrying the STT, which is redeemed at /authorize to establish an impersonated web session as the customer. This PR implements the initiator side of that flow.

✨ Features

  • request_session_transfer_token(...) - performs a custom token exchange against the urn:{domain}:session_transfer audience and returns the STT. The audience is built from the SDK's resolved request domain (so it is correct under multiple custom domains). Requires an actor_token; raises CustomTokenExchangeError(ACTOR_UNAVAILABLE) client-side if none is provided.
  • build_session_transfer_redirect(target_login_url, result, organization=None) —-pure helper that returns the redirect URL handing the STT (and optional organization) to the target app's login URL. Reuses the existing URL.build_url helper. Performs no network call and writes nothing to the session.

🔧 API Changes

  • New SessionTransferTokenResult model (session_transfer_token, issued_token_type, expires_in, token_type, scope)
  • New module constant SESSION_TRANSFER_TOKEN_TYPE (urn:auth0:params:oauth:token-type:session_transfer_token)
  • New error codes on CustomTokenExchangeErrorCode: ACTOR_UNAVAILABLE (raised client-side), SETACTOR_REQUIRED, SESSION_TRANSFER_DISABLED (server-side cases; surfaced via the raw server error/error_description)

All additions are additive - no existing types, methods, or behavior change.

Contributor Checklist

…session transfer (PoC)

Adds the initiator surface for CTE Impersonation via Session Transfer (Release 2):
- request_session_transfer_token(): mints an STT via custom token exchange against the
  urn:{domain}:session_transfer audience (domain resolved per-request for MCD)
- build_session_transfer_redirect(): builds the redirect URL handing the STT to the
  target app's login URL (reuses URL.build_url)
- SessionTransferTokenResult model and SESSION_TRANSFER_TOKEN_TYPE constant
- CustomTokenExchangeErrorCode: ACTOR_UNAVAILABLE, SETACTOR_REQUIRED, SESSION_TRANSFER_DISABLED

Additive and non-breaking. Explicit-actor scope; auto-source-from-session and tests deferred.
@kishore7snehil kishore7snehil requested a review from a team as a code owner June 26, 2026 13:11
@kishore7snehil kishore7snehil changed the title feat: add Session Transfer Token (STT) support for impersonation via session transfer (PoC) PoC: add Session Transfer Token (STT) support for impersonation via session transfer Jun 26, 2026
actor_token_type is caller-supplied, so it no longer defaults to the id_token URN -
the caller states the type matching their actor token (consistent with custom_token_exchange).
Also sorts the auth_types import block (ruff I001). Lint clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant