Working with Delegation and Impersonation

1. Understanding Delegation Concepts

TermDetail
DelegationUser grants subset of perms to another principal
ImpersonationAdmin acts as another user (full identity)
On-behalf-ofService acts on behalf of original user

2. Implementing User Impersonation

RequirementDetail
PermissionRestricted role (e.g., support_impersonator)
AuditLog impersonator + target + reason ticket
BannerUI always shows "Impersonating X"
TokenContains both sub (target) and act (actor)

3. Using OAuth Delegation

GrantRFC
Authorization codeUser delegates to client
Token exchangeRFC 8693 — actor + subject tokens
Rich Authorization RequestsRFC 9396 fine-grained scopes

4. Implementing Service Account Delegation

CloudDetail
GCPService account impersonation via IAM iam.serviceAccountTokenCreator
AWSSTS AssumeRole
AzureWorkload Identity Federation

5. Using Delegation Scopes

Example: RFC 8693 token-exchange

POST /token
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
subject_token=<user-token>
subject_token_type=urn:ietf:params:oauth:token-type:access_token
actor_token=<service-token>
requested_token_type=urn:ietf:params:oauth:token-type:access_token
scope=orders:read

6. Auditing Delegated Actions

Log FieldDetail
actorWho is acting
subjectOn whose behalf
actionWhat operation
reasonTicket / business justification
timestampUTC + duration

7. Implementing Delegation Expiration

TypeTTL
Impersonation session15-30 min, auto-end
Vacation delegationFixed end date
Action-boundSingle-use (e.g., one approval)

8. Preventing Delegation Abuse

ControlDetail
No re-delegationDelegatee cannot delegate further
Scope capCannot exceed delegator's permissions
Step-up MFAFor sensitive impersonation
Notify subjectEmail user when impersonated

9. Using Constrained Delegation

SystemDetail
Kerberos S4U2ProxyService delegates only to allowed targets
OAuth audience-restrictedToken usable only at named service
Resource-boundPer-object scopes (RAR)

10. Implementing Delegation Revocation

MechanismDetail
By delegatorSelf-service revoke
By adminEmergency revoke
AutomaticOn role change / termination
Token revocationRFC 7009 endpoint