hapijs / cookie

Cookie authentication plugin
Other
229 stars 100 forks source link

After upgrading from 9.1.0 to 10.0.0 on hapi 18.1.0 getting strange behaviour for plugin #211

Closed CloudVector closed 5 years ago

CloudVector commented 5 years ago

Error: Missing authentication at module.exports.internals.Auth._authenticate (C:\unicomp\session\node_modules\hapi\lib\auth.js:270:26) at process._tickCallback (internal/process/next_tick.js:68:7)

I have a route which using the strategy "session", but I can get to the route where auth is not valid and the validationFunc NEVER got called.

Debugging the code, after the

request.cookieAuth.set({ 'sid': sid });

where I set the session (and actually just a random cookie as well)

h.state('abc', '123');

Then I redirect to another url where I would expect to see both cookies, but NOTHING. No cookie set at all. I tried h.redirect('/new-url') and inject into a page which get redirected from the client side (javascript). Both cases the endpoint receiving the call does not have ANY COOKIE SET. I am baffled, what am I missing?

CloudVector commented 5 years ago

I have figured out the issue. When I declared the parameter, never before specified the path. Now with version 10 the path will be defaulted for the specific url path, that is why I could not see the cookie on the new url, because only applied to the previous old one. I had to add path: '/' to the initial options and it started to work.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.