0.2.1 • Published 2 years ago

@aborn.jiang/nuxt-openid-connect v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Nuxt OpenID-Connect

OpenID-Connect(OIDC) integration module for nuxt 3.0.

Features

  • An Nuxt 3 module.
  • OIDC integration ( implemetation base openid-client ).
  • State Management, shared login user info.
  • OIDC provider config.
  • Encrypt userInfo cookie (V0.2+).
  • Support browser localStorage store userInfo, which keep user auth info after page refresh. Similar like this.

Why use this module

  • The official auth module doesn't support Nuxt 3.0 yet.
  • nuxt-oidc also not support Nuxt 3.0.

How to use this module

  • Add to a project
yarn add nuxt-openid-connect
  • Then, add nuxt-openid-connect to the modules section of nuxt.config.ts and modify config depend yours:
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: [
    'nuxt-openid-connect'
  ],
  openidConnect: {
    addPlugin: true,
    op: {
      issuer: 'your_issuer_value',
      clientId: 'clientid',
      clientSecret: 'secret',
      callbackUrl: 'http://localhost:3000/oidc/cbt',
      scope: [
        'email',
        'profile',
        'address'
      ]
    },
    session: {
      cookie: {},
      cookiePrefix: 'oidc._',
      secret: 'oidc._sessionid',
      maxAge: 24 * 60 * 60       // one day
    }
  }
})

Here is an using example.

💻 Development

  • Clone repository
  • Install dependencies using yarn install
  • Run npm run dev:prepare to generate type stubs.
  • Use npm run dev to start playground in development mode.

License

MIT - Made with 💚