hapijs / crumb

CSRF crumb generation and validation for hapi
Other
171 stars 51 forks source link

crumb request.plugins.crumb: undefined #51

Closed abernardobr closed 9 years ago

abernardobr commented 9 years ago

Versions: HAPI: 8.5.2, crumb: 4.0.3, hapi-auth-cookie: 2.2.0 Startup process:

crumbOpts = {
            key: 'encrumb',
            restful: true,
            allowOrigins: ['http://*.emprego.net', 'https://*.emprego.net'],
            cookieOptions: {
                ttl: 356 * 60 * 60 * 1000,
                isSecure: false
            }
        };

authOpts = {
            password: 'anynicepassword',
            cookie: 'sid-myappname',
            redirectTo: '/unlogged',
            isSecure: false,
            keepAlive: true,
            ttl: 356 * 60 * 60 * 1000
        };

I am staring up first Crumb and then Cookie.

On my machine (Mac OSx Yosemite) I start the server with pm2 with several CPUs. It all works fine.

On the production server I start the server with pm2 with several CPUs. It all works fine with Chrome and IE. Once I use Firefox it is giving me the following problem:

It is generating the crumb just fine.

ui-0 (out): crumb generate --> crumb: xn27IZhk_WxKw0xSFVdWH2wbuWVoawsKWYWm0hPxM7Z
ui-0 (out): crumb onPreResponse --> request.plugins.crumb: xn27IZhk_WxKw0xSFVdWH2wbuWVoawsKWYWm0hPxM7Z
ui-0 (out): crumb onPostAuth
ui-0 (out): crumb onPostAuth 1 - request.route.settings.plugins._crumb: [object Object]
ui-0 (out): crumb onPostAuth settings.autoGenerate: true request.route.settings.plugins._crumb: [object Object]
ui-0 (out): crumb onPreResponse --> settings.addToViewContext: true - request.route.settings.plugins._crumb: [object Object] - request.plugins.crumb: undefined - response.variety: view

But once I make a POST request:

ui-0 (out): crumb onPostAuth
ui-0 (out): crumb onPostAuth settings.autoGenerate: true request.route.settings.plugins._crumb: [object Object]
ui-0 (out): crunb onPostAuth --> header: xn27IZhk_WxKw0xSFVdWH2wbuWVoawsKWYWm0hPxM7Z
ui-0 (out): 'xn27IZhk_WxKw0xSFVdWH2wbuWVoawsKWYWm0hPxM7Z'
ui-0 (out): crunb onPostAuth --> request.plugins.crumb: undefined
ui-0 (out): crumb onPreResponse --> settings.addToViewContext: true - request.route.settings.plugins._crumb: [object Object] - request.plugins.crumb: undefined - response.variety: undefined

Notice that request.plugins.crumb: undefined is undefined

I have tried all sorts of ways to detect why this might be happening, but have not yet come to any light on how to possibly solve this problem.

stongo commented 9 years ago

To clarify, this only happens on this particular POST route? Or for all POSTs?

abernardobr commented 9 years ago

Hello @stongo. Thanks for your reply.

This happens on a login POST.

Since I cannot get it, I cannot test the other routes.

stongo commented 9 years ago

This might nothing, but might you have a typo somewhere?

ui-0 (out): crunb onPostAuth --> request.plugins.crumb: undefined

stongo commented 9 years ago

Getting a similar error in one test only when converting crumb to hapi 9 https://github.com/hapijs/crumb/commit/f728d646107dd6fec7584aca098afbffadab3e17. This may be related to this issue

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.