> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# SPA向け埋め込みパスワードレス認証

> シングルページアプリケーション（SPA）で、埋め込みログインを使用してパスワードレス認証を実装する方法を説明します。

> [!WARNING]
>
> Web アプリケーションで埋め込みログインを使用する場合、tenant に [カスタムドメイン](/docs/docs/ja-jp/customize/custom-domains) を設定していない限り、[クロスオリジン認証](/docs/docs/ja-jp/authenticate/login/cross-origin-authentication) が使用されます。クロスオリジン認証では、異なるオリジン間で安全な認証トランザクションを可能にするため、サードパーティ Cookie を使用します。

## Auth0のSDKを使用して埋め込みログインを実装する

Auth0のLockウィジェットを使用してパスワードレス (パスワードレス: パスワードを最初の認証要素として使わない認証形式。)ログインを実装できます。あるいは、ユーザー体験を完全に制御する必要がある場合は、Auth0.jsを使用して実装することもできます。

* [Lock for Web](/docs/docs/ja-jp/libraries/lock)
* [Auth0.jsリファレンス](/docs/docs/ja-jp/libraries/auth0js)

### Cross-Origin Resource Sharing (CORS) を設定する

セキュリティ上、アプリのオリジン URL は承認済み URL として登録されている必要があります。まだアプリケーションの **Allowed Callback URLS** に追加していない場合は、**Allowed Origins (CORS)** のリストにも追加する必要があります。

1. [Auth0 Dashboard > アプリケーション > アプリケーション](https://manage.auth0.com/#/applications) に移動し、アプリケーション名を選択して設定を表示します。
2. **Allowed Origins (CORS)** を見つけて、アプリケーションの [オリジン URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin) を入力し、**変更を保存** を選択します。

## MFAをカスタマイズ

> [!WARNING]
>
> **Resource Owner Password Grant、埋め込み、またはリフレッシュトークンのフローでカスタマイズ可能なMFA機能は現在、[早期アクセス](/docs/docs/troubleshoot/product-lifecycle/product-release-stages)です。**
>
> この機能を使用することにより、Oktaの該当する無料トライアル規約および[Master Subscription Agreement](https://www.okta.com/legal)に同意したものとみなされます。

埋め込みフローでMFA (多要素認証（MFA）: SMSで送信されるコードなど、ユーザー名とパスワードに加えて認証要素を使用するユーザー認証プロセス。)をカスタマイズできます。MFA APIを使用すると、ユーザーはアプリケーションでサポートされている任意の認証要素を登録し、その認証要素で認証できるようになります。

[Lock for Web](/docs/docs/ja-jp/libraries/lock#2-authenticating-and-getting-user-info)を使用する場合、`oauth/token`エンドポイントは`mfa_required`エラーを返し、MFA APIの利用に必要な`mfa_token`と、アプリケーションが現在サポートしている認証器の一覧を含む`mfa_requirements`パラメーターを返します。

```json lines theme={null}
{
  "error": "mfa_required",
  "error_description": "Multifactor authentication required",
  "mfa_token": "Fe26...Ha",
  "mfa_requirements": {
    "challenge": [
      { "type": "otp" },
      { "type": "push-notification" },
      { "type": "phone" },
      { "type": "recovery-code" }
      { "type": "email"} //チャレンジでのみ使用可能
    ]
  }
}
```

`mfa_token` を使用して [`mfa/authenticator`](/docs/docs/ja-jp/api/authentication/multi-factor-authentication/list-authenticators) エンドポイントを呼び出し、ユーザーが登録済みの認証要素をすべて取得して、アプリケーションがサポートする `type` と一致するものを特定します。また、チャレンジを発行するには、対応する `authenticator_type` も取得する必要があります:

```json lines theme={null}
[
  {
    "type": "recovery-code",
    "id": "recovery-code|dev_qpOkGUOxBpw6R16t",
    "authenticator_type": "recovery-code",
    "active": true
  },
  {
    "type": "otp",
    "id": "totp|dev_6NWz8awwC8brh2dN",
    "authenticator_type": "otp",
    "active": true
  }
]
```

[`request/mfa/challenge`](/docs/docs/ja-jp/api/authentication/multi-factor-authentication/request-mfa-challenge) エンドポイントを呼び出して、MFA チャレンジを必須にします。

Auth0 Actions を使用すると、MFA フローをさらにカスタマイズできます。詳しくは、[Actions トリガー: post-challenge - API オブジェクト](/docs/docs/ja-jp/actions/reference/password-reset-post-challenge/password-reset-post-challenge-api-object) をご覧ください。
