> ## 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.

> MFA向けに Cisco Duo Security を設定する方法について説明します。

# MFA向けに Cisco Duo Security を設定する

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) + "*****マスク済み*****";
          }
          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>;
};

<Card title="始める前に">
  * Duo アカウントを設定します。詳しくは、[Duo Docs の Getting Started](https://duo.com/docs/getting-started#getting-started) を参照してください。
  * [Duo Security Web SDK 統合](https://duo.com/docs/duoweb) を作成し、**Integration Key**、**Secret Key**、**API hostname** の認証情報を記録します。
</Card>

Cisco Duo は複数の認証方法に対応した認証プロバイダーであるため、他のすべての認証要素が無効になっている場合にのみ、Auth0 テナントで使用できます。Duo アカウントでは、設定に応じてプッシュ通知、SMS、OTP、電話コールバックなどをサポートできます。

他の認証要素が有効になっている場合、Duo を有効にすることはできません。Duo は、有効になっている唯一の認証要素である場合にのみユーザーが利用できます。

アプリケーションは Duo を使用してユーザーに第 2 認証要素を求め、Duo アカウントで有効にしたオプションを表示します。

ユーザーは、第 2 認証要素として使用するために、[Google Play](https://play.google.com/store/apps/details?id=com.duosecurity.duomobile) または [App Store](https://itunes.apple.com/us/app/duo-mobile/id422663827?mt=8) から Duo をダウンロードできます。

<div id="configure-duo">
  ## Duo を設定する
</div>

Duo Security を設定するには、<Tooltip tip="Auth0 Dashboard: サービスを設定するための Auth0 の主要プロダクト。" cta="用語集を見る" href="/ja/docs/glossary?term=Auth0+Dashboard">Auth0 Dashboard</Tooltip> で、Duo の認証情報をアプリケーションに渡すよう設定する必要があります。

1. [Dashboard > Security > Multi-factor Auth > Duo Security](https://manage.auth0.com/#/security/mfa/duo) に移動し、これを有効にします。
2. 各フィールドに必要な情報を入力して、Duo アカウントを Auth0 にリンクします。
3. **Save** を選択します。

<div id="use-actions-to-enable-duo">
  ## Actions を使用して Duo を有効にする
</div>

Action で Duo を有効にするには、<Tooltip tip="多要素認証（MFA）: SMS で送信される code など、ユーザー名とパスワードに加えて認証要素を使用するユーザー認証プロセス。" cta="用語集を表示" href="/ja/docs/glossary?term=multi-factor+authentication">多要素認証</Tooltip>を有効にする際に、`provider` パラメーターに `duo` を指定します。

```js lines theme={null}
exports.onExecutePostLogin = async (event, api) => {
  api.multifactor.enable('duo', { allowRememberBrowser: false });
};
```

Duo には、"Remember Me" の動作を設定するオプションはありません。30 日間の MFA セッションはハードコードされており、初回ログイン後はユーザーを記憶するようになっています。

ユーザーに毎回 Duo でログインさせるには、`allowRememberBrowser: false` を指定した Rule を作成します。

<div id="actions-template-for-duo">
  ## Duo 向け Actions テンプレート
</div>

このテンプレートは、条件が満たされたときに [Duo Security](http://duosecurity.com/) で多要素認証をトリガーするための例と出発点を示します。

初回ログイン時に、ユーザーはデバイスを登録できます。

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  Duo Security で 2 つの統合を作成する必要があります。1 つは **Web SDK** タイプ、もう 1 つは **Admin SDK** タイプです。
</Callout>

export const codeExample = `exports.onExecutePostLogin = async (event, api) => {

	const CLIENTS_WITH_MFA = ['{yourClientId}'];
	// 指定したクライアントに対してのみ実行
	if (CLIENTS_WITH_MFA.includes(event.client.client_id)) {

		// user_metadata.use_mfa === true のユーザーにのみ第 2 認証要素を要求する場合は、次の if 句のコメントを解除してください
		//if (event.user.user_metadata && event.user.user_metadata.use_mfa){

		// 任意。デフォルトは true です。毎回 DuoSecurity を強制するには false に設定します。
		// 詳細は https://auth0.com/docs/multifactor-authentication/custom#change-the-frequency-of-authentication-requests を参照してください
		api.multifactor.enable('duo', {
			providerOptions.ikey: configuration.DUO_IKEY,
			providerOptions.skey: configuration.DUO_SKEY,
			providerOptions.host: configuration.DUO_HOST,
			allowRememberBrowser: false
		})

		// 任意。ユーザープロファイルの属性のいずれかを DuoSecurity での username として使用します。ユーザーがすでに Duo に登録済みの場合にも便利です。
		// username: event.user.nickname
	};
	// }

};`;

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

<div id="current-limitations">
  ## 現在の制限事項
</div>

* [Auth0 MFA Enrollment Tickets](/ja/docs/secure/multi-factor-authentication/multi-factor-authentication-developer-resources/create-custom-enrollment-tickets) を使用して、Duo でユーザーを登録することはできません。該当するユーザーは Duo 側で登録してください。
* <Tooltip tip="Universal Login: アプリケーションは、ユーザーの本人確認のために、Auth0 の認可サーバーでホストされる Universal Login にリダイレクトされます。" cta="用語集を表示" href="/ja/docs/glossary?term=Universal+Login">Universal Login</Tooltip> を使用する場合は、前述のとおり、`provider` を `duo` に設定した Action で Duo を有効にする必要があります。特定のアプリケーションでは、Duo と Auth0 の組み込みプロバイダーを条件に応じて使い分けることもできます。
