Hi Guys,
Recently we encountered an issue in our sharepoint portal where FedAuth Cookie generated from SPFederationAuthenticationModule was not getting created on certain Safari browsers. After a long hours of testing , trials and error. We found that the issue was caused by SameSite property of the browser Cookie.
So in order to fix it, I applied the below code snippet, just after the SetPrincipalAndWriteSessionToken of the SPFederationAuthenticationModule.
fam.SetPrincipalAndWriteSessionToken(securityToken);
string userAgent = Request.ServerVariables["HTTP_USER_AGENT"];
if ((userAgent.Contains("CPU iPhone OS") ||
userAgent.Contains("iPad; CPU OS") ||
userAgent.Contains("Macintosh; Intel Mac OS X")) &&
userAgent.Contains("Safari"))
{
HttpCookie httpCookie = null;
for (int i = 0; i < Response.Cookies.AllKeys.Count(); i++)
{
httpCookie = Response.Cookies[Response.Cookies.AllKeys[i]];
httpCookie.SameSite = SameSiteMode.Lax;
}
}
Recently we encountered an issue in our sharepoint portal where FedAuth Cookie generated from SPFederationAuthenticationModule was not getting created on certain Safari browsers. After a long hours of testing , trials and error. We found that the issue was caused by SameSite property of the browser Cookie.
So in order to fix it, I applied the below code snippet, just after the SetPrincipalAndWriteSessionToken of the SPFederationAuthenticationModule.
fam.SetPrincipalAndWriteSessionToken(securityToken);
string userAgent = Request.ServerVariables["HTTP_USER_AGENT"];
if ((userAgent.Contains("CPU iPhone OS") ||
userAgent.Contains("iPad; CPU OS") ||
userAgent.Contains("Macintosh; Intel Mac OS X")) &&
userAgent.Contains("Safari"))
{
HttpCookie httpCookie = null;
for (int i = 0; i < Response.Cookies.AllKeys.Count(); i++)
{
httpCookie = Response.Cookies[Response.Cookies.AllKeys[i]];
httpCookie.SameSite = SameSiteMode.Lax;
}
}
Comments
Post a Comment