fix(auth): pass preferredRedirectUrl through signInWithRedirect to ge… - #14870
Open
shivennn wants to merge 2 commits into
Open
fix(auth): pass preferredRedirectUrl through signInWithRedirect to ge…#14870shivennn wants to merge 2 commits into
shivennn wants to merge 2 commits into
Conversation
…tRedirectUrl The preferredRedirectUrl option was accepted by signInWithRedirect() but never passed through the internal call chain to getRedirectUrl(). This made it impossible to use HTTPS App Links/Universal Links as OAuth redirect URIs on React Native, forcing apps to use custom URL schemes which are vulnerable to authorization code interception. Changes: - Add preferredRedirectUrl to AuthSignInWithRedirectInput options type - Pass preferredRedirectUrl from signInWithRedirect → oauthSignIn → getRedirectUrl - Add unit tests verifying preferredRedirectUrl is used in the authorization URL
|
Contributor
|
Thanks for the PR, @shivennn! We'll review it soon and follow up with feedback. |
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.
The preferredRedirectUrl option was accepted by signInWithRedirect() but never passed through the internal call chain to getRedirectUrl(). This made it impossible to use HTTPS App Links/Universal Links as OAuth redirect URIs on React Native, forcing apps to use custom URL schemes which are vulnerable to authorization code interception.
Changes:
Description of changes
preferredRedirectUrlis accepted bysignInWithRedirect()options but never passed through the internal call chain togetRedirectUrl(). The parameter is alwaysundefinedwhen it reachesgetRedirectUrl.native.ts, making it impossible to use HTTPS App Links/Universal Links as OAuth redirect URIs on React Native.This forces apps to use custom URL schemes (e.g.,
myapp://auth/callback) which are vulnerable to authorization code interception on Android — any malicious app can register the same scheme and steal auth codes via the disambiguation dialog (see RFC 8252 §8.2).Fix (3 lines of functional code):
packages/auth/src/types/inputs.ts— AddedpreferredRedirectUrl?: stringtoAuthSignInWithRedirectInput.optionspackages/auth/src/providers/cognito/apis/signInWithRedirect.ts— PasspreferredRedirectUrlthroughsignInWithRedirect()→oauthSignIn()→getRedirectUrl()getRedirectUrl.native.tsalready has the logic to handlepreferredRedirectUrl— it simply never received it.Non-breaking: If
preferredRedirectUrlis not passed, behavior is identical to before.Issue #, if available
#14869
Description of how you validated changes
yarn test --scope @aws-amplify/auth).well-known/assetlinks.json) while legitimate app receives the redirectChecklist
yarn testpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.