-
Notifications
You must be signed in to change notification settings - Fork 569
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
Allow configuration of Access-Control-Allow-Origin
value
#511
Conversation
79add95
to
2fcbaae
Compare
@flenter may I ask what use case you have in mind (which would not be covered by the |
I think it helps if I explain how I came to this pr: What
|
Is there anything I can do to help progress this pr? |
+1 |
When will this PR get merged? Is there any blocker? |
Allows responses with the correct Access-Control-Allow-Origin value instead of: Access-Control-Allow-Origin: *
I've rebased the pr so there are no more merge conflicts |
As an alternative, would it be easier to provide official api access to the headers before they are written. We ran into the same issue as @flenter where a penetration testing suite flagged socket.io as having arbitrary origins trusted. Our current approach is to register for the socket connection's transport 'headers' event as well as intercept the response's writeHead for the handshake in allowRequest (no access to socket transport at that stage) and modify the headers. Needless to say, that's icky. In our case we don't even need CORS at all. |
Would be really good to have this issue sorted out one way or the other. |
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 approve of this
Merged! Sorry for the delay.. |
…511) This reverts commit ebf1a96. Related: socketio/socket.io#3381
Allows responses with a specified
Access-Control-Allow-Origin
value instead of:Access-Control-Allow-Origin: *
orAccess-Control-Allow-Origin: <req.headers.origin>
The kind of change this PR does introduce
Current behaviour
In several places the
Access-Control-Allow-Origin
header is set to either '*' or to thevalue that was part of the request. This gives the impression that CORS is always allowed.
There are two scenarios where this happens:
lib/server.js
New behaviour
It's now possible to specify an
origins
value (default value is '*') when initialising the engine. This value will be returned as theAccess-Control-Allow-Origin
value.Note: this pr does not add support for verifying/checking the origins values, socket.io by default passes a function that performs this check already (via the
allowRequest
option).Other information (e.g. related issues)
There will be an accompanying PR for socket.io that passes the origins value it has to this package (once this pr is merged or has gotten some feedback).
Related issue: