Sitecore Identity - Sticky Virtual User Properties Issue

 I recently came across an issue with our CMS users getting elevated access permissions even after they were moved to a lower-level role. We use OKTA as our identity provider and use federated authentication to integrate Sitecore with OKTA for staff login. The OKTA group memberships are mapped to Sitecore roles using claims mapping to manage user roles in Sitecore. This was working fine for a long time until recently when we started noticing changing user roles in OKTA have no impact on the user permissions in Sitecore.

I started troubleshooting by monitoring the network traffic during the login redirect, capturing the JWT token to inspect the claims we are receiving from OKTA. Once the user's group membership in OKTA has changed, I can see the new groups values in the claims. So, the issue has to be on the Sitecore end with claims to roles mapping. After further investigating into the code which hasn't changed in months, I looked into what else has changed. We did upgrade our Sitecore version (and Identity server) a couple of times since the federated authentication was implemented. I looked into the release notes for any changes related to this functionality but that was a dead end.

In the meantime, we had to do a deployment and noticed that the new roles and permissions started reflecting post deployment. After being able to reproduce the same behaviour in my local dev environment I was able to conclude there is some kind of user profile caching going on at Sitecore end for the virtual users that's causing this and the only solution at the moment is to do an application restart which confirms why a deployment fixed the issue.

I logged a support ticket with Sitecore to investigate this. Sitecore suggested to try setting the Caching.DefaultClientDataCacheSize value to 0 to see if that resolves the issue. Changing the setting value to 0 did work. The new user roles and permissions started reflecting as soon as the user logged out of their current session and log back into a new session (should be a new browser session). Sitecore introduced UserRuntimeSettingsCache  in 10.2.1 prerelease. The UserRuntimeSettingsCache  is initialised as a service in the “Sitecore.DependencyInjection.DefaultSitecoreServicesConfigurator” class which makes it impossible to override using a config setting.

Sitecore confirmed this is a bug and working on a hotfix. If you are on Sitecore 10.2 or above and facing similar issues (you may want to check as this is not obvious to notice) contact Sitecore support and quote the bug reference number 594651 to request a hotfix for your Sitecore version.

For more information about public reference numbers can be found here: https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0853187


Update: Sitecore has provided a fix for this issue through a platform pre-release which can be found here: Sitecore 10.2.2 rev. 009719 PRE. Do note that this only applues to Sitecore 10.2 version and you need to upgrade to 10.2.1 version first before you can apply this pre-release.

Comments

Popular posts from this blog

SXA Scriban extension to get link field target URL

How to ace your Sitecore .Net Developer 10 Certification Exam

View and download Sitecore log files using Log Viewer