I have a relatively clean install of Sitecore PowerShell Extensions v 5.0 in my environment, which is running Sitecore 9.1 on Azure PaaS. As far as I can tell, everything in the install seems to be working fine, except elevating permissions to run scripts in the Console. When I attempt to elevate permissions, I see an excessive number of network requests (3k+) flow through the browser, the window locks up, and I eventually have to kill the tab.
I am seeing this issue on both the XP-Single and XP-Scaled topologies. When I check the logs, it is showing that the session was elevated, however I cannot use it (even after refreshing the browser).
I attempted to re-install the module, but this did not resolve the issue.
Any ideas as to what might be causing those two requests to repeatedly fire?
UPDATE:
I pulled down the Git repo, and did the ol' add logging trick. It looks like the context of the authentication attempt for the console is coming through as an anonymous user, instead of the currently logged in user:
Local Environment (working):
13288 13:24:03 ERROR User is logged in: True
13288 13:24:03 ERROR User is authorized from manager: True for user sitecore\admin
13288 13:24:03 ERROR User is authorized: True
13288 13:24:03 ERROR Session is elevated: False
13360 13:24:05 WARN Session state elevated for 'Console' by user: sitecore\admin
1988 13:24:05 ERROR User is logged in: True
1988 13:24:05 ERROR User is authorized from manager: True for user sitecore\admin
1988 13:24:05 ERROR User is authorized: True
1988 13:24:05 ERROR Session is elevated: True
Non-Local Environment (not working):
21180 20:26:39 ERROR User is logged in: False
21180 20:26:39 ERROR User is authorized from manager: False for user extranet\Anonymous
21180 20:26:39 ERROR User is authorized: False
21180 20:26:39 ERROR Session is elevated: False
13220 20:26:46 WARN Session state elevated for 'Console' by user: sitecore\xcadmin
11464 20:26:47 ERROR User is logged in: False
11464 20:26:47 ERROR User is authorized from manager: False for user extranet\Anonymous
11464 20:26:47 ERROR User is authorized: False
11464 20:26:47 ERROR Session is elevated: True
Here is the snippet I modified:
[WebMethod(EnableSession = true)]
public object ExecuteCommand(string guid, string command, string stringFormat)
{
var serializer = new JavaScriptSerializer();
var output = new StringBuilder();
var isSessionElevated = SessionElevationManager.IsSessionTokenElevated(ApplicationNames.Console);
Log.Error($"User is logged in: {Sitecore.Context.IsLoggedIn}", this);
Log.Error($"User is authorized from manager: {ServiceAuthorizationManager.IsUserAuthorized(WebServiceSettings.ServiceClient, Sitecore.Context.User?.Name)} for user {Sitecore.Context.User?.Name}", this);
Log.Error($"User is authorized: {IsLoggedInUserAuthorized}", this);
Log.Error($"Session is elevated: {isSessionElevated}", this);
if (!IsLoggedInUserAuthorized || !isSessionElevated)
{
return serializer.Serialize(
new
{
status = StatusElevationRequired,
result =
"You need to be authenticated, elevated and have sufficient privileges to use the PowerShell console. Please (re)login to Sitecore.",
prompt = "PS >",
background = OutputLine.ProcessHtmlColor(ConsoleColor.DarkBlue)
});
}
...
}