Zitadel 供應商
資源
設定
回調 URL
https://example.com/api/auth/callback/zitadel
環境變數
AUTH_ZITADEL_ID
AUTH_ZITADEL_SECRET
配置
/auth.ts
import NextAuth from "next-auth"
import Zitadel from "next-auth/providers/zitadel"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [Zitadel],
})
注意事項
建立憑證時使用的重新導向 URI 必須包含您的完整網域,並以回調路徑結尾。例如
- 對於生產環境:
https://{YOUR_DOMAIN}/api/auth/callback/zitadel
- 對於開發環境:
https://127.0.0.1:3000/api/auth/callback/zitadel
請務必在 ZITADEL 控制台中啟用開發模式,以允許本機開發的重新導向。
ZITADEL 還會在個人資料中返回一個 email_verified 布林屬性。您可以使用此屬性來限制對具有驗證帳戶的人員的存取。
const options = {
...
callbacks: {
async signIn({ account, profile }) {
if (account.provider === "zitadel") {
return profile.email_verified;
}
return true; // Do different verification for other providers that don't have `email_verified`
},
}
...
}