aborn / nuxt-openid-connect

OpenID-Connect(OIDC) integration module for nuxt 3.0.
35 stars 16 forks source link

for nuxt3 with rc.12 #2

Closed psetier1 closed 1 year ago

psetier1 commented 1 year ago

it says empty callback, but there is a callback url and is also set in keycloak

psetier1 commented 1 year ago

under callback.mjs -> its using access_token, but the keyloack is using id_token, but it says afterward invalid token, but when i verify in the jwt.io, the id_token is a valid one and its when you parse using http://jwt.io it has a valid value

params {"id_token":"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJhRVg2QjVrNVZsZndBY2hrSmRqSzhSbDVmN1BJWGlVY1FZYzhlZ3pSenZFIn0.eyJleHAiOjE2NjY4NjgzODksImlhdCI6MTY2Njg2NzQ4OSwiYXV0aF90aW1lIjoxNjY2ODY0OTQ0LCJqdGkiOiJjZDJiNWNlNi0xNGRmLTRkN2QtOWJhMC1iZmE5Zjg1NmY4NzgiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvcmVhbG1zL0RldlJlYWxtIiwiYXVkIjoibG9jYWwiLCJzdWIiOiJmOTk1NmU3Mi03MTVjLTRlZWItOTg1ZS1iOGMzOTBkZDJkNGIiLCJ0eXAiOiJJRCIsImF6cCI6ImxvY2FsIiwibm9uY2UiOiIxZGY3ZGM1YS0xN2RlLTQ1NGItYWJiZi0xYTY5YzMwY2U3ZWMiLCJzZXNzaW9uX3N0YXRlIjoiNmUzNDZhZmQtNjRlMS00OGI4LTg1ZWYtZjhiYmYyZTI2MjJiIiwiYWNyIjoiMCIsInNpZCI6IjZlMzQ2YWZkLTY0ZTEtNDhiOC04NWVmLWY4YmJmMmUyNjIyYiIsImFkZHJlc3MiOnt9LCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwibmFtZSI6IlBldGVyIFZlcnNhbiBTZXRpZXIiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJ0ZXN0IiwiZ2l2ZW5fbmFtZSI6IlBldGVyIFZlcnNhbiIsImZhbWlseV9uYW1lIjoiU2V0aWVyIiwiZW1haWwiOiJwZXRlci12ZXJzYW4uc2V0aWVyQHRlcmFkeW5lLmNvbSJ9.Tp22nxcdQEFFvFd4VkNQ2BJxfM5lAa56T4NoqqFX_wSb49rueBYMjRJGfYIKJeB66EePQqVStPXpqJGU8YToBmJZXI1tQTawNMSNPDPb-hvSqflWtRrL2m38IxSneRAeCNoM8nxLDVz3ya5sQeYI-N-ke-YOElybjY6EshmRgmZIYEMZw-KeJmq65v1jmRaqOKiwiG7MwTyuF77Z87kPrKeZAjj4hLhV5uQlCfRM4UH76p-EVYvndTueEum8rzufB-yd6xpihenhXG2aL3IcoDwTBf2KnAzRFtVvy0np0wbValYgr_B1KW3Czu0ceWpWeh-Z-rcdXdku8h_vqVsPdA","session_state":"6e346afd-64e1-48b8-85ef-f8bbf2e2622b"} OPError: invalid_token (Token verification failed) at throwAuthenticateErrors (/Users/peterversanj.setier/Documents/projects/dev/nuxt-app/node_modules/openid-client/lib/helpers/process_response.js:11:11) at processResponse (/Users/peterversanj.setier/Documents/projects/dev/nuxt-app/node_modules/openid-client/lib/helpers/process_response.js:34:7) at Client.userinfo (/Users/peterversanj.setier/Documents/projects/dev/nuxt-app/node_modules/openid-client/lib/client.js:1237:18) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async file:///Users/peterversanj.setier/Documents/projects/dev/nuxt-app/.nuxt/dev/index.mjs:666:24 at async Object.handler (file:///Users/peterversanj.setier/Documents/projects/dev/nuxt-app/node_modules/h3/dist/index.mjs:567:19) at async Server.toNodeHandle (file:///Users/peterversanj.setier/Documents/projects/dev/nuxt-app/node_modules/h3/dist/index.mjs:631:7) { error: 'invalid_token', error_description: 'Token verification failed' }

aborn commented 1 year ago

Can your provide your nuxt.config.ts content, or provide a minimal reproduction project.

psetier1 commented 1 year ago

// https://v3.nuxtjs.org/api/configuration/nuxt.config export default defineNuxtConfig({ app: { head: { title: '', bodyAttrs: { class: 'body-container' } } }, css : [

    'primevue/resources/themes/saga-blue/theme.css',
    'primevue/resources/primevue.min.css',
    'primeicons/primeicons.css',
    'primeflex/primeflex.css',
    'assets/css/ace.min.css',
    'assets/css/ace-themes.min.css',
    'assets/css/ace-font.css',
    'assets/css/custom.css',
],
build: {
    transpile: ['primevue']
},
image : {

},

modules: [
    'nuxt-openid-connect'
  ],
  openidConnect: {
    addPlugin: true,
    op: {
      issuer: process.env.issuer,
      clientId: process.env.clientId,
      clientSecret: process.env.clientSecret,
      callbackUrl: process.env.callbackUrl,
      scope: [
        'email',
        'profile',
        'address'
      ]
    },
    session: {
      secret: 'oidc._sessionid',
      cookie: {},
      cookiePrefix: 'oidc._',
      maxAge: 24 * 60 * 60       // one day
    }
  }

})

psetier1 commented 1 year ago

this is the .env

issuer=http://192.168.1.7:8080/realms/DevRealm/ clientId=local clientSecret=WnbN5z0qX5yf20oCMKPpQxmNJySlIwoZ

callbackUrl=http://127.0.0.1:8080/realms/DevRealm/protocol/openid-connect/token

callbackUrl=http://192.168.1.7:3000/api/callback

aborn commented 1 year ago

DevRealm/

192.168.x.x is local server ip. I cannot connected to debug.

psetier1 commented 1 year ago

192.168.x.x is local server ip - this a local setup of keycloak SSO, but i recently upgrade to nuxt 3 rc.14 , it seems the module is not supported anymore

aborn commented 1 year ago

Upgrade to v0.4.0 +, which version supports nuxt 3.0.0 stable release. https://github.com/aborn/nuxt-openid-connect/releases