-
-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Following along with a blog post similar to this one: https://sitecore.derekc.net/setting-up-azure-active-directory-integration-with-sitecore-identity-server-sitecore-9-1/, you can set your Sitecore website up to authenticate users through 3rd party services, such as Azure Active Directory.
When you do this, Sitecore creates a persistent user for the user who is authenticating: https://doc.sitecore.com/developers/91/sitecore-experience-manager/en/using-federated-authentication-with-sitecore.html#UUID-2cc3b983-72ec-afe0-0b52-b2f9193c6a02_id_configuring-content-delivery-and-content
However, the federated persistent user isn't a "full" user in the Sitecore ecosystem. They're more like a virtual in-memory user. When logging in with a federated user, you can check the roles associated with their account via Sitecore.Context.User.Roles. This will show you all roles that have been mapped back to the user from their federated claims. However, when you check Sitecore.Security.Accounts.User.FromName(userName, false).Roles, you will always see zero roles associated with the account. This is because roles from federated claims are not saved back to the core database.
If you take a look at ServiceAuthorizationManager, line ~48, you will see User.FromName("username", false); being used for authorization checks: https://github.com/SitecorePowerShell/Console/blob/master/Spe/Core/Settings/Authorization/ServiceAuthorizationManager.cs
This is incompatible with federated user accounts.
Expected Behavior
- Configure a security role called "sitecore\ScriptUser" in sitecore.
- Grant access to execute Sitecore Powershell scripts to all users within the role of sitecore\ScriptUser. The right-click context menu is considered for this test case.
- Configure Sitecore Identity Server to authenticate users from a 3rd party source, such as Azure Active Directory.
- Create a role in Azure Active Directory for "Azure Script User", and map this back to the "sitecore\ScriptUser"
- Login with an Azure Active Directory account who has the "Azure Script User" role.
- Observe that this user can perform script executions via the right click context menu.
Actual Behavior
User cannot access right click context script menu
Steps to Reproduce the Problem
See expected behavior. I can assist with reproduction if needed. This is occurring in both SPE 5.0 and 5.1, but I believe it also exists in 6.x series.
-
Tested issue with clean install of Sitecore and the latest available version of SPE.
-
Asked questions on the Sitecore Slack Chat channel.
-
Reviewed questions and answers on the Sitecore Stack Exchange.