1. 認証

ベアラートークン認証

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

Sitecoreは、CE Connectを経由せずにCommerce Engineを直接呼び出すシステムにベアラー トークン認証を使用します。呼び出し元は、トークンを取得するために、Sitecoreの資格情報を使用してSitecore Identityサーバーに接続する必要があります。Sitecoreは、そのトークンをリクエスト ヘッダーの認証ベアラーとして使用します。

Sitecore IdentityサーバーのURLは、Commerce Engineのconfig.jsonファイルのSitecoreIdentityServerUrlパラメーターに指定する必要があります。

Sitecore Identityサーバーは、トークンを取得するために次の2つのエンドポイントを提供します。

  • GetToken (http://{{SitecoreIdentityServerHost}}/connect/token)

    UIからログインせずにトークンを取得できるサイレントモード。Postman、コンソール、およびデプロイメントスクリプトで使用されます。

  • Authorize (http://{{SitecoreIdentityServerHost}}/connect/authorize)

    Sitecore Identity Serverのログイン ページを読み込みます。ユーザーがSitecoreの資格情報で正常にログインすると、ユーザーはWebサイトに戻ります。Commerce Business Toolsで使用されます。

Commerce Engineを呼び出すシステム (Postman、Commerce Business Toolsなど) のIDは、Sitecore.Commerce.IdentityServer.Host.xml構成ファイルに格納する必要があります。XML設定ファイルのデフォルトの場所はC:\inetpub\wwwroot\<SXAStorefront-IdentityServer>\Config\production\Sitecore.Commerce.IdentityServer.Host.xmlです。

以下は、Postmanクライアント用のSitecore Identity ServerのSitecore.Commerce.IdentityServer.Host.xmlファイル内のクライアント設定のサンプルです。

<PostmanClient>
    <ClientId>postman-api</ClientId>
    <ClientName>Postman API</ClientName>
    <AccessTokenType>0</AccessTokenType>
    <AllowOfflineAccess>true</AllowOfflineAccess>
    <AlwaysIncludeUserClaimsInIdToken>false</AlwaysIncludeUserClaimsInIdToken>
    <AccessTokenLifetimeInSeconds>3600</AccessTokenLifetimeInSeconds>
    <IdentityTokenLifetimeInSeconds>3600</IdentityTokenLifetimeInSeconds>
    <AllowAccessTokensViaBrowser>true</AllowAccessTokensViaBrowser>
    <RequireConsent>false</RequireConsent>
    <RequireClientSecret>false</RequireClientSecret>
    <AllowedGrantTypes>
      <AllowedGrantType1>password</AllowedGrantType1>
    </AllowedGrantTypes>
    <RedirectUris>
       <RedirectUri1>{AllowedCorsOrigin}/oauth2/callback</RedirectUri1>
    </RedirectUris>
    <PostLogoutRedirectUris>
       <PostLogoutRedirectUri1>{AllowedCorsOrigin}</PostLogoutRedirectUri1>
       </PostLogoutRedirectUris>
    <AllowedCorsOrigins>
        <AllowedCorsOrigins1>https://www.getpostman.com</AllowedCorsOrigins1>
     </AllowedCorsOrigins>
    <AllowedScopes>
        <AllowedScope1>openid</AllowedScope1>
        <AllowedScope2>EngineAPI</AllowedScope2>
        <AllowedScope3>postman_api</AllowedScope3>
        </AllowedScopes>
     <UpdateAccessTokenClaimsOnRefresh>true</UpdateAccessTokenClaimsOnRefresh>
 </PostmanClient>
    

Commerce Business ToolsのSitecore.Commerce.IdentityServer.Host.xmlにあるクライアント構成の例を次に示します。

<Clients>
     <CommerceClient>
       <ClientId>CommerceBusinessTools</ClientId>
       <ClientName>CommerceBusinessTools</ClientName>
       <AccessTokenType>0</AccessTokenType>
       <AllowOfflineAccess>true</AllowOfflineAccess>
       <AlwaysIncludeUserClaimsInIdToken>false</AlwaysIncludeUserClaimsInIdToken>
       <AccessTokenLifetimeInSeconds>3600</AccessTokenLifetimeInSeconds>
       <IdentityTokenLifetimeInSeconds>3600</IdentityTokenLifetimeInSeconds>
       <AllowAccessTokensViaBrowser>true</AllowAccessTokensViaBrowser>
       <RequireConsent>false</RequireConsent>
       <RequireClientSecret>false</RequireClientSecret>
       <AllowedGrantTypes>
         <AllowedGrantType1>implicit</AllowedGrantType1>
       </AllowedGrantTypes>
       <RedirectUris>
         <RedirectUri1>{AllowedCorsOrigin}</RedirectUri1>
       </RedirectUris>
       <PostLogoutRedirectUris>
         <PostLogoutRedirectUri1>{AllowedCorsOrigin}</PostLogoutRedirectUri1>
       </PostLogoutRedirectUris>
       <AllowedCorsOrigins>                     <AllowedCorsOriginsGroup1>http://localhost:4200|https://localhost:4200|http://localhost:5005|https://localhost:5005</AllowedCorsOriginsGroup1>
       </AllowedCorsOrigins>
       <AllowedScopes>
         <AllowedScope1>openid</AllowedScope1>
         <AllowedScope2>dataEventRecords</AllowedScope2>
         <AllowedScope3>dataeventrecordsscope</AllowedScope3>
         <AllowedScope4>securedFiles</AllowedScope4>
         <AllowedScope5>securedfilesscope</AllowedScope5>
         <AllowedScope6>role</AllowedScope6>
         <AllowedScope7>EngineAPI</AllowedScope7>
       </AllowedScopes>
       <UpdateAccessTokenClaimsOnRefresh>true</UpdateAccessTokenClaimsOnRefresh>
     </CommerceClient>
この記事を改善するための提案がある場合は、 お知らせください!