fix(oauth2-redirect): guard window.opener for cross-origin flows#10867
Open
yogeshwaran-c wants to merge 1 commit into
Open
fix(oauth2-redirect): guard window.opener for cross-origin flows#10867yogeshwaran-c wants to merge 1 commit into
yogeshwaran-c wants to merge 1 commit into
Conversation
Cross-origin navigation can sever window.opener (browser policy), causing the redirect page to crash with TypeError when accessing window.opener.swaggerUIRedirectOauth2. Guard the access and surface a clear message to the user instead of failing silently. Refs: swagger-api#10786, swagger-api#6150
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.
Description
When the OAuth2 authorization flow goes through a cross-origin redirect, browser policy can sever
window.openeron the redirect tab. The currentdev-helpers/oauth2-redirect.js(which webpack copies todist/oauth2-redirect.html) accesseswindow.opener.swaggerUIRedirectOauth2unconditionally, throwingTypeError: Cannot read properties of null (reading 'swaggerUIRedirectOauth2')and leaving the user staring at a blank redirect tab.This PR adds a single guard at the top of
run()that detects the missing opener and surfaces a clear instruction to the user instead of crashing silently.Motivation and Context
Refs: #10786, #6150
Both issues report the redirect tab failing without a useful message in cross-origin OAuth flows. The fix is the minimum needed to convert the silent crash into actionable feedback; it does not alter the success path.
How Has This Been Tested?
test/unit/core/oauth2-redirect.jsexercises the script under three scenarios:window.openerisnull→ no throw, instruction text is shownwindow.openerexists butswaggerUIRedirectOauth2is missing → no throw, instruction text is shownChecklist