Token Exchange — Impersonation
Demonstrating RFC 8693 Token Exchange for impersonation. An admin with a 'may_act' privilege exchanges their token for a clean token belonging to a target user.
An administrator ('charlie') wants to impersonate a user ('bob') to troubleshoot an issue. Charlie sends a Token Exchange request to the Authz Server. The request includes Charlie's token as the 'actor_token', and specifies 'bob' as the 'subject_token'.
• In impersonation, the 'subject_token' does not have to be an actual token; it can be an identifier (like a username) if the Authz Server supports it.
• Charlie's 'actor_token' contains a 'may_act' claim. The Authz Server verifies this claim to ensure Charlie actually has permission to impersonate Bob.
• Unlike delegation, the newly issued token has NO 'act' claim. It is indistinguishable from a token Bob acquired himself.
Step 1: POST /token (Exchange)
application/x-www-form-urlencoded
grant_type=urn:ietf:params:oauth:grant-type:token-exchange&subject_token=bob&subject_token_type=urn:ietf:params:oauth:token-type:jwt&actor_token=eyJ0eXAiOiJhdCtqd3QiLCJhbGciOiJIUzI1NiJ9...&actor_token_type=urn:ietf:params:oauth:token-type:access_token&audience=api
{"typ"?:"at+jwt","alg":"HS256"}{"iss"?:"https://auth.example.com","sub"?:"admin_charlie","aud"?:"admin_portal","exp"?:1562266216,"iat"?:1562262616,"may_act":{"sub"?:"bob"}}{"typ"?:"at+jwt","alg":"HS256"}{"iss"?:"https://auth.example.com","sub"?:"bob","aud"?:"api","exp"?:1562266216,"iat"?:1562262616}