feat(android): expose allowedBrowserPackages option for web authentication#1513
Open
mrbrentkelly wants to merge 4 commits intoauth0:masterfrom
Open
feat(android): expose allowedBrowserPackages option for web authentication#1513mrbrentkelly wants to merge 4 commits intoauth0:masterfrom
mrbrentkelly wants to merge 4 commits intoauth0:masterfrom
Conversation
Adds an allowedBrowsers option to NativeAuthorizeOptions that restricts which browsers can handle the web authentication flow on Android. This works around a known issue with Firefox where App Link redirects are not correctly handled, causing login flows to fail. The underlying Auth0.Android SDK supports browser filtering via BrowserPicker and CustomTabsOptions. This change exposes that capability through the React Native bridge. When set, the behaviour is: - Default browser in the list → use it - Default browser not in the list, another allowed browser installed → use that - No allowed browser installed → a0.browser_not_available error This brings parity with the auth0-flutter SDK which already exposes this option (see auth0/auth0-flutter#392). Ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1976809
Contributor
|
Hey @mrbrentkelly, thanks for this PR! I've reviewed it against the underlying Auth0.Android SDK and have a few things that need to be addressed before we can merge.
|
- Rename allowedBrowsers -> allowedBrowserPackages across all layers for consistency - Add allowedBrowserPackages support to the logout (clearSession) flow - Add allowedBrowserPackages param to iOS A0Auth0.mm webAuth and webAuthLogout (accepted, ignored on iOS) - Add test cases for allowedBrowserPackages on authorize and clearSession
Author
|
Hey @subhankarmaiti, I think I've addressed all your comments if you want to take a second pass. Thanks for calling out the iOS side, I had noticed as well it was crashing so I've updated the appropriate method signatures in |
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.
Changes
Adds an
allowedBrowserPackagesoption toNativeAuthorizeOptionsthat restricts which browsers can handle the web authentication flow on Android.This exposes the browser filtering capability already present in the underlying Auth0.Android SDK via
BrowserPickerandCustomTabsOptionsthrough the React Native bridge.Motivation
Firefox on Android does not correctly handle App Link redirects, causing the Auth0 login flow to fail silently — the browser renders the callback URL as a page rather than handing off to the app. This is a known Firefox bug.
The same issue was reported and resolved for the Flutter SDK in auth0/auth0-flutter#392 by exposing an
allowedBrowsersoption. This PR brings the same capability to React Native.Behaviour
When
allowedBrowserPackagesis set on Android:a0.browser_not_availableerror is returnedOn iOS the option is ignored.
Usage
Files changed
src/types/platform-specific.ts— addsallowedBrowserPackages?: string[]toNativeAuthorizeOptionswith JSDoc indicating Android-onlysrc/specs/NativeA0Auth0.ts— adds parameter to TurboModule specsrc/platforms/native/bridge/NativeBridgeManager.ts— passes option through to native layerandroid/src/main/java/com/auth0/react/A0Auth0Module.kt— implementsBrowserPickerviaCustomTabsOptionsandroid/src/main/oldarch/com/auth0/react/A0Auth0Spec.kt— updates old arch abstract method signatureReferences