nuxt-auth-pkce
v0.10.2
Published
Nuxt Auth PKCE module (No requirement for SSR)
Readme
Auth PKCE
My new Nuxt module for doing amazing things.
Setup
- Add the
nuxt-auth-pkcedependency to your Nuxt.js project:
npm install nuxt-auth-pkce
# or
yarn add nuxt-auth-pkce
# or
pnpm i nuxt-auth-pkce- Add
nuxt-auth-pkceto themodulessection ofnuxt.config.js:
{
modules: [
'nuxt-auth-pkce',
],
authPkce: {
// Options
}
}Register your application in Azure AD and configure it as a SPA. Make sure to add the redirect URI
http://localhost:3000/auth/callbackto the app registration - as well as the URL you will be using in production.Create a
.envfile in the root of your project and add the following:
NUXT_PUBLIC_AUTH_PKCE_CLIENT_ID="your-client-id"
NUXT_PUBLIC_AUTH_PKCE_TENANT_ID="your-tenant-id"- Use the
AuthGatecomponent in your application
<template>
<AuthGate auto-login>
<div>
<h1>My secret content</h1>
</div>
</AuthGate>
</template>Features
- Builtin MSAL Authentication using PKCE flow
- fetchAuth helper for authenticated requests
- $fetchAuth method for authenticated requests
Quick Setup
Install the module to your Nuxt application with one command:
npx nuxi module add nuxt-auth-pkceThat's it! You can now use My Module in your Nuxt app ✨
Contribution
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release