Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add public SignOut method to CasAuthentication class #37

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions DotNetCasClient/CasAuthentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,23 @@ public static void SingleSignOut()
response.Redirect(singleSignOutRedirectUrl, true);
}
}

/// <summary>
/// Clear authentication cookie and revoke service ticket in cache.
/// </summary>
/// <param name="ticket">Optionally specifies FormsAuthenticationTicket to explicitly sign out</param>
public static void SignOut(FormsAuthenticationTicket ticket = null)
{
// Defaults to current ticket
if (ticket == null)
ticket = GetFormsAuthenticationTicket();

// ClearAuthCookie();
FormsAuthentication.SignOut();

if (ServiceTicketManager != null && ticket != null)
ServiceTicketManager.RevokeTicket(ticket.UserData);
}

/// <summary>
/// Process SingleSignOut requests originating from another web application by removing the ticket
Expand Down Expand Up @@ -889,8 +906,7 @@ internal static void ProcessRequestAuthentication()
securityLogger.Warn("CasAuthenticationTicket failed verification: " + casTicket);

// Deletes the invalid FormsAuthentication cookie from the client.
ClearAuthCookie();
ServiceTicketManager.RevokeTicket(serviceTicket);
SignOut(formsAuthenticationTicket);

// Don't give this request a User/Principal. Remove it if it was created
// by the underlying FormsAuthenticationModule or another module.
Expand Down Expand Up @@ -1603,4 +1619,4 @@ public static string[] BypassCasForHandlers

#endregion
}
}
}