5

I am implementing a Single sign on solution for a client. It is required if a user is logged in for one of the two sitecore sites, he/she will be logged in for the other.
The first instance is 6.5.0 (rev. 121009) the second is 8.1 (rev. 160519). They share the same domain so they can share the cookies. I made the configuration of membership, roles,profile point to the same db.
The issue I am having right now is Sitecore 8.1 depends on another cookie called sitecore_userticket that is generated differently in 6.5. I was able to share the sitecore_userticket cookie across subdomains using this solution https://community.sitecore.net/developers/f/8/t/1241 but the problem that the cookie content is different across the versions remains

So currently if a user is authenticated first in Sitecore 8.1, he is authenticated in 6.5, while if he is authenticated first in sitecore 6.5, he is not authenticated in 8.1.

Is there any code I can use in Sitecore 6.5 to generate the expected cookie for Sitecore 8.1?

2
  • 2
    Why not create another cookie with a userId so that it can be shared across the different instances? Commented Dec 7, 2016 at 4:07
  • This is really a great idea. the .aspxauth is already shared and I can generate the ticket from there. I will post the solution below Commented Dec 7, 2016 at 18:55

1 Answer 1

1

Thanks to Hishaam Namooya who gave me the idea to the solution in his comment. Instead of creating the new ticket in the new version. I will make every version responsible for its own ticket cookie creation. The .aspxauth cookie is already shared between the 2 sitecore instances of different version. So I can check the user from there and call the code to create the ticket for the user.
As a modification to the cross domain solution for sitecore ticket cookie in the Global.asax here.

protected void Application_EndRequest(object sender, EventArgs e)
{
    var authCookie = HttpContext.Current.Response.Cookies["sitecore_userticket"];


    if (!Request.IsAuthenticated || authCookie == null)
    {
        // when checking response cookies, cookie is created if not exists, so delete now
        HttpContext.Current.Response.Cookies.Remove("sitecore_userticket");
        return;
    }

    //we don't need to make it cross domain as it will be different for every instance 
    //due to version differences.
    //create the ticket cookie. Every Sitecore instance will generate it the way it expects.
    authCookie.Value = TicketManager.CreateTicket(HttpContext.Current.User.Identity.Name, string.Empty);
}

This code must be in both sitecore instances Global.asax files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.