-
Notifications
You must be signed in to change notification settings - Fork 75
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
Owin connect-src not working as expected #63
Comments
Yes, it's probably refused because 'self' is same scheme/host/port. Have you tried adding ws://localhost:41698 as a custom source? |
This works:
Although it's no good because I have to hardcode the url, if someone else checks out the repository from Git and uses a different port on IIS express it won't work. I couldn't find a way to avoid hardcoding it in Startup.cs though since I don't have context information to get the host name. |
Yes, there's currently no way to do that automagically. A workaround for the localhost scenario would be to configure it with a wildcard port like so:
I'll leave this issue open and have another look at it for an upcoming release, we can probably handle this particular case in a more elegant manner. |
I thank you for your time. If I find a solution I'll be sure to send in a pull request. |
This particular scenario will be considered for the next iteration (3) of CSP, it might mandate a change in browser behaviour. I've opened an issue for it: w3c/webappsec#489. |
The CSP issue was just moved to another repo: w3c/webappsec-csp#7 |
This has been a real pain. Browser Link also causes this problem. I have had to add pre-processor directives and
I've raised this issue on ASP.NET 5 here. Mads Kristensen has been assigned to fix this. |
Yes, I see the browserlink pain. Hopefully they'll move the inline stuff to a separate file at least. It is an option to introduce an "allowSameHostWs" configuration option, but that would introduce som unwanted complexity. If the CSP gods decide to not do any adjustments to the semantics of connect-src 'self', I'll definitely add it. If they decide otherwise, well then I'll just wait until the problem disappears by itself. :) Doing different configs for different environments is a pain when using the attributes. I would suggest using two different configs, either through web.config, or per environment Owin startup classes. That should ease some of the pain. |
Agreed, lets hope they fix it. ASP.NET 5 fixes the multiple environments problem. You no longer need to rely on web.config file transforms, so you could remove the ugly pre-processor directives and do something more civilized like this:
|
So, they've decided to alter CSP and allow same host/port web sockets when you declare the 'self' source. We'll just wait them out. |
@RehanSaeed is the |
They are just constants, sorry I should have made that clear:
|
I am using the owin middleware like this:
Still, websocket connections from self are refused:
I have found no way to configure with CustomSources() to tell him to allow "ws://" + Self.
Thanks.
The text was updated successfully, but these errors were encountered: