> ## Documentation Index
> Fetch the complete documentation index at: https://docs-dev-actions-triggers-prototype.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) + "*****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>;
};

<Card title="Before you start">
  * お手持ちのDuoアカウントを構成します。詳細については、[Duo Docsの「Getting Started」](https://duo.com/docs/getting-started#getting-started)をお読みください。
  * [Duo SecurityのWeb SDK統合](https://duo.com/docs/duoweb)を作成し、**統合キー** 、**秘密鍵** と**APIホスト名** の資格情報を記録します。
</Card>

Cisco Duoは多角的な認証プロバイダーで、他の要素がすべて無効な場合にのみ、Auth0テナントで使用できます。Duoアカウントはプッシュ通知、SMS、OTP、電話でのコールバックの他、構成によってはそれ以外にも対応することができます。

他の要素が有効になっている場合、Duoは有効化できません。Duoは、それだけが単独で有効になっている場合にのみ使うことができます。

アプリケーションは、ユーザーにDuoを使った第二要素を求める際に、Duoアカウントで有効になっているオプションを表示します。

ユーザーは[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をダウンロードして、第二要素として使うことができます。

## Duoを構成する

Duo Securityを構成するには、<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-jp/glossary?term=auth0-dashboard" tip="Auth0 Dashboard: サービスを構成するためのAuth0の主製品。" cta="用語集の表示">Auth0 Dashboard</Tooltip>でアプリケーションにDuoの資格情報を渡す必要があります。

1. [［Dashboard］>［Security（セキュリティ）］>［Multi-factor Auth（多要素認証）］>［Duo Security］](https://manage.auth0.com/#/security/mfa/duo)に移動して、有効にします。
2. フィールドに情報を入力して、DuoアカウントをAuth0とリンクさせます。
3. **［Save（保存）］** を選択します。

## アクションを使ってDuoを有効にする

アクション内でDuoを有効化するには、多要素認証を有効化する際に`duo`を`provider`パラメーターとして渡します。

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

Duoには、「Remember Me（自動ログイン）」の動作オプションはありません。初回のログイン後にユーザーを記憶しておく、30日間の<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-jp/glossary?term=multifactor-authentication" tip="多要素認証（MFA）: ユーザー名とパスワードに加えて、SMS経由のコードなどの要素を使用するユーザー認証プロセス。" cta="用語集の表示">MFA</Tooltip>セッションがハードコードされています。

ユーザーが毎回Duoを使ってログインすることを強制するには、`allowRememberBrowser: false`を使ってルールを作成します。

## Duo用のアクションテンプレート

このテンプレートは例として、条件が満たされた場合に[Duo Security](http://duosecurity.com/)を使った多要素認証をトリガーする始点を提供します。

初めてログインした後、ユーザーはデバイスを登録することができます。

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

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

	const CLIENTS_WITH_MFA = ['{yourClientId}'];
	// run only for the specified clients
	if (CLIENTS_WITH_MFA.includes(event.client.client_id)) {

		// uncomment the following if clause in case you want to request a second factor only from user's that have user_metadata.use_mfa === true
		//if (event.user.user_metadata && event.user.user_metadata.use_mfa){

		// optional, defaults to true. Set to false to force DuoSecurity every time.
		// See https://auth0.com/docs/multifactor-authentication/custom#change-the-frequency-of-authentication-requests for details
		api.multifactor.enable('duo', {
			providerOptions.ikey: configuration.DUO_IKEY,
			providerOptions.skey: configuration.DUO_SKEY,
			providerOptions.host: configuration.DUO_HOST,
			allowRememberBrowser: false
		})

		// optional. Use some attribute of the profile as the username in DuoSecurity. This is also useful if you already have your users enrolled in Duo.
		// username: event.user.nickname
	};
	// }

};`;

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

## 現在の制限

* Duoを使ってユーザーを登録するのに、[Auth0のMFA登録チケット](/docs/ja-jp/secure/multi-factor-authentication/multi-factor-authentication-developer-resources/create-custom-enrollment-tickets)は使用できません。それらのユーザーは、Duoから登録します。
* ユニバーサルログインを使う場合には、上記のように、アクションで`provider`を`duo`に設定してDuoを有効化する必要があります。特定のアプリケーションには、Duoを条件付きで使用するか、内蔵のAuth0プロバイダーを使うことができます。

## もっと詳しく

* [多要素認証問題をトラブルシューティングする](/docs/ja-jp/troubleshoot/authentication-issues/troubleshoot-mfa-issues)
