1

We have to modify some changes in the Sitecore identity server's Sitecore.IdentityServer.Host file using docker.

This file remains present at the location xp01.localidentityserver.dev.local\Config\production.

We want to modify the domain name with the new domain name, using XML transformation, as you can see in the config below [new-domain-name]

<?xml version="1.0" encoding="utf-8" ?>
<Settings>
  <Sitecore>
    <IdentityServer>
      <CertificateThumbprint>AA69xxxxxxxxxxxxxxxxxxx3A231</CertificateThumbprint>
      <CertificateStoreLocation>LocalMachine</CertificateStoreLocation>
      <CertificateStoreName>My</CertificateStoreName>
      <SitecoreMembershipOptions>
        <ConnectionString>Data Source=(local);Initial Catalog=xxxxx_Core;User ID=xxxxxxx;Password=******</ConnectionString>
      </SitecoreMembershipOptions>
      <AccountOptions>
        <PasswordRecoveryUrl>https://[new-domain-name]/sitecore/login?rc=1</PasswordRecoveryUrl>
      </AccountOptions>
      <Clients>
        <DefaultClient>
          <AllowedCorsOrigins>
            <AllowedCorsOriginsGroup1>https://[new-domain-name]</AllowedCorsOriginsGroup1>
          </AllowedCorsOrigins>
        </DefaultClient>
        <PasswordClient>
          <ClientSecrets>
            <ClientSecret1>IdentityServerClientSecret</ClientSecret1>
          </ClientSecrets>
        </PasswordClient>
      </Clients>
    </IdentityServer>
  </Sitecore>
</Settings>

How to perform this activity so that when we deploy this using docker and CI/CD on different environments (dev, uat and prod) then this [new-domain-name] should be according to that.

If with the Sitecore docker, there is any way other than transformation please suggest that as well. We are using Sitecore 10.2 with SXA.

2 Answers 2

1

You can try adding this to your docker-compose.override.xml file like below.

Sitecore_Sitecore__IdentityServer__Clients__DefaultClient__AllowedCorsOrigins__AllowedCorsOriginsGroup1: https://${HRZ_HOST}

Here is how it is being added to the file.

id:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-id:${VERSION:-latest}
    build:
      context: ./docker/build/id
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp1-cd:${SITECORE_VERSION}        
        TOOLING_IMAGE: ${SITECORE_TOOLS_REGISTRY}sitecore-docker-tools-assets:${TOOLS_VERSION}
        SOLUTION_IMAGE: ${REGISTRY}${COMPOSE_PROJECT_NAME}-solution:${VERSION:-latest}
    depends_on:
      - solution
    environment: 
      Sitecore_Sitecore__IdentityServer__Clients__DefaultClient__AllowedCorsOrigins__AllowedCorsOriginsGroup1: https://${HRZ_HOST}
    volumes:
      - ${LOCAL_DEPLOY_PATH}\identity:C:\deploy
    entrypoint: powershell -Command "& C:\tools\entrypoints\worker\Development.ps1"

Then try building and see if it works for you.

2
0

You can use XSLT transformation to transform XML files.

For that, create a .xslt file and paste the below transformations.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes" indent="yes" />
  <xsl:strip-space elements="*" />

  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*" />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="//IdentityServer/AccountOptions">
    <xsl:copy>
       <PasswordRecoveryUrl>https://[new-domain-name]/sitecore/login?rc=1 </PasswordRecoveryUrl>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="//IdentityServer/Clients/DefaultClient/AllowedCorsOrigins">
    <xsl:copy>
       <AllowedCorsOriginsGroup1>https://[new-domain-name]</AllowedCorsOriginsGroup1>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

After that, Open the dockerfile of the ID role, and map the XSLT file to ID image.

COPY ./<path of XSLT folder>/Sitecore.IdentityServer.Host.xslt /Config/production/Sitecore.IdentityServer.Host.xslt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.