sails-permissions icon indicating copy to clipboard operation
sails-permissions copied to clipboard

Audit Policy error when using sockets.

Open dottodot opened this issue 10 years ago • 5 comments

Firstly it fails for the ip address which could be resolved by including req.socket.handshake.address.address but then it fails on the sanitizeRequestUrl function as req.get('host') causes the error has no method 'get' and req.originalUrl is undefined.

dottodot avatar Apr 09 '15 10:04 dottodot

@scott-wyatt do you think your work on tjwebb/sails-auth#37 and tjwebb/sails-auth#38 might be relevant here?

tjwebb avatar Apr 10 '15 09:04 tjwebb

@tjwebb not exactly as those only refer to the passport policy, more than likely there will need to be a handler for socket requests for the Audit Policy to inject what normally comes through a http request and is missing from a socket request. @dottodot, would you mind posting some sample code and a break down of what you are trying to do?

scott-wyatt avatar Apr 10 '15 16:04 scott-wyatt

I just using https://github.com/oscarhaggerty/Backbone.Sails which defaults to using socket requests rather that ajax. So this is what causes the error. Changing the setting to just ajax request resolves the issue.

dottodot avatar Apr 10 '15 17:04 dottodot

@dottodot, I work with a lot of socket requests as well, so I'll definitely be looking into this. If you find a solution please post.

scott-wyatt avatar Apr 10 '15 19:04 scott-wyatt

I just submitted a PR that fixes these issues

scott-wyatt avatar May 12 '15 00:05 scott-wyatt