User Impersonation
Act on behalf of any user for support and debugging without asking for their password. Bounded to 10 minutes, strictly audited in security logs.
What is impersonation?
User impersonation allows an administrator or support engineer to generate a short-lived bearer token that acts as a specific user. This enables reproducing customer bugs, checking RLS policy permissions, or troubleshooting data issues without requesting credentials.
Impersonation in Aurabase guarantees three fundamental security principles:
- Short lifespan: Impersonation tokens are valid between 1 and 600 seconds (10 minutes maximum, default 300 seconds). They never include a refresh token.
- Explicit actor attribution: The issued access token carries the standard RFC 8693
actclaim indicating who initiated the session. - Audit-before-issuance: The action is recorded in
auth_audit_logwith the actor, reason, duration, and target user before the token is ever generated. If the log insertion fails, no token is issued.
RFC 8693 act claim structure
An impersonation token is signed with the project's active ES256 key and conforms to the standard user access token format, with an additional act (actor) object:
sub: The identity of the user being impersonated. Postgres RLS (auth.uid()) evaluates to this value.act.sub: The identity of the operator who generated the token (e.g. console user ID orservice_role).
Admin endpoint
Impersonation requires administrator authorization via a service_role key or an operator with the admin role.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
reason | string | Optional* | Justification recorded in security logs. Required for privileged target accounts (admin/owner). |
ttl_seconds | number | Optional | Token lifetime in seconds (1 to 600, default 300). |
allow_privileged | boolean | Optional | Must be set to true if the target user has an admin or owner role. |
Response (200 OK)
TypeScript SDK
Use authAdmin.impersonate() with an Aurabase client configured with the service_role key:
Privileged accounts and audit logs
Guarding privileged accounts
Target accounts that possess administrative roles (such as role = 'admin', role = 'owner', or app_metadata.roles containing 'admin') represent high-value targets. To prevent accidental privilege elevation:
- You must explicitly pass
allow_privileged: true. - A non-empty
reasonstring must be provided. - If either check fails, the backend rejects the request with
403 Forbidden.
Security audit log
Every impersonation event is inserted into the tenant's auth_audit_log table:
- Action:
admin_impersonation - User ID: ID of the target user
- Metadata: JSON object containing
{ "actor": "...", "reason": "...", "ttl_seconds": 300, "privileged": false }
This trail is visible in Studio › Authentication › Audit logs and can be forwarded to SIEM tools via database drains.