コンテンツにスキップ
NextAuth.js v4 からの移行ですか?こちらをお読みください 移行ガイド.

プロバイダー

CredentialInput

CredentialInput の再エクスポート

CredentialsConfig

CredentialsConfig の再エクスポート

CredentialsProviderType

CredentialsProviderType の再エクスポート

EmailConfig

EmailConfig の再エクスポート

EmailProviderType

EmailProviderType の再エクスポート

EmailUserConfig

EmailUserConfig の再エクスポート

AppProvider

すべてのProviderType で共有

拡張

プロパティ

callbackUrl

callbackUrl: string;

id

id: string;

AuthConfig.providers でプロバイダーを一意に識別します。また、URL の一部でもあります。

継承元

CommonProviderOptions.id

name

name: string;

デフォルトのサインインページのサインインボタンで使用されるプロバイダー名。たとえば、「Google」の場合、対応するボタンには「Googleでサインイン」と表示されます。

継承元

CommonProviderOptions.name

signinUrl

signinUrl: string;

type

type: ProviderType;

ProviderType を参照してください

継承元

CommonProviderOptions.type


CommonProviderOptions

すべてのProviderType で共有

拡張

プロパティ

id

id: string;

AuthConfig.providers でプロバイダーを一意に識別します。また、URL の一部でもあります。

name

name: string;

デフォルトのサインインページのサインインボタンで使用されるプロバイダー名。たとえば、「Google」の場合、対応するボタンには「Googleでサインイン」と表示されます。

type

type: ProviderType;

ProviderType を参照してください


OAuth2Config<Profile>

TODO:ドキュメント化

拡張

型パラメーター

型パラメーター
Profile

プロパティ

[conformInternal]?

optional [conformInternal]: true;
参照

customFetch?

optional [customFetch]: (input, init?) => Promise<Response>;
参照
パラメーター
パラメーター
inputURL | RequestInfo
init?RequestInit
戻り値

Promise<Response>

account?

optional account: AccountCallback;

OAuthプロバイダーから返された完全なTokenSetを受け取り、サブセットを返します。これは、データベース内のユーザーに関連付けられたアカウントを作成するために使用されます。

返されるプロパティに合わせて、データベースのAccountモデルを調整する必要があります。詳細については、データベースアダプターのドキュメントを確認してください。

デフォルト: access_token, id_token, refresh_token, expires_at, scope, token_type, session_state

import GitHub from "@auth/core/providers/github"
// ...
GitHub({
  account(account) {
    // https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens#refreshing-a-user-access-token-with-a-refresh-token
    const refresh_token_expires_at =
      Math.floor(Date.now() / 1000) + Number(account.refresh_token_expires_in)
    return {
      access_token: account.access_token,
      expires_at: account.expires_at,
      refresh_token: account.refresh_token,
      refresh_token_expires_at
    }
  }
})
参照

allowDangerousEmailAccountLinking?

optional allowDangerousEmailAccountLinking: boolean;

通常、OAuthプロバイダーでサインインし、同じメールアドレスを持つ別のアカウントが既に存在する場合、アカウントは自動的にリンクされません。

サインイン時の自動アカウントリンクは、任意のプロバイダー間では安全ではなく、デフォルトで無効になっています。詳細については、セキュリティFAQをご覧ください。

ただし、関与するプロバイダーがアカウントに関連付けられたメールアドレスを安全に検証していると信頼できる場合は、自動アカウントリンクを許可することが望ましい場合があります。allowDangerousEmailAccountLinking: trueを設定して、自動アカウントリンクを有効にします。

authorization?

optional authorization: string | AuthorizationEndpointHandler;

ログインプロセスは、ユーザーをこのURLに送信することによって開始されます。

認証エンドポイント

checks?

optional checks: ("none" | "state" | "pkce")[];

コールバックエンドポイントで実行されるCSRF保護。

デフォルト
["pkce"]
注意

redirectProxyUrlまたはAuthConfig.redirectProxyUrlが設定されている場合、"state"が自動的にチェックに追加されます。

RFC 7636 - OAuthパブリッククライアントによるコード交換の証明キー (PKCE) | RFC 6749 - OAuth 2.0 認証フレームワーク | OpenID Connect Core 1.0 |

client?

optional client: Partial<Client & {
  token_endpoint_auth_method: string;
}>;

基になるOAuthライブラリにオーバーライドを渡します。詳細については、oauth4webapi クライアントを参照してください。

clientId?

optional clientId: string;

clientSecret?

optional clientSecret: string;

id

id: string;

特定のプロバイダーにサインインする場合に、プロバイダーを識別します。

signIn('github') // "github" is the provider ID
オーバーライド

CommonProviderOptions.id

issuer?

optional issuer: string;
オーバーライド

PartialIssuer.issuer

jwks_endpoint

jwks_endpoint: any;
継承元

PartialIssuer.jwks_endpoint

name

name: string;

プロバイダーの名前。デフォルトのサインインページに表示されます。

オーバーライド

CommonProviderOptions.name

options?

optional options: OAuthUserConfig<Profile>;

profile?

optional profile: ProfileCallback<Profile>;

OAuthプロバイダーから返された完全なProfileを受け取り、サブセットを返します。これは、データベースにユーザーを作成するために使用されます。

デフォルト: id, email, name, image

参照

データベースアダプター:ユーザーモデル

redirectProxyUrl?

optional redirectProxyUrl: string;

style?

optional style: OAuthProviderButtonStyles;

token?

optional token: string | TokenEndpointHandler;

type

type: "oauth";

ProviderType を参照してください

オーバーライド

CommonProviderOptions.type

userinfo?

optional userinfo: string | UserinfoEndpointHandler;

wellKnown?

optional wellKnown: string;

OpenID Connect(OIDC)準拠のプロバイダーは、ほとんどの場合、追加の構成なしで、authorize/token/userinfoオプションの代わりにこれを構成できます。高度な制御のために、authorize/token/userinfoオプションを使用することもできます。

認証サーバーメタデータ


OAuthProviderButtonStyles

プロパティ

bg?

optional bg: string;
非推奨

代わりに「brandColor」を使用してください

brandColor?

optional brandColor: string;
optional logo: string;

text?

optional text: string;
非推奨

OIDCConfig<Profile>

OAuth2Configの拡張。

参照

https://openid.net/specs/openid-connect-core-1_0.html

拡張

型パラメーター

型パラメーター
Profile

プロパティ

[conformInternal]?

optional [conformInternal]: true;
参照
継承元

Omit.[conformInternal]

customFetch?

optional [customFetch]: (input, init?) => Promise<Response>;
参照
パラメーター
パラメーター
inputURL | RequestInfo
init?RequestInit
戻り値

Promise<Response>

継承元

Omit.[customFetch]

account?

optional account: AccountCallback;

OAuthプロバイダーから返された完全なTokenSetを受け取り、サブセットを返します。これは、データベース内のユーザーに関連付けられたアカウントを作成するために使用されます。

返されるプロパティに合わせて、データベースのAccountモデルを調整する必要があります。詳細については、データベースアダプターのドキュメントを確認してください。

デフォルト: access_token, id_token, refresh_token, expires_at, scope, token_type, session_state

import GitHub from "@auth/core/providers/github"
// ...
GitHub({
  account(account) {
    // https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens#refreshing-a-user-access-token-with-a-refresh-token
    const refresh_token_expires_at =
      Math.floor(Date.now() / 1000) + Number(account.refresh_token_expires_in)
    return {
      access_token: account.access_token,
      expires_at: account.expires_at,
      refresh_token: account.refresh_token,
      refresh_token_expires_at
    }
  }
})
参照
継承元

Omit.account

allowDangerousEmailAccountLinking?

optional allowDangerousEmailAccountLinking: boolean;

通常、OAuthプロバイダーでサインインし、同じメールアドレスを持つ別のアカウントが既に存在する場合、アカウントは自動的にリンクされません。

サインイン時の自動アカウントリンクは、任意のプロバイダー間では安全ではなく、デフォルトで無効になっています。詳細については、セキュリティFAQをご覧ください。

ただし、関与するプロバイダーがアカウントに関連付けられたメールアドレスを安全に検証していると信頼できる場合は、自動アカウントリンクを許可することが望ましい場合があります。allowDangerousEmailAccountLinking: trueを設定して、自動アカウントリンクを有効にします。

継承元

Omit.allowDangerousEmailAccountLinking

authorization?

optional authorization: string | AuthorizationEndpointHandler;

ログインプロセスは、ユーザーをこのURLに送信することによって開始されます。

認証エンドポイント

継承元

Omit.authorization

checks?

optional checks: ("none" | "state" | "nonce" | "pkce")[];

client?

optional client: Partial<Client & {
  token_endpoint_auth_method: string;
}>;

基になるOAuthライブラリにオーバーライドを渡します。詳細については、oauth4webapi クライアントを参照してください。

継承元

Omit.client

clientId?

optional clientId: string;
継承元

Omit.clientId

clientSecret?

optional clientSecret: string;
継承元

Omit.clientSecret

id

id: string;

特定のプロバイダーにサインインする場合に、プロバイダーを識別します。

signIn('github') // "github" is the provider ID
継承元

Omit.id

idToken?

optional idToken: boolean;

false に設定すると、ユーザーデータのために userinfo_endpoint がフェッチされます。

認証フロー中に id_token が返される必要があります。

issuer?

optional issuer: string;
継承元

Omit.issuer

jwks_endpoint

jwks_endpoint: any;
継承元

Omit.jwks_endpoint

name

name: string;

プロバイダーの名前。デフォルトのサインインページに表示されます。

継承元

Omit.name

options?

optional options: OAuthUserConfig<Profile>;
継承元

Omit.options

profile?

optional profile: ProfileCallback<Profile>;

OAuthプロバイダーから返された完全なProfileを受け取り、サブセットを返します。これは、データベースにユーザーを作成するために使用されます。

デフォルト: id, email, name, image

参照

データベースアダプター:ユーザーモデル

継承元

Omit.profile

redirectProxyUrl?

optional redirectProxyUrl: string;
継承元

Omit.redirectProxyUrl

style?

optional style: OAuthProviderButtonStyles;
継承元

Omit.style

token?

optional token: string | TokenEndpointHandler;
継承元

Omit.token

type

type: "oidc";

userinfo?

optional userinfo: string | UserinfoEndpointHandler;
継承元

Omit.userinfo

wellKnown?

optional wellKnown: string;

OpenID Connect(OIDC)準拠のプロバイダーは、ほとんどの場合、追加の構成なしで、authorize/token/userinfoオプションの代わりにこれを構成できます。高度な制御のために、authorize/token/userinfoオプションを使用することもできます。

認証サーバーメタデータ

継承元

Omit.wellKnown


AccountCallback()

type AccountCallback: (tokens) => TokenSet | undefined | void;

パラメータ

パラメーター
tokensTokenSet

戻り値

TokenSet | undefined | void


AppProviders

type AppProviders: (Provider | ReturnType<BuiltInProviders[keyof BuiltInProviders]>)[];

AuthorizationEndpointHandler

type AuthorizationEndpointHandler: EndpointHandler<AuthorizationParameters>;

BuiltInProviderType

type BuiltInProviderType: RedirectableProviderType | OAuthProviderType | WebAuthnProviderType;

BuiltInProviders

type BuiltInProviders: Record<OAuthProviderType, (config) => OAuthConfig<any>> & Record<CredentialsProviderType, typeof default> & Record<EmailProviderType, typeof default> & Record<WebAuthnProviderType, (config) => WebAuthnConfig>;

OAuthChecks

type OAuthChecks: OpenIDCallbackChecks | OAuthCallbackChecks;

OAuthConfig<Profile>

type OAuthConfig<Profile>: OIDCConfig<Profile> | OAuth2Config<Profile>;

型パラメータ

型パラメーター
Profile

OAuthEndpointType

type OAuthEndpointType: "authorization" | "token" | "userinfo";

OAuthProviderType

type OAuthProviderType: 
  | "42-school"
  | "apple"
  | "asgardeo"
  | "atlassian"
  | "auth0"
  | "authentik"
  | "azure-ad-b2c"
  | "azure-ad"
  | "azure-devops"
  | "bankid-no"
  | "battlenet"
  | "beyondidentity"
  | "box"
  | "boxyhq-saml"
  | "bungie"
  | "click-up"
  | "cognito"
  | "coinbase"
  | "concept2"
  | "descope"
  | "discord"
  | "dribbble"
  | "dropbox"
  | "duende-identity-server6"
  | "eventbrite"
  | "eveonline"
  | "facebook"
  | "faceit"
  | "forwardemail"
  | "foursquare"
  | "freshbooks"
  | "fusionauth"
  | "github"
  | "gitlab"
  | "google"
  | "hubspot"
  | "identity-server4"
  | "instagram"
  | "kakao"
  | "keycloak"
  | "kinde"
  | "line"
  | "linkedin"
  | "mailchimp"
  | "mailgun"
  | "mailru"
  | "mastodon"
  | "mattermost"
  | "medium"
  | "microsoft-entra-id"
  | "naver"
  | "netlify"
  | "netsuite"
  | "nextcloud"
  | "nodemailer"
  | "notion"
  | "okta"
  | "onelogin"
  | "ory-hydra"
  | "osso"
  | "osu"
  | "passage"
  | "passkey"
  | "patreon"
  | "ping-id"
  | "pinterest"
  | "pipedrive"
  | "postmark"
  | "reddit"
  | "resend"
  | "roblox"
  | "salesforce"
  | "sendgrid"
  | "simplelogin"
  | "slack"
  | "spotify"
  | "strava"
  | "threads"
  | "tiktok"
  | "todoist"
  | "trakt"
  | "twitch"
  | "twitter"
  | "united-effects"
  | "vipps"
  | "vk"
  | "webauthn"
  | "webex"
  | "wechat"
  | "wikimedia"
  | "wordpress"
  | "workos"
  | "yandex"
  | "zitadel"
  | "zoho"
  | "zoom";

OAuthUserConfig<Profile>

type OAuthUserConfig<Profile>: Omit<Partial<OAuthConfig<Profile>>, "options" | "type">;

型パラメータ

型パラメーター
Profile

OIDCConfigInternal<Profile>

type OIDCConfigInternal<Profile>: OAuthConfigInternal<Profile> & {
  checks: OIDCConfig<Profile>["checks"];
  idToken: OIDCConfig<Profile>["idToken"];
};

型宣言

checks

checks: OIDCConfig<Profile>["checks"];

idToken

idToken: OIDCConfig<Profile>["idToken"];

型パラメータ

型パラメーター
Profile

OIDCUserConfig<Profile>

type OIDCUserConfig<Profile>: Omit<Partial<OIDCConfig<Profile>>, "options" | "type">;

型パラメータ

型パラメーター
Profile

ProfileCallback()<Profile>

type ProfileCallback<Profile>: (profile, tokens) => Awaitable<User>;

型パラメータ

型パラメーター
Profile

パラメータ

パラメーター
profileProfile
tokensTokenSet

戻り値

Awaitable<User>


Provider<P>

type Provider<P>: 
  | OIDCConfig<P>
  | OAuth2Config<P>
  | EmailConfig
  | CredentialsConfig
  | WebAuthnConfig & InternalProviderOptions | (...args) => 
  | OAuth2Config<P>
  | OIDCConfig<P>
  | EmailConfig
  | CredentialsConfig
  | WebAuthnConfig & InternalProviderOptions & InternalProviderOptions;

サポートされている認証プロバイダー構成である必要があります

  • OAuthConfig
  • EmailConfigInternal
  • CredentialsConfigInternal

詳細については、ガイドを参照してください

参照

型パラメータ

型パラメーター
P extends Profileany

ProviderType

type ProviderType: 
  | "oidc"
  | "oauth"
  | "email"
  | "credentials"
  | WebAuthnProviderType;

Auth.js に渡されるプロバイダーは、これらのタイプのいずれかを定義する必要があります。

参照


RedirectableProviderType

type RedirectableProviderType: "email" | "credentials";

TokenEndpointHandler

type TokenEndpointHandler: EndpointHandler<UrlParams, {
  checks: OAuthChecks;
  params: CallbackParamsType;
  }, {
  tokens: TokenSet;
}>;

UserinfoEndpointHandler

type UserinfoEndpointHandler: EndpointHandler<UrlParams, {
  tokens: TokenSet;
}, Profile>;
Auth.js © Balázs Orbán and Team -2024