> ## Documentation Index
> Fetch the complete documentation index at: https://docs-dev-fix-docs-5528-php-updates.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OIDC Discoveryを使ってアプリケーションを構成する

> OpenID Connect（OIDC）Discoveryを使用して、Auth0でSDKを用いてアプリケーションを構成する方法について説明します。

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>;
};

[OpenID Connect（OIDC）Discovery](https://openid.net/specs/openid-connect-discovery-1_0-final.html#RFC5785)ドキュメントは、IDプロバイダー（<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-2" href="/docs/ja-jp/glossary?term=idp" tip="IDプロバイダー（IdP）: デジタルIDを保存および管理するサービス。" cta="用語集の表示">IdP</Tooltip>）についてのメタデータを含みます。SDKにディスカバリーを追加して、アプリケーションを`./wellknown`エンドポイントにポイントし、IdPに関する情報を取得することで、IdPとの統合構成に役立てることができます。

OIDC DiscoveryをSDKに統合すると以下が得られます。

* IdPの公開されているエンドポイント
* 標準の[OIDCがサポートするクレームとスコープ](/docs/ja-jp/get-started/apis/scopes/openid-connect-scopes)（これにはテナントで定義された[カスタムクレーム](/docs/ja-jp/secure/tokens/json-web-tokens/create-custom-claims)とスコープは含まれません）
* IdPがサポートする機能

次の<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-jp/glossary?term=openid" tip="OpenID: アプリケーションがログイン情報を収集および保存することなくにユーザーのIDを検証できるようにする認証用のオープン標準。" cta="用語集の表示">OpenID</Tooltip> Connect（OIDC）Discoveryドキュメントを使ってアプリケーションを構成することができます：`https://{yourDomain}/.well-known/openid-configuration`

### 応答例

export const codeExample1 = `{
  "issuer": "https://{yourDomain}.us.auth0.com/",
  "authorization_endpoint": "https://{yourDomain}.us.auth0.com/authorize",
  "token_endpoint": "https://{yourDomain}.us.auth0.com/oauth/token",
  "device_authorization_endpoint": "https://{yourDomain}.us.auth0.com/oauth/device/code",
  "userinfo_endpoint": "https://{yourDomain}.us.auth0.com/userinfo",
  "mfa_challenge_endpoint": "https://{yourDomain}.us.auth0.com/mfa/challenge",
  "jwks_uri": "https://{yourDomain}.us.auth0.com/.well-known/jwks.json",
  "registration_endpoint": "https://{yourDomain}.us.auth0.com/oidc/register",
  "revocation_endpoint": "https://{yourDomain}.us.auth0.com/oauth/revoke",
  "scopes_supported": [
    "openid",
    "profile",
    "offline_access",
    "name",
    "given_name",
    "family_name",
    "nickname",
    "email",
    "email_verified",
    "picture",
    "created_at",
    "identities",
    "phone",
    "address"
  ],
  "response_types_supported": [
    "code",
    "token",
    "id_token",
    "code token",
    "code id_token",
    "token id_token",
    "code token id_token"
  ],
  "code_challenge_methods_supported": [
    "S256",
    "plain"
  ],
  "response_modes_supported": [
    "query",
    "fragment",
    "form_post"
  ],
  "subject_types_supported": [
    "public"
  ],
  "id_token_signing_alg_values_supported": [
    "HS256",
    "RS256",
    "PS256"
  ],
  "token_endpoint_auth_methods_supported": [
    "client_secret_basic",
    "client_secret_post",
    "private_key_jwt"
  ],
  "claims_supported": [
    "aud",
    "auth_time",
    "created_at",
    "email",
    "email_verified",
    "exp",
    "family_name",
    "given_name",
    "iat",
    "identities",
    "iss",
    "name",
    "nickname",
    "phone_number",
    "picture",
    "sub"
  ],
  "request_uri_parameter_supported": false,
  "request_parameter_supported": false,
  "token_endpoint_auth_signing_alg_values_supported": [
    "RS256",
    "RS384",
    "PS256"
  ]
}`;

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

### 実装例

たとえば、以下の方法でKatana v3（OWIN）に対するOIDCミドルウェアを構成します。

1. NuGetのパッケージをインストールします：**Microsoft.Owin.Security.OpenIdConnect** （v3.x.x）
2. `App_Start\Startup.Auth.cs`に移動し、実装を以下に置き換えます。

export const codeExample2 = `   app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = CookieAuthenticationDefaults.AuthenticationType
});

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
    Authority = "https://{yourDomain}/",
    ClientId = "{yourClientId}",
    SignInAsAuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
    ResponseType = "token",
    Notifications = new OpenIdConnectAuthenticationNotifications
    {
        // OPTIONAL: you can read/modify the claims that are populated based on the JWT
        SecurityTokenValidated = context =>
        {
            // add Auth0 Access Token as claim
            var accessToken = context.ProtocolMessage.AccessToken;
            if (!string.IsNullOrEmpty(accessToken))
            {
                context.AuthenticationTicket.Identity.AddClaim(new Claim("access_token", accessToken));
            }
            return Task.FromResult(0);
        }
    }
});
`;

<AuthCodeBlock children={codeExample2} language="text" lines />

## JWTのRSAアルゴリズム

OIDCミドルウェアは対称鍵で署名された<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-3" href="/docs/ja-jp/glossary?term=json-web-token" tip="JSON Web Token（JWT）: 二者間のクレームを安全に表現するために使用される標準IDトークン形式（および多くの場合、アクセストークン形式）。" cta="用語集の表示">JWT</Tooltip>をサポートしていません。必ず、公開鍵/秘密鍵を使用して、RSAアルゴリズムを使用するようにアプリを構成してください。

1. [［Dashboard］>［Settings（設定）］](https://manage.auth0.com/#/applications/%7BYOUR_AUTH0_CLIENT_ID%7D/settings)に移動します。
2. **［Advanced Settings（高度な設定）］** までスクロールします。
3. **［OAuth］** タブで、`RS256`を **［Json Web Token (JWT) Signature Algorithm（JSON Web Token署名アルゴリズム）］** に設定し、**［Save（保存）］** をクリックします。

この設定により、Auth0は秘密署名鍵で署名されたJWTを発行します。アプリはそれらを公開署名鍵で検証します。

## もっと詳しく

* [JSON Webトークン](/docs/ja-jp/secure/tokens/json-web-tokens)
* [カスタムクレームを作成する](/docs/ja-jp/secure/tokens/json-web-tokens/create-custom-claims)
