Auth providers

Clerk

@clerk/nuxtevent.context.auth
Read the auth object that Clerk's middleware put on the event.

@clerk/nuxt adds a server middleware that authenticates every request before route handlers run. It leaves a function on event.context.auth.

server/auth/verify-user.ts
import { createError, getHeader } from 'h3'
import type { VerifyUser } from '@kurashina-design/nuxt-bff-guard'

export default (async (event) => {
  const auth = event.context.auth()
  if (!auth.isAuthenticated || !auth.userId) throw createError({ statusCode: 401 })

  event.context.user = { id: auth.userId, orgId: auth.orgId }
  // Clerk authenticates from the Authorization header alone when it is present.
  const bearer = getHeader(event, 'authorization')?.startsWith('Bearer ') ?? false
  return { viaBearer: bearer }
}) satisfies VerifyUser

Organizations and roles

Clerk's organization role is a good app-wide rule for a 403:

const auth = event.context.auth()
if (!auth.isAuthenticated) throw createError({ statusCode: 401 })
if (!auth.orgId) throw createError({ statusCode: 403 }) // signed in, but not in any organization
Clerk's middleware runs before the guard. If it cannot reach Clerk, it answers by itself, so the guard's 503 mapping does not apply to that part.