aborn / nuxt-openid-connect

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

Error h3 after pressing login #16

Closed glennovische closed 1 year ago

glennovische commented 1 year ago

After pressing the login button on the default index.vue page

I am redirected to : http://localhost:3000/oidc/login?redirect=/secure

I get the following error: Cannot read properties of undefined (reading 'req')

image

any ideas how to fix this?

aborn commented 1 year ago

Oidc use event.node.req at login process. As https://github.com/unjs/h3/pull/231 mentioned , this error because of the lower version of h3. Upgrade nuxt version to latest can fix this problem.

glennovische commented 1 year ago

It fixed some of my problems. To get it fully working i had to remove the if check you did in the template:

if (hash.length > 0 && hash.includes('#'))

In a script tag in the HTML all the important data is shared like my clientSecret and some other important data. Is it possible to hide this else this package is not useable for me and probably alot of other people.

glennovische commented 1 year ago

Got it working made a fork with:

First removing if (hash.length > 0 && hash.includes('#'))

Second editing module.ts line 148 with
let publicOps = Object.assign({}, options.op); let cnfg = Object.assign({}, options.config); delete(publicOps.clientSecret) delete(cnfg.cookieEncryptALGO) delete(cnfg.cookieEncryptIV) delete(cnfg.cookieEncryptKey)

`nuxt.options.runtimeConfig.public.openidConnect = defu(nuxt.options.runtimeConfig.public.openidConnect, {
  op: publicOps,
  config: cnfg
});`

This worked for me :) See PR

aborn commented 1 year ago

Thanks your PR. dist/ folder files should not be added into git repo. Remove it and i will test it your pr.