Describe the bug
If you use github as backend the following basic setup is required:
Example:
The authentication and token creation with github is successfull but the communication between the auth popup and the original page fails.
To Reproduce
Expected behavior
Login should work
Applicable Versions:
Additional context
It seems that the following check in netlify-auth.js is not working:
e.origin !== this.base_url
I think origin is always just the host without any path segment.
Thanks @agairing, looks like origin contains the schema and port too:
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#The_dispatched_event
We would gladly accept a PR for it (probably we just need to parse base_url and reconstruct without the path).
Ok, and I can try to create a PR. What about sth. like
this.base_url.indexOf(e.origin) !== 0
?
How about e.origin !== new URL(this.base_url).origin ? It makes it clear what we're checking and is stricter.
Fine for me.
I just did the local setup and executed the tests before changing anything. 34 tests are failing on windows.
Example:
Expected: ObjectContaining {"path": "static/media/abc_def_eaco_.png"}
Received: {"field": undefined, "fileObj": {}, "path": "static\\media\\abc_def_eaco_.png", "url": "displayURL"}
How should this be handled? At first glance, it seems that the test is not cross platform compatible.
@agairing, thanks for letting us know. I opened an new issue for that https://github.com/netlify/netlify-cms/issues/3655 and I'm surprised our CI doesn't fail it since it we run the tests on Widows too: https://github.com/netlify/netlify-cms/runs/609296943?check_suite_focus=true#step:6:1496.
I think you could just test the fix locally and submit it and I'll take care of the tests.
Most helpful comment
Ok, and I can try to create a PR. What about sth. like
this.base_url.indexOf(e.origin) !== 0?