Skip to content
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

Do not expose API in non-secure context #13

Open
dlongley opened this issue Jan 7, 2020 · 4 comments
Open

Do not expose API in non-secure context #13

dlongley opened this issue Jan 7, 2020 · 4 comments
Labels
Priority 2 Important but not critical

Comments

@dlongley
Copy link
Contributor

dlongley commented Jan 7, 2020

Since CHAPI is not meant to be available in a non-secure context, the polyfill should not install on non-HTTPS sites. Currently, the browser will eventually block its functionality but it should be blocked immediately and throw a SecurityError error if a developer tries to use it on a non-secure site.

@dmitrizagidulin
Copy link
Contributor

Is the idea here that the polyfill should check the current window URL, and make sure it's https?

@dlongley
Copy link
Contributor Author

dlongley commented Jan 8, 2020

Is the idea here that the polyfill should check the current window URL, and make sure it's https?

Yes. When loading the polyfill, if the window location doesn't use https then the software should throw a DOM SecurityError indicating that the polyfill can only be loaded in a secure context (e.g., 'https').

@llorllale
Copy link

Use window.isSecureContext: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.

I'm not sure we can rely on simply checking the location's url scheme.

@dlongley
Copy link
Contributor Author

dlongley commented Feb 27, 2020

This looks pretty green: https://caniuse.com/#search=isSecureContext

We should use it but if it's not present (e.g., IE11), we should fall back to using https.

@dlongley dlongley added Priority 2 Important but not critical and removed Priority 1 labels Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority 2 Important but not critical
Projects
None yet
Development

No branches or pull requests

4 participants