跳至內容
從 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 和團隊 -2024