Server Utils

OIDC Handler

Nuxt OIDC Auth route handlers

OIDC Event Handlers

All configured providers automatically register the following server routes.

  • /auth/<provider>/callback
  • /auth/<provider>/login
  • /auth/<provider>/logout

In addition, if defaultProvider is set, the following route rules are registered as forwards to the default provider.

  • /auth/login
  • /auth/logout

Using the session in server side code

You can access the user session in your server side code by using the getUserSession function from the @nuxtjs/oidc-auth module.

import { getUserSession } from 'nuxt-oidc-auth/runtime/server/utils/session.mjs'

export default eventHandler(async (event) => {
  const session = await getUserSession(event)
  return session.userName
})

Be careful to not expose any sensitive information from the handler code.


Copyright © 2024