Allow configuration of Access-Control-Allow-Origin value#511
Allow configuration of Access-Control-Allow-Origin value#511darrachequesne merged 3 commits intosocketio:developfrom
Access-Control-Allow-Origin value#511Conversation
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. |
|
Merged! Sorry for the delay.. |
…511) This reverts commit ebf1a96. Related: socketio/socket.io#3381
Allows responses with a specified
Access-Control-Allow-Originvalue 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-Originheader 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.jsNew behaviour
It's now possible to specify an
originsvalue (default value is '*') when initialising the engine. This value will be returned as theAccess-Control-Allow-Originvalue.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
allowRequestoption).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: