在asp.net中使用CAS进行单点注销不会注销用户

时间:2014-03-06 20:21:51

标签: asp.net cas

使用单点登录在.Net中创建应用程序。我们已经实施了CAS。单点登录有效但单点登出无效。

在web.config中,CAS的配置如下:

<section name="casClientConfig" type="DotNetCasClient.Configuration.CasClientConfiguration, DotNetCasClient"/>

<casClientConfig 
   casServerLoginUrl="http://aus-vc-bdpu-tl1.argous.com:8100/cas/login"
   casServerUrlPrefix=" http://au-vc-bdpu-tl1.argous.com:8100/cas" 
   serverName="http://localhost:53124/"
   cookiesRequiredUrl="~/CookiesRequired.aspx"
   redirectAfterValidation="true" gateway="false" renew="false" singleSignOut="true"  
   ticketTimeTolerance="50000000" 
   ticketValidatorName="Saml11" proxyTicketManager="CacheProxyTicketManager" 
   serviceTicketManager="CacheServiceTicketManager"
   gatewayStatusCookieName="CasGatewayStatus"/>

我在下面的代码中添加了清除注销功能的cookie:

ClearAuthCookie();
string redirectPage = System.Configuration.ConfigurationSettings.AppSettings["CASurl"];
Response.Redirect(redirectPage, true);
public static void ClearAuthCookie()
{
    HttpContext current = HttpContext.Current;
    HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName); 
    cookie.Expires = DateTime.Now.AddMonths(-1); 
    cookie.Domain = FormsAuthentication.CookieDomain;
    cookie.Path = FormsAuthentication.FormsCookiePath;
    current.Response.Cookies.Add(cookie);
}

我有两个问题:

(1)在注销时,页面被重定向到所需的页面,但如果我通过后退按钮返回我的应用程序主页并单击各种链接,页面将导航到链接而不是要求用户登录。因此注销不成功。

(2)当用户使用单点登录在另一个应用程序上并且如果他从另一个应用程序注销时,用户仍然可以访问作为我们网站的父应用程序。因此单点退出不起作用

请你能告诉我这里缺少的东西。

1 个答案:

答案 0 :(得分:0)

你现在可能已经想到了这一点 - 但你必须使用的命令是:

CasAuthentication.SingleSignOut(); 

这将创建一个重定向到CAS服务器以进行服务器注销并删除本地身份验证协议

See also this SO answer