feat(android): optional Custom Tabs for oauth2 (#442) - #443
Conversation
Add androidUseCustomTabs (default false) so apps can opt into Chrome Custom Tabs instead of the embedded WebView, without breaking existing WebView flows. Co-authored-by: Cursor <cursoragent@cursor.com>
Beta npm buildMaintainers can publish this PR to npm for fast testing. Comment The workflow will:
Security note: beta publish is only enabled for branches inside this repository. |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 40 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Android OAuth2 provider now supports optional Chrome Custom Tabs authorization. It persists pending login state, handles deep-link and App Link redirects, supports process recovery, detects cancellation on resume, and documents the required configuration. ChangesAndroid Custom Tabs OAuth2
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant OAuth2Provider
participant ChromeCustomTabs
participant SocialLoginPlugin
OAuth2Provider->>ChromeCustomTabs: Open authorization URL
ChromeCustomTabs->>SocialLoginPlugin: Deliver redirect URI
SocialLoginPlugin->>OAuth2Provider: Process redirect URI
OAuth2Provider->>OAuth2Provider: Exchange code or cancel pending login
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@android/src/main/java/ee/forgr/capacitor/social/login/OAuth2Provider.java`:
- Around line 710-738: Update handleRedirectUri to validate the redirect URI by
components instead of using redirectUrl.startsWith(uri.toString()). Require
matching scheme, authority, and exact path between pendingState.redirectUri and
uri, while preserving the existing rejection behavior for invalid or mismatched
redirects before processCallbackData is called.
- Around line 496-503: Update the Custom Tabs launch flow around
launchCustomTabs and its caller to catch ActivityNotFoundException, reject the
pending call, and invoke cleanupPending(). When falling back to
OAuth2LoginActivity after this failure, clear pendingUseCustomTabs before
starting the fallback activity.
In
`@android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java`:
- Around line 625-631: Update SocialLoginPlugin’s redirect handling and
initialize flow to buffer an initial ACTION_VIEW URI when the OAuth2 provider is
unavailable, then replay it after OAuth2Provider initialization. Persist and
restore pendingCall, pendingState, pendingUseCustomTabs, and the buffered
callback across process recreation, and ensure the transaction state is cleared
only after login resolves or rejects; apply the corresponding OAuth2Provider
handling changes at OAuth2Provider.java lines 58-60.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3421978c-26dd-4e0f-b5b6-c18e9900f3a4
📒 Files selected for processing (5)
README.mdandroid/src/main/java/ee/forgr/capacitor/social/login/OAuth2Provider.javaandroid/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.javadocs/setup_keycloak.mdsrc/definitions.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
Cap-go/capacitor-updater(manual)
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Catch missing-browser launches with WebView fallback, match redirects by URI components, parse encoded fragments, persist/replay Custom Tabs PKCE state across process death, and document launchMode. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java`:
- Around line 187-192: In the provider-registration flow around
handleOnResume(), restore the pending Custom Tabs session from the stored
CUSTOM_TABS_PENDING_* state after registration, then call
handleUserReturnedWithoutCallback() when no buffered redirect was handled so the
orphaned transaction is canceled and storage is cleared. Preserve the existing
pendingOAuth2RedirectUri replay behavior when a redirect is available.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: fdf1b035-3289-4387-aed8-10d70bf905d9
📒 Files selected for processing (4)
README.mdandroid/src/main/java/ee/forgr/capacitor/social/login/OAuth2Provider.javaandroid/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.javadocs/setup_keycloak.md
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
Cap-go/capacitor-updater(manual)
If resume ran before initialize with no buffered redirect, restore persisted PKCE state and cancel/clear the orphaned Custom Tabs transaction. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
{
"review_module": "filesystem_workspace_boundary",
"result": "pass",
"summary": "No filesystem workspace-boundary vulnerabilities found in changed lines.",
"findings": [],
"validated_changed_files": [
"README.md",
"android/src/main/java/ee/forgr/capacitor/social/login/OAuth2Provider.java",
"android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java",
"docs/setup_keycloak.md",
"src/definitions.ts"
],
"notes": "Reviewed only the PR diff hunks. Changes introduce OAuth Custom Tabs/deep-link state handling and documentation updates; no new model-controlled filesystem path inputs, workspace containment checks, cache/tarball/git/project/canvas path joins, or symlink validation logic were added in the modified lines."
}Sent by Cursor Security Agent: Security Reviewer


What
androidUseCustomTabsonOAuth2ProviderConfig(defaultfalse)Why
disallowed_useragent, SSO)How
handleOnNewIntentpattern already used byopenSecureWindow()openSecureWindow)Testing
bun run buildbun run verify:androidNot Tested
Made with Cursor
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
androidUseCustomTabsconfiguration option, disabled by default.Documentation