feat(auth): support short-lived impersonated sessions - #3792
Merged
Conversation
|
😎 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. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Generated-By: PostHog Code Task-Id: 78153265-2b26-450a-95af-6245e8b2280e
tatoalo
force-pushed
the
posthog-code/fix-impersonated-login-error
branch
from
July 27, 2026 11:02
0569c08 to
12612e9
Compare
tatoalo
marked this pull request as ready for review
July 27, 2026 11:02
Contributor
|
Reviews (1): Last reviewed commit: "feat(auth): support short-lived imperson..." | Re-trigger Greptile |
jonathanlab
approved these changes
Jul 27, 2026
tatoalo
enabled auto-merge (squash)
July 27, 2026 11:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.