-
Notifications
You must be signed in to change notification settings - Fork 51
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
Getting 403 forbidden because token has changed #54
Comments
@marlonmantilla @hapijs/university 's current assignment is related to crumb. Plus, I made a sample app fulfilling requirements of Assignment8 here. The app has 100% test coverage and uses crumb in AJAX post requests, so should provide the solutions you are looking for. The tests code for the login and logout routes should be very relevant too. Cheers! |
If you're trying pass the token as a "X-CSRF-Token" header you'll need to set crumb's plugin option |
@stongo I tried with both disabling restful: true|false, you can see |
Getting a similar error in one test only when converting crumb to hapi 9 f728d64. This may be related to this issue |
Closing due to inactivity. Re-open if this bug still reproduce-able with Crumb >= 5.x |
@stongo, I'm still seeing this issue with:
|
Same here with :-/ Note : right now I'm not even trying to integrate the plugin, i'm just fiddling with the "restful.js" demo app (had trouble integrating, so I cut all the "this might be due to some weird plugin interaction / configuration" issues and just tried the demo app barebone. As far as I can tell, the "generate" function is called on the /crumbed call (when i'd expect to check the token I have in my headers). I'm using the default configuration. Right now I'm trying to see how it fares when deactivating the auto-generation, so far no luck |
Here is my config
And form
Result restful : true does not work with form :( |
I am also getting the same error as per @hoshin. The generate function gets called twice:
Relevant part when debugging:
|
@stongo I'd gladly re-open if I could but it doesn't seem possible on my end =) |
I encountered this issue as well using the server example. |
found a bug related to the generate function. fixing in upcoming release |
It might have been a problem with the example, in fact. Using |
@afgallo check the pr example now, forgot to add the generate function args :( |
@stongo still no luck :( I noticed that the objects request.plugins.crumb and server.plugins.crumb are different. If this is by design, you can ignore my comment, but wouldn't this cause issues? When calling request.server.plugins.crumb.generate I noticed that request.plugins.crumb was already populated ... I also created a gist for you to have a look and see if I am making any stupid mistakes: https://gist.github.com/afgallo/e62fba828b2fcb1a96a808f754b94c3f |
@stongo finally some good news! I reviewed your tests cases and found what appeared to fix my unit tests. I simply modified my test cases from:
to:
It seems to be working now! I'll let you know if I come across any other issues. |
Excellent @afgallo |
Thanks =) |
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. |
Hi guys, I'm working in a HapiJS API and a separate Web client app (Just HTML and JS) which basically will have a form with a CSRF crumb token. So the Web app basically makes a call to GET /generate and HapiJS will return the CSRF token. After that when I submit the form I hit POST /send and sends the token with X-CSRF-Token header but for some reason is returning 403 ...
HAPIJS Routes
HapiJS routes handlers:
On the web side:
Here's plugin config:
Also I noticed that when calling multiple times GET /generate is returning the same CSRF token, not sure how to generate a new one per request.
When adding a debugger to crumb/lib/index.js, I noticed that the they're not the same:
Am I missing something here ?
The text was updated successfully, but these errors were encountered: