feat: persistent profile mode for enterprise SSO (BROWSE_PROFILE_DIR)#485
Open
haha1903 wants to merge 1 commit intogarrytan:mainfrom
Open
feat: persistent profile mode for enterprise SSO (BROWSE_PROFILE_DIR)#485haha1903 wants to merge 1 commit intogarrytan:mainfrom
haha1903 wants to merge 1 commit intogarrytan:mainfrom
Conversation
Add opt-in persistent browser profile support via two new env vars: - BROWSE_PROFILE_DIR: path to persistent profile dir, triggers launchPersistentContext() with SSO-friendly defaults - BROWSE_CHANNEL: use system Chrome/Edge instead of bundled Chromium When BROWSE_PROFILE_DIR is set, Playwright's SSO-breaking defaults (--disable-extensions, --use-mock-keychain, --password-store=basic) are automatically removed, enabling macOS Platform SSO, Intune device compliance, and Azure AD Conditional Access to work headlessly. Default behavior (bundled Chromium, ephemeral context) is unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
BROWSE_PROFILE_DIRenv varchromium.launchPersistentContext()instead ofchromium.launch()+newContext(), which preserves SSO sessions, device certs, and browser extensions across commandsBROWSE_CHANNELenv var to use system Chrome/Edge instead of bundled Chromium--disable-extensions,--use-mock-keychain,--password-store=basic) that break enterprise auth flowsThis enables headless access to enterprise sites protected by macOS Platform SSO, Intune device compliance, and Azure AD Conditional Access — without any UI popups or manual login.
Default behavior is completely unchanged. Only activates when
BROWSE_PROFILE_DIRis set.Usage
How it works
Playwright's bundled Chromium launches with
--disable-extensionsand--use-mock-keychainby default, which disables macOS Platform SSO Extension and blocks real Keychain access. Enterprise SSO (Azure AD, Okta, etc.) relies on these OS-level hooks.launchPersistentContext()with a dedicated profile dir +ignoreDefaultArgsfor the SSO-breaking flags is the same approach used by Google's Chrome DevTools MCP (via Puppeteer). This PR brings the same capability to Playwright.Changes
browse/src/browser-manager.tsbuildLaunchConfig()helper, persistent profile launch path, guards forclose(),isHealthy(),recreateContext(),handoff()browse/src/meta-commands.tsstatusshows persistent mode infoTest plan
$B goto https://example.comworks as before (no env vars set)BROWSE_PROFILE_DIR+BROWSE_CHANNEL=chrome, verify SSO-protected sites load$B statusshowsMode: persistent-profilewhen active$B handoffworks in persistent mode (close + relaunch headed)useragentcommand returns graceful message in persistent mode🤖 Generated with Claude Code