Skip to content

feat(auth): support short-lived impersonated sessions - #3792

Merged
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/fix-impersonated-login-error
Jul 27, 2026
Merged

feat(auth): support short-lived impersonated sessions#3792
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/fix-impersonated-login-error

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Problem

PostHog intentionally issues impersonated OAuth sessions without refresh tokens so they cannot outlive the browser impersonation session. PostHog Code previously required a refresh token and failed while creating the local session.

Staff need to use PostHog Code as an impersonated user when investigating user-specific behavior without turning that short-lived authorization into a persistent login.

Changes

Support refresh-less OAuth responses as short-lived impersonated sessions. The access token remains in memory, works for API and agent proxy requests, and is never written to the persistent auth store.

Impersonated sessions remain active through permission-denied responses, then sign out at the exact token expiry, on token rejection, when the app restarts, or when a refresh is requested. The project switcher shows when the session ends, and the sign-in screen explains how to continue after expiry.

Normal OAuth refreshes retain the existing refresh token when the server does not rotate it. Impersonated credentials are not exported to the process environment.

@trunk-io

trunk-io Bot commented Jul 24, 2026

Copy link
Copy Markdown

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 12612e9.

@tatoalo tatoalo changed the title fix(auth): explain impersonated login failure fix(auth): clarify unsupported impersonated sign-in Jul 24, 2026
@tatoalo tatoalo changed the title fix(auth): clarify unsupported impersonated sign-in feat(auth): support short-lived impersonated sessions Jul 24, 2026
Generated-By: PostHog Code
Task-Id: 78153265-2b26-450a-95af-6245e8b2280e
@tatoalo
tatoalo force-pushed the posthog-code/fix-impersonated-login-error branch from 0569c08 to 12612e9 Compare July 27, 2026 11:02
@tatoalo
tatoalo marked this pull request as ready for review July 27, 2026 11:02
@tatoalo tatoalo self-assigned this Jul 27, 2026
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(auth): support short-lived imperson..." | Re-trigger Greptile

@tatoalo
tatoalo requested a review from a team July 27, 2026 11:05
@tatoalo
tatoalo enabled auto-merge (squash) July 27, 2026 11:26
@trunk-io
trunk-io Bot merged commit 3389f0a into main Jul 27, 2026
36 of 37 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/fix-impersonated-login-error branch July 27, 2026 11:27
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.

2 participants