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

> Auth0 は、リクエストに クライアントシークレット を含まない機密アプリケーションからの /passwordless/start エンドポイントの使用を非推奨としているため、必要な移行手順について説明します。

# 機密アプリケーションからパスワードレス エンドポイントに移行する

export const AuthCodeBlock = ({filename, icon, language, highlight, children}) => {
  const [displayText, setDisplayText] = useState(children);
  const [copyText, setCopyText] = useState(children);
  const wrapperRef = React.useRef(null);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      if (!window.autorun || !window.rootStore) {
        return;
      }
      unsubscribe = window.autorun(() => {
        let processedChildrenForDisplay = children;
        let processedChildrenForCopy = children;
        for (const [key, value] of window.rootStore.variableStore.values.entries()) {
          const escapedKey = key.replaceAll(/[.*+?^${}()|[\]\\]/g, (String.raw)`\$&`);
          let displayValue = value;
          if (key === "{yourClientSecret}" && value !== "{yourClientSecret}") {
            displayValue = value.substring(0, 3) + "*****MASKED*****";
          }
          processedChildrenForDisplay = processedChildrenForDisplay.replaceAll(new RegExp(escapedKey, "g"), displayValue);
          processedChildrenForCopy = processedChildrenForCopy.replaceAll(new RegExp(escapedKey, "g"), value);
        }
        setDisplayText(processedChildrenForDisplay);
        setCopyText(processedChildrenForCopy);
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  useEffect(() => {
    if (!wrapperRef.current) return;
    const originalWriteText = navigator.clipboard.writeText.bind(navigator.clipboard);
    let isOverriding = false;
    const handleClick = e => {
      const button = e.target.closest('[data-testid="copy-code-button"]');
      if (!button || !wrapperRef.current.contains(button)) return;
      isOverriding = true;
      navigator.clipboard.writeText = text => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
          return originalWriteText(copyText);
        }
        return originalWriteText(text);
      };
      setTimeout(() => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
        }
      }, 100);
    };
    const wrapper = wrapperRef.current;
    wrapper.addEventListener('click', handleClick, true);
    return () => {
      wrapper.removeEventListener('click', handleClick, true);
      if (navigator.clipboard.writeText !== originalWriteText) {
        navigator.clipboard.writeText = originalWriteText;
      }
    };
  }, [copyText]);
  return <div ref={wrapperRef}>
      <CodeBlock filename={filename} icon={icon} language={language} lines highlight={highlight}>
        {displayText}
      </CodeBlock>
    </div>;
};

Auth0 は、呼び出しがそのアプリケーションに代わって行われていることを Auth0 が確認できない場合、confidential アプリケーションからの `/passwordless/start` エンドポイントの使用を非推奨とします。

<Tooltip tip="OAuth 2.0: 認可プロトコルとワークフローを定義する認可フレームワーク。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=OAuth">OAuth</Tooltip> では、シークレットを保存できるアプリケーションを 'confidential' と呼びます。Auth0 では、これに該当するのは 'Regular Web Applications'、つまりバックエンドアプリから Web ページを配信する従来型Webアプリケーションです。シングルページアプリケーションとネイティブアプリケーションは 'public' アプリケーションと見なされるため、この変更の影響はありません。

Auth0 は、`client_secret` がパラメーターとして含まれている場合、または呼び出しがクラシックログインのカスタムログインページから行われ、`state` パラメーターが転送される場合に、`/passwordless/start` への呼び出しを認証できます。

<div id="features-affected">
  ## 影響を受ける機能
</div>

現在、いずれかのアプリケーションが Web アプリケーションから<Tooltip tip="パスワードレス: 第1認証要素としてパスワードに依存しない認証の形式。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=passwordless">パスワードレス</Tooltip>認証を開始するために `/passwordless/start` エンドポイントを直接呼び出しており、`client_secret` をパラメーターとして送信していない場合、この非推奨化の影響を受けます。

クラシックログインページでパスワードレス認証を実装しており、Auth0 ライブラリの既定の初期化方法を変更している場合も、影響を受ける可能性があります。

影響を受けるかどうかは、[テナントログ](https://manage.auth0.com/#/logs)を確認し、「非推奨通知」で絞り込んだうえで、「Enforce client authentication for passwordless connections」というログがあるかを確認することで判断できます。また、次のクエリを使って直接検索することもできます：`type:depnote AND description:*passwordless*`。なお、このクエリが使えるのはパブリッククラウドのテナントのみです。プライベートクラウドのログでは、description フィールドで検索できないためです。

<div id="actions">
  ## Actions
</div>

適切なアプリケーション認証を行わずに `/passwordless/start` エンドポイントを呼び出している場合は、次の対応が必要です。

* 以下の説明に従ってコードを調整し、`/passwordless/start` を正しく呼び出せるようにしてください。
* [テナントログ](https://manage.auth0.com/#/logs)を確認し、変更が正しく行われていること、および「Enforce client authentication for passwordless connections」に関する非推奨化ログが生成されていないことを確認してください。
* **Advanced Tenant Settings** の **Migrations** セクションで、**Enforce client authentication for passwordless connections** トグルをオンにしてください。

影響を受ける可能性があるユースケースはいくつかありますが、いずれも移行手順は比較的シンプルです。

<div id="api-calls-from-backend">
  ### バックエンドからのAPI呼び出し
</div>

バックエンドから `/passwordless/start` エンドポイントに対して行う呼び出しでは、パラメーターとして <Tooltip tip="Client Secret: クライアント（アプリケーション）が認可サーバーに対して認証を行うために使用するシークレット。クライアントと認可サーバーだけが知るべき情報であり、推測されないよう十分なランダム性が必要です。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=client+secret">クライアントシークレット</Tooltip> を必ず含める必要があります。

`/passwordless/start` に直接 POST リクエストを送信する場合は、`client_secret` をペイロードに含めます。

export const codeExample = `POST https://{yourDomain}/passwordless/start
    Content-Type: application/json
    {
      "client_id": "{yourClientId}",
      "client_secret": "{yourClientSecret}",
      "connection": "email|sms",
      "email": "{userEmailAddress}", //connection=email のときに設定
      "phone_number": "{userPhoneNumber}", //connection=sms のときに設定
      "send": "link|code",
      "authParams": { 
          "scope": "openid",
          "state": "{yourState}"
        }
      }`;

<AuthCodeBlock children={codeExample} language="json" />

SDK を使用している場合は、パスワードレスフローを開始するメソッドにそのパラメーターを追加してください。設定方法は SDK ごとに異なり、まだ更新されていない SDK もあります。更新されていない SDK を使用している場合は、対応が完了するまで HTTP 呼び出しを直接行うことができます。

<div id="auth0js-or-lockjs-in-the-classic-login-page">
  ### クラシックログインページでの Auth0.js または Lock.js
</div>

Web アプリケーションでパスワードレス認証にクラシックログインページを使用している場合、Lock.js または Auth0.js を使って `/passwordless/start` エンドポイントを呼び出すことになります。

Web ページにクライアントシークレットを保存することはできないため、この呼び出しを認証するには、クラシックログインページで受け取った `state` パラメーターを `/passwordless/start` エンドポイントに転送します。そのパラメーターは、カスタムログインページの `config.internalOptions` フィールドに保存されています。

ログインページをカスタマイズするためのデフォルトテンプレートでは、Lock.js または auth0.js の初期化時に、次のようにこれを使用します。

```javascript lines theme={null}
var lock = new Auth0Lock(
  config.clientID, 
  config.auth0Domain, 
  {
    auth: {
      // .. その他のフィールドを設定
      params: {
       scope: config.internalOptions.scope,
       _csrf: config.internalOptions._csrf,
       state: config.internalOptions.state,
      }
    }
  });
```

```javascript lines theme={null}
var params = Object.assign({
    scope: config.internalOptions.scope,
    _csrf: config.internalOptions._csrf,
    state: config.internalOptions.state,
  }, {
    // ...認証パラメータ
  });

var webAuth = new auth0.WebAuth(params);
```

カスタムページの実装で、そのコードを削除していないことを確認してください。

<div id="call-passwordlessstart-from-the-client-in-a-web-application">
  ### Web アプリケーションでクライアントから /passwordless/start を呼び出す
</div>

通常の Web アプリケーションで、JavaScript を使用するページ (たとえば、そのページで auth0.js を使用する場合) から `/passwordless/start` エンドポイントを呼び出している場合、JavaScript による呼び出しではクライアントシークレットを指定できません。これがアプリケーションに該当する場合は、`/passwordless/start` をフロントエンドではなく Web アプリケーションのバックエンドから呼び出すように変更する必要があります。

<div id="rate-limits">
  ### レート制限
</div>

`/passwordless/start` にクライアント認証を追加すると、Auth0 はそのリクエストで送信されるヘッダーを信頼できるようになります。`auth0-forwarded-for` ヘッダーを設定すると、IP アドレスがログに表示され、<Tooltip tip="攻撃対策: Auth0 が攻撃を検出して軽減するために提供する機能で、総当たり攻撃対策、不審な IP スロットリング、漏えいパスワードの検知、ボット検出、適応型多要素認証が含まれます。" cta="用語集を表示" href="/docs/ja-jp/glossary?term=attack+protection">攻撃対策</Tooltip> に使用されます。

認証済みの `/passwordless/start` リクエストは、通常の認証済み Authentication API リクエストとして扱われるため、対応する Authentication API のグローバルなレート制限が適用されます。
