Use the Sitecore Identity server as a federation gateway
Because it is based on the IdentityServer4, you can use the Sitecore Identity (SI) server as a gateway to one or more external identity providers (or subproviders, sometimes also called inner providers). IdentityServer4 Federation Gateway has more information about this concept.
When you configure a subprovider, a login button for this provider appears on the login screen of the SI server.
You must enable the Azure AD identity provider that is included with the SI server. See the {SI_server_root_folder}\sitecore\Sitecore.Plugin.IdentityProvider.AzureAd\Config\readme.txt file for instructions about to do this.
You can configure Azure AD to work with the SI server by authorizing access to web applications using OpenID Connect and Azure Active Directory
If you see this error: "The reply url specified in the request does not match the reply urls configured for the application:", use the https://[SI Server host name]/signin-oidc URL in the replyUrls section of the application manifest.
Configure subproviders in the Sitecore Identity server
To add a subprovider in the SI server:
-
Create a new plugin in Visual Studio:
- Create a Class Library (.NET Standard) C# project.
- Create a
global.jsonfile at the root of the repository:Specify the version as appropriate. - Edit the
csprojfile: add<Sdk Name="Sitecore.Framework.Runtime.Build" />after theProjectnode. - Add other references you need: Sitecore.Framework.Runtime.Commands to enable commands, Sitecore.Framework.Runtime.Abstractions to enable using runtime abstractions, and references to other plugins if you build on features already in a plugin.
-
Configure services for the preferred subprovider according to the instructions for this provider, and specify the
SignInSchemesetting asidsrv.external.NoteTo use authentication middleware such as AddOpenIdConnect, you must have an object of the
Microsoft.AspNetCore.Authentication.AuthenticationBuildertype . Usenew Microsoft.AspNetCore.Authentication.AuthenticationBuilder(services)instead ofservices.AddAuthentication()in your plugin. -
Register your subprovider in the configuration. The
{SI_server_root_folder}\sitecore\Sitecore.Plugin.IdentityProvider.AzureAd\Config\Sitecore.Plugin.IdentityProvider.AzureAd.xmlfile has an example of this. -
Optionally, register a subprovider in the Sitecore instance.
Register subproviders in the Sitecore instance
By default, the Sitecore instance knows only about one external identity provider: the SI server (the SitecoreIdentityServer name in the Sitecore.Owin.Authentication.IdentityServer.config configuration file) and it does not know about any subproviders unless you explicitly specify them.
You specify subproviders in the following situations:
- You want to map the subprovider to other sites instead of the
SitecoreIdentityServeritself. For example, the SI server is mapped to theshellandadminsites, but you want to map the Azure AD provider configured in the SI server to thewebsite. - You use the
GetSignInUrlInfoPipelinepipeline and you want to get a sign-in URL for a particular subprovider to redirect users directly to the subprovider login page (skipping the SI login page).
It is optional to register subproviders in Sitecore in order to use the new login endpoint with subproviders. If you enable the built-in Azure AD subprovider in the SI server, and then specify this URL $(loginPath)shell/SitecoreIdentityServer/IdS4-AzureAd in the loginPage attribute of a shell site, shell users can authenticate using Azure AD and skip the SI server login page
To register Azure AD in the SI server, specify the value of the AuthenticationScheme setting as IdS4-AzureAd.
To register a subprovider in Sitecore:
-
Add an
identityProvidernode in thesitecore/federatedAuthentication/identityProvidersnode. This configuration node must follow the naming conventions for thenameparameter. Thenameparameter must be in this format:[gateway_identity_provider]/[AuthenticationScheme], wheregateway_identity_provideris an identity provider that Sitecore communicates with directly, andAuthenticationSchemeis an authentication scheme of a subidentity provider you have configured ingateway_identity_provider(for example, IdS4-AzureAd).There are a number of limitations to take into account:
- The
TriggerExternalSignOutandTransformationsproperties are inherited from thegateway_identity_providernode and you cannot override them. - The
Enabledproperty of thegateway_identity_providerprovider must be set toEnabledto enable this subprovider.
- The
The App_Config\Sitecore\Owin.Authentication.IdentityServer\Sitecore.Owin.Authentication.IdentityServer.config configuration file has an example of registering Azure AD subprovider.
Configure claims transformations
You can configure claims transformations for each external identity provider. They are similar to what Sitecore already has, however, you have to have claims transformations on the SI server side for the following reasons:
- There are no Sitecore instances in the communication between the SI server and other SI clients (those that are not Sitecore itself). For instance, if some non-Sitecore application uses the SI server as an external provider, that application will not receive normalized claims unless they are normalized in SI server.
- The SI server returns only those claims that were actually requested by SI clients using Scopes. Therefore, SI clients will not receive claims that are unknown to them.
By default, Sitecore Identity operates with the following custom scopes: sitecore.profile as an identity resource and sitecore.profile.api as an API resource.
You can modify requested scopes for Sitecore in this pipeline: sitecore/pipelines/owin.identityProviders/processor[id=SitecoreIdentityServer]/scopes).
For applications that use the Sitecore.Plugin.Authentication.OpenIdConnect package, check the {application_root_folder}\sitecore\Sitecore.Plugin.Authentication.OpenIdConnect\Config\openIdConnect.xml file. The configuration path is Sitecore:Authentication:OpenIdConnectOptions:Scope:....
You can find default scope definitions in the {SI_server_root_folder}\sitecore\Sitecore.Plugin.IdentityServer\Config\identityserver.xml file.
The sitecore.profile and sitecore.profile.api scopes both contain the following claims:
- name
- role
http://www.sitecore.net/identity/claims/isAdminhttp://www.sitecore.net/identity/claims/originalIssuer
To give users roles:
-
Map a particular incoming claim to the appropriate role claims. For example, to transform the 90e5a2e5-4e3f-4f25-8beb-1238052fda8e Azure AD group to the sitecore\Author role:
Do not add multiple nodes with the same name. If you need multiple nodes, name the nodes AzureGroupTransformation1, AzureGroupTransformation2, and so forth.
To make a user an administrator:
-
Add
http://www.sitecore.net/identity/claims/isAdminand set the value totrue(being an admin user in Sitecore is not about having a particular role). For example, to make all users from a9bb60b6-40d2-4e2a-88b8-0e47ee2d078e Azure AD group Sitecore administrator users:
Then map the claim in Sitecore in the configuration:sitecore:federatedAuthentication:propertyInitializer:maps node. The {application_root_folder}\App_Config\Sitecore\Owin.Authentication.IdentityServer\Sitecore.Owin.Authentication.IdentityServer.config file has an example of this:
Use a similar procedure for the transformed name and email claims to map them to User properties in Sitecore.
The following example illustrates the necessity of having a mandatory claims transformation:
If a subprovider returns an identity with the http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress claim, you cannot retrieve it in any SI client. You have two options:
- In the SI server, you can add a claims transformation to map
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddressto anemailclaim. See the example in the{SI_server_root_folder}\sitecore\Sitecore.Plugin.IdentityProvider.AzureAd\Config\Sitecore.Plugin.IdentityProvider.AzureAd.xmlfile. - Register a new scope with the necessary claims in the SI server, allow the client to request this scope, and request this scope by the client.
There are a number of limitations when Sitecore creates persistent users to represent external users. Sitecore does not support the following features for such users:
- Reading and deleting roles of external users in the User Manager because these roles are not stored in Sitecore.
- Because of this, using the Access Viewer.
- Changing a user password. You have to change passwords it in the corresponding identity provider.
Configure Azure AD
When you configure and use Azure AD with the Sitecore Identity server, you have to remember:
- Check the ID tokens checkbox in the Advanced Settings in the Web - Authentication tab in the application registration.
- Set the value of the
groupMembershipClaimssetting in the application manifest toSecurityGroup. - You can only configure
replyUrlsin the legacy version of the application registration. UsereplyUrlsWithTypeinstead.