Hebilicious / authjs-nuxt

AuthJS edge-compatible authentication Nuxt module.
https://authjs-nuxt.pages.dev/
MIT License
249 stars 28 forks source link

Keycloak Cookie not set #19

Closed dissy123 closed 1 year ago

dissy123 commented 1 year ago

Environment

node 18.0.0 nuxt 3.6.1 nitro 2.5.2

Reproduction

https://github.com/dissy123/authjs-nuxt/tree/main/playgrounds/keycloak

Describe the bug

No cookies are set when signin with keycloak, in keycloak i get a user session after the login attempt

image 1

and this is directly after login:

image

Additional context

No response

Logs

In my monorepo i get the following error message:

montreet:dev: [auth][error][InvalidCheck]: Read more at https://errors.authjs.dev#invalidcheck
montreet:dev: [auth][cause]: InvalidCheck: PKCE code_verifier cookie was missing.
montreet:dev:     at Object.use (file:///Users/matthiasdollfuss/00_Dev/localflow-monorepo/node_modules/.pnpm/@auth+core@0.9.0/node_modules/@auth/core/lib/oauth/checks.js:42:19)
montreet:dev:     at handleOAuth (file:///Users/matthiasdollfuss/00_Dev/localflow-monorepo/node_modules/.pnpm/@auth+core@0.9.0/node_modules/@auth/core/lib/oauth/callback.js:52:44)
montreet:dev:     at async Module.callback (file:///Users/matthiasdollfuss/00_Dev/localflow-monorepo/node_modules/.pnpm/@auth+core@0.9.0/node_modules/@auth/core/lib/routes/callback.js:20:41)
montreet:dev:     at async AuthInternal (file:///Users/matthiasdollfuss/00_Dev/localflow-monorepo/node_modules/.pnpm/@auth+core@0.9.0/node_modules/@auth/core/lib/index.js:65:38)
montreet:dev:     at async Auth (file:///Users/matthiasdollfuss/00_Dev/localflow-monorepo/node_modules/.pnpm/@auth+core@0.9.0/node_modules/@auth/core/index.js:100:30)
montreet:dev:     at async file:///Users/matthiasdollfuss/00_Dev/localflow-monorepo/01_Websites/montreet/.nuxt/dev/index.mjs:745:22
montreet:dev:     at async Object.handler (file:///Users/matthiasdollfuss/00_Dev/localflow-monorepo/node_modules/.pnpm/h3@1.6.6/node_modules/h3/dist/index.mjs:1255:19)
montreet:dev:     at async Server.toNodeHandle (file:///Users/matthiasdollfuss/00_Dev/localflow-monorepo/node_modules/.pnpm/h3@1.6.6/node_modules/h3/dist/index.mjs:1330:7)
montreet:dev: [auth][details]: {
montreet:dev:   "provider": "keycloak"
montreet:dev: }

In the reproduction i don't get an error message. But the cookies are not set.

Hebilicious commented 1 year ago

Hey, Are you able to make it work with authjs directly without this module ? This looks like it could be a provider issue. We can definitely add a keycloak example to the playground once we resolved this though.

Hebilicious commented 1 year ago

Fixed by https://github.com/Hebilicious/authjs-nuxt/pull/38, please re-open if this still happens in latest version.