We are using OIOSAML.NET/dk.Nita for NemLog-in (Danish National Identity Provider) as authentication mechanism for editors. Claims from the federation are mapped to Sitecore users on login, and that part works great.
We are using Sitecore 8.1 update 3.
However, when logging out the user is only logged out from Sitecore when pressing "Logout" in the Sitecore Shell. I have therefore added a pipeline component in the Logout pipeline, where I change the redirect URL by injecting SheerResponse.SetLocation(urlString) into the Pipeline before GotoLogin (and aborting the pipeline). This works great for some pages, like the Content Editor.
public class LogoutFlowAdmin : ILogoutFlowAdmin
{
private readonly ISecurityContext _securityContext;
public LogoutFlowAdmin(ISecurityContext securityContext)
{
_securityContext = securityContext;
}
public void Process(LogoutArgs args)
{
args.AbortPipeline();
Tracer.Info("Intercepting call to Sitecore logout. Redirecting to Single Logout instead");
var urlString = _securityContext.GetLogoutUrl();
SheerResponse.SetLocation(urlString); // only works for non-SPEAK
}
}
However, since some pages use the SPEAK logout pipeline, I also need to inject my code here. This part does not include GotoLogin, so I assume the flow is somewhat different.
When I debug logout from SPEAK, I can see that my code is hit every time, but adding JavaScript using SheerResponse has no effect. Also I have tried a standard redirect (which of course causes an error when invoked in an Ajax handler), changing the RedirectUrl property of the LogoutArgs, but nothing seems to work for SPEAK logout.
One option would be to change the JavaScript that invokes the Ajax handler (Sitecore AuthenticationController) so the line below with window.location
is hardcoded to point to the custom Logout handler, but I would rather not go into that direction.
define(["sitecore", "jquery"], function (sc, $) {
sc.Factories.createBaseComponent({
name: "AccountInformation",
base: "ControlBase",
selector: ".sc-accountInformation",
logout: function (target, event) {
event.preventDefault();
// Disable cache to make sure that URL is always "followed"
// and the logout function gets executed on the server
var ajaxSettings = {
type: "POST",
url: "/sitecore/shell/api/sitecore/Authentication/Logout?sc_database=master",
data: {},
cache: false
};
var token = sc.Helpers.antiForgery.getAntiForgeryToken();
ajaxSettings.data[token.formKey] = token.value;
$.ajax(ajaxSettings).done(function (data) {
window.location = JSON.parse(data).Redirect; // possible to hack here
});
}
});
});
Does anyone have a way to change the URL the editor is redirected to after logout? Preferably in a manner that would be supported by Sitecore, and is sufficiently stable?
Update: I have been in contact with Sitecore support, that has informed that this is indeed a bug. It is fixed in 8.2. I still need a workaround, until we can upgrade, so any ideas are welcome :)
Update: Quick fix
I have implemented a temporary workaround in sitecore\shell\client\Business Component Library\Layouts\Renderings\Authentications\AccountInformation\AccountInformation.js where the line with window.location
is hardcoded to redirect to the Single Logout Page, as hinted in the code above.
Thank you all for your answers and comments :)