Change Password and Logout from Sitecore CMS still allows to access /sitecore home page
Context:
Recently, I came across an interesting scenario from a Sitecore Slack channel thread that the home page is accessible after a user changes password and logs out of the CMS. So, I decided to simulate the issue in a local instance and I could do the same. So, instead of explaining the situation via words, here is a video that demonstrates the issue in a fresh 10.4 Sitecore instance:
Root Cause:
The root cause for the issue is, the application cookies for the domain were still accessible esp., the .ASPXAUTH session cookie:
Once I manually deleted the concerned application cookie, the authentication process would kick-in and display the login page automatically.
Fix:
By trial and error, I found that if I could invoke the FormsAuthentication Signout method, the cookie clearance would work fine, SignOut method is quite self-explanatory here below:
Now, all I had to do was patch the invocation call in a relevant processor and I chose to do before login as follows:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Sitecore.Diagnostics; | |
using Sitecore.Pipelines.Logout; | |
namespace CustomSitecoreLogout | |
{ | |
public class LogoutProcessor | |
{ | |
public void Process(LogoutArgs args) | |
{ | |
Tracer.Info("Intercepting call to Sitecore logout."); | |
System.Web.Security.FormsAuthentication.SignOut(); | |
} | |
} | |
} |
**************
Patch Config:
#############
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> | |
<sitecore> | |
<pipelines> | |
<speak.logout> | |
<processor type="CustomSitecoreLogout.LogoutProcessor" patch:before="processor[@type='Sitecore.Pipelines.Logout.GotoLogin, Sitecore.Kernel']"/> | |
</speak.logout> | |
</pipelines> | |
</sitecore> | |
</configuration> |
#############
End-result:
Once you do the usual shenanigans of dll deployment to webroot bin folder and patch the config under site' App_config zzz folder, here is the end-result of the patch:
Github - ensure to publish dll and config file to correct webroot folder path
Comments
Post a Comment