-
Notifications
You must be signed in to change notification settings - Fork 9k
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
fix(oauth2): add fallback for case when window.opener is null #9248
base: master
Are you sure you want to change the base?
Conversation
I think that window.postMessage could be used to communicate with the original opener instead of doing it manually (by using the oauth2 state to check the origin). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a maintainer of swagger-ui but I found your PR and can generally confirm it to be working apart from two minor bugs
@nicolashenry Could you elaborate? I'm interested in getting this fixed and am willing to contribute. |
@nicolashenry This is how it usually works already, yeah. The problem is, when @ftsell Thank you so much for the review! Fixed both issues. |
I looked into using An alternative I found is to use a BroadcastChannel but that would broadcast authentication related information through the whole browser which is also not optimal. |
Yes, I was thinking about BroadcastChannel.postMessage and not Window.postMessage. Sorry for the mistake. |
@nicolashenry Sounds like a good idea. Wanna try implement it? |
@notpushkin I made this quickly : 940ebe0, I have not tested it yet but I will try to turn this into a PR this week if it works. |
@nicolashenry Have you tested/made a PR for your fix? |
Are there plans to include the fix in a release? I ran into the same problem and this solution from @nicolashenry works fine for me. |
any updates on this? |
Motivation and Context
Sometimes
window.opener
might be null (there's multiple issues about that). Currently this results in a blank page without any indication of what might have gone wrong.Related: #8315, #3227
Fixes #8030, fixes #6150
Description
This PR adds a fallback: if
window.opener
is null, it will display a one-liner to run on a Swagger UI page (using devtools) in aprompt()
. Not too elegant, but given this is an edge case I'm not sure if it warrants more complex UI.How Has This Been Tested?
I've checked the added snippet independently by running it in devtools and it works as intended.
I'll be grateful for pointers to how to cover it with unit / integrations tests :-)
Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests