跳到内容
从 NextAuth.js v4 迁移?阅读 我们的迁移指南.
入门适配器Azure 表格

Azure 表格存储适配器

资源

设置

安装

npm install @auth/azure-tables-adapter

环境变量

AUTH_AZURE_ACCOUNT=storageaccountname
AUTH_AZURE_ACCESS_KEY=longRandomKey
AUTH_AZURE_TABLES_ENDPOINT=https://$AZURE_ACCOUNT.table.core.windows.net

配置

  1. 为身份验证数据创建一个表格,例如以下示例中的 auth
./auth.ts
import NextAuth, { type AuthConfig } from "next-auth"
import { TableStorageAdapter } from "@auth/azure-tables-adapter"
import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables"
 
const credential = new AzureNamedKeyCredential(
  process.env.AUTH_AZURE_ACCOUNT,
  process.env.AUTH_AZURE_ACCESS_KEY
)
const authClient = new TableClient(
  process.env.AUTH_AZURE_TABLES_ENDPOINT,
  "auth",
  credential
)
 
export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [],
  adapter: TableStorageAdapter(authClient),
} satisfies AuthConfig)
Auth.js © Balázs Orbán and Team -2024