Skip to content

fix(getCustomBrowser): explicitly set browser to nil if type not found #1064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 12, 2025

Conversation

valentinrey
Copy link
Contributor

Fixes #1063

Description

This pull request fixes an issue in the getCustomBrowser: method where an invalid or empty browser type (e.g., an empty string or NSNull) received from the JavaScript layer would not be properly handled. In iOS release builds, such values caused the method to pass a non-nil result, leading to an attempt to execute an invalid browser block and resulting in a crash.

  • Updated getCustomBrowser: in RNAppAuth.m to explicitly check the return value of browser. If the value is not in the dictionary, it will return nil to trigger an ephemeral session.
  • Updated gitignore.

Steps to verify

  1. Configure the authorize method with a configuration object with no iosCustomBrowser, that includes:
const config = {
  issuer: "https://youridprovider.com",
  clientId: "yourClientID",
  redirectUrl: "yourapp://callback",
  scopes: ["openid"],
  iosPrefersEphemeralSession: true,
  usePKCE: true,
};
  1. Call authorize(config) in your React Native code.
  2. Build the app in iOS release mode (the issue is only reproducible in release builds for iOS).
  3. Observe that the app not crashes.

Copy link

changeset-bot bot commented Mar 12, 2025

🦋 Changeset detected

Latest commit: 443871b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
react-native-app-auth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Mar 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-app-auth ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 1:26pm

@carbonrobot carbonrobot merged commit 85f1ce6 into FormidableLabs:main Mar 12, 2025
3 checks passed
@github-actions github-actions bot mentioned this pull request Mar 12, 2025
@tuladharjaa
Copy link

@valentinrey logout does not work after these changes

@valentinrey
Copy link
Contributor Author

@tuladharjaa, I had to refactor my logout logic a bit. Basically moved the check up in the file tree

@sepperousseau
Copy link

@valentinrey what do you mean with "moved the check up in the file tree"?
For me the login works now, but the logout doesn't work anymore.

@valentinrey
Copy link
Contributor Author

@tuladharjaa I have an application with a simple auth logic, and take a check in App.tsx now that was in another file. It checks if the user is authenticated, if not, runs a logout function that also wipes tokens and other stored data

@seanfar
Copy link

seanfar commented Apr 25, 2025

@sepperousseau @tuladharjaa

I've introduced what I think may be the fix for logout in #1070. Please take a look at your convenience to see if this addresses the issue you're experiencing. ty!

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.

iosCustomBrowser falsely evaluated as provided, causing crash in release builds (iOS)
5 participants