---
title: "SitecoreインスタンスとSitecore Identityサーバーを構成してください"
slug: "configure-a-sitecore-instance-and-sitecore-identity-server"
abstract: "SitecoreインスタンスおよびSitecore Identityサーバーの設定方法"
---
# SitecoreインスタンスとSitecore Identityサーバーを構成してください

SitecoreインスタンスでSitecore Identity(SI)サーバー認証を設定するには、以下の条件が必要です:

-   [Sitecoreインスタンスの設定](https://doc.sitecore.com/xp/ja/developers/103/sitecore-experience-manager/configure-a-sitecore-instance-and-sitecore-identity-server.html#UUID-cf318396-9ffb-def8-f705-153192cb19b5_section-idm46212284250992 "Configure the Sitecore instance")
-   [Sitecore Identityサーバーの設定](https://doc.sitecore.com/xp/ja/developers/103/sitecore-experience-manager/configure-a-sitecore-instance-and-sitecore-identity-server.html#UUID-cf318396-9ffb-def8-f705-153192cb19b5_section-idm45900735853216 "Configure the Sitecore Identity server")

Sitecore Identity Serverコンポーネントの詳細については、「[Sitecore Identity Structure](https://doc.sitecore.com/xp/ja/developers/103/sitecore-experience-manager/sitecore-identity-structure.html "Sitecore Identity structure")」をご覧ください。

## Sitecoreインスタンスの設定

Sitecoreインスタンスを設定するには、SIサーバー認証を使用するすべてのSitecoreインスタンスを以下で有効にしてください:

-   SIサーバーの絶対URL(OpenId Connect用語では*Authority* )。これは $(identityServerAuthority) 設定変数で設定します。デプロイメントプロセスで指定されます。
    
-   登録されたクライアントのID。Sitecore SIサーバーにデフォルトクライアントを設定し、ID Sitecore。SitecoreはこのIDを
    
    FederatedAuthentication.IdentityServer.ClientId設定。
    
-   カスタム*Resource Owner Password*フロー専用クライアントのID。Sitecore内部目的でカスタム*Resource Owner Password*フローを使用します。 FederatedAuthentication.IdentityServer.ResourceOwnerClientId設定はこのクライアントのIDを指定します。デフォルト値はSitecorePasswordです。
    

Sitecoreは [、フェデレーテッド認証設定](https://doc.sitecore.com/xp/ja/developers/103/sitecore-experience-manager/configure-federated-authentication.html "Configure federated authentication")に従ってSIサーバーに接続します。

## Sitecore Identityサーバーの設定

Sitecore Identityサーバーはすべてのクライアントの構成を含まなければなりません( [Duende IdentityServerクライアント](https://docs.duendesoftware.com/identityserver/v6/reference/models/client/)を参照)。

Sitecore Identityサーバーの設定:

1.  Sitecore IdentityサーバーのConfig\\Sitecore.IdentityServer.Host.xmlファイルのSitecore:IdentityServer:Clients:PasswordClient:ClientSecrets: ClientSecret1設定でクライアントシークレットを設定してください。
    
    それはApp\_Config\\ConnectionStrings.configファイルのクライアントシークレットと同じでなければなりません。Sitecoreインスタンスのsitecoreidentity.secret接続文字列でなければなりません。
    
    Sitecore XPをインストールすると、クライアントシークレットはデフォルトでIdentity Server Sitecoreに設定されており、このステップは不要です。
    
2.  Sitecoreユーザーがサインインできるようにするには、Config\\Sitecore.IdentityServer.Host.xmlファイルのSitecore:IdentityServer:SitecoreMembershipOptions:ConnectionString設定で、*Security*データベースへの接続文字列を設定してください。
    
3.  ユーザーがパスワードを回復できるようにするには、Config\\Sitecore.IdentityServer.Host.xmlファイルでSitecore:IdentityServer:AccountOptions: PasswordRecoveryUrl設定を設定してください。
    
    Sitecore XPをインストールすると、Sitecoreインスタンスへのリンクがデフォルトで使われるため、この手順は不要です。
    
4.  クライアントを設定するにはSitecore:IdentityServer:Clientsセクションを使うか、依存性注入を使うことができます。
    
    各クライアント設定ノードには、Duende.IdentityServer.Models.Clientクラスのプロパティにバインドされた複数のプロパティが含まれています。ほとんどの場合、クラスプロパティと設定プロパティの名前は一致します。あるいは、依存注入を使ってDuende IdentityServerの全オプションにアクセスすることもできます。
    
    > !注Sitecore(Sitecore:IdentityServer:Clients:DefaultClient)というあらかじめ定義されたクライアントが存在します。
    
5.  デフォルトのSitecoreクライアント宣言を再利用するには、許可されたRedirectUris、PostLogoutRedirectUris、AllowedCorsOriginsの各値を拡張して、アプリケーションに適した値を含めるようにしてください。
    
    {AllowedCorsOrigin}特殊トークンは、RedirectUrisリストやPostLogoutRedirectUrisリストで使うことができます。以下の例(Config\\Sitecore.IdentityServer.Host.xmlファイルにあります):
    
    <?xml version="1.0" encoding="utf-8"?>
    <Settings>
     <Sitecore>
     <IdentityServer>
     <Clients>
     <DefaultClient>
     ...
     <RedirectUris>
     <RedirectUri1>{AllowedCorsOrigin}/identity/signin</RedirectUri1>
     <RedirectUri2>{AllowedCorsOrigin}/signin-oidc</RedirectUri2>
     </RedirectUris>
     <PostLogoutRedirectUris>
     <PostLogoutRedirectUri1>{AllowedCorsOrigin}/identity/postexternallogout</PostLogoutRedirectUri1>
     <PostLogoutRedirectUri2>{AllowedCorsOrigin}/signout-callback-oidc</PostLogoutRedirectUri2>
     </PostLogoutRedirectUris>
     ...
    
6.  URLのprotocol+domain+port部分をAllowedCorsOriginsセクションでのみ指定するには、{AllowedCorsOrigin}トークンを使用します。
    
    <?xml version="1.0" encoding="utf-8"?>
    <Settings>
     <Sitecore>
     <IdentityServer>
     <Clients>
     <DefaultClient>
     ...
     <AllowedCorsOrigins>
     <AllowedCorsOriginsGroup1>https://host1|http://host1</AllowedCorsOriginsGroup1>
     <AllowedCorsOriginsGroup2>https://host2</AllowedCorsOriginsGroup2>
     <AllowedCorsOriginsGroup3>https://host3</AllowedCorsOriginsGroup3>
     </AllowedCorsOrigins>
     ...
    
    Sitecoreは、RedirectUri\*ノード値とPostLogoutRedirectUri\*ノード値を拡張し、AllowedCorsOriginsリストで指定されたすべての原点に対して許可される{AllowedCorsOrigin}トークンを適用します。