Skip to content
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

HTTPOnly cookie possible? #377

Open
Xzandro opened this issue Dec 13, 2023 · 2 comments
Open

HTTPOnly cookie possible? #377

Xzandro opened this issue Dec 13, 2023 · 2 comments
Labels
question Further information is requested

Comments

@Xzandro
Copy link

Xzandro commented Dec 13, 2023

So, i tried to use the authentication and it worked pretty great for the most part. But when I set httpOnly for the cookies, it will not be set. What would be the reason for that? I would unterstand, that the client does not have access to that cookie, but not sure if we would need to have access anyway? I'm just worried about potential security risks.

When I try this, it works:

cookie: {
    maxAge: 14 * 24 * 60 * 60,
    secure: process.env.NODE_ENV === 'production',
    sameSite: true
}

But when I add httpOnly, then the cookie is not set. Does not work:

cookie: {
    httpOnly: true,
    maxAge: 14 * 24 * 60 * 60,
    secure: process.env.NODE_ENV === 'production',
    sameSite: true
}

I also tried various other things, like settings sameSite to lax etc. Everything works, until I set httpOnly to true.
@Xzandro Xzandro added the question Further information is requested label Dec 13, 2023
@rrubio
Copy link

rrubio commented Dec 27, 2023

I'm having the same issue. Have you had any luck @Xzandro ?

Versions -

  • NuxtJS 3 &
  • Strapi 4.13.6
  • NodeJS v18.16.0

nuxt.config.ts (strapi)

  runtimeConfig: {
    recaptcha: {
      secret_key: process.env.RECAPTCHA_SECRET_KEY,
    },
    public: {
      recaptcha: {
        site_key: process.env.RECAPTCHA_SITE_KEY,
      },
      media: {
        url: process.env.STRAPI_URL,
      },
      strapi: {
        url: process.env.STRAPI_URL,
        prefix: '/api',
        version: 'v4',
        cookieName: 'strapi_jwt',
        cookie: {
          path: '/',  
          httpOnly: true,            
        },
      },
    }
  },

@Xzandro
Copy link
Author

Xzandro commented Dec 29, 2023

I do not. I just went without HTTP only for now. I set secure in production for the cookie tho. Still not sure how bad it currently is, but I suspect, that we somehow get the cookies via JS on the client side and thus HTTP only is not possible, not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants