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
- 開発環境の場合:
http://localhost: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`
},
}
...
}