我在.net 4.5中創建了一個MVC 4應用程序,並安裝了Identity and Access工具,以便可以創建聲明感知應用程序。我對應用程序進行了配置,以便它使用2012年推出的新LocalSTS,因此它不會創建與2010年相同的STS網站。2012年聲明感知MVC應用程序 - 註銷
如何在我的應用程序中支持註銷場景?有沒有像FormsAuthentication.SignOut
這樣的方法?
我在.net 4.5中創建了一個MVC 4應用程序,並安裝了Identity and Access工具,以便可以創建聲明感知應用程序。我對應用程序進行了配置,以便它使用2012年推出的新LocalSTS,因此它不會創建與2010年相同的STS網站。2012年聲明感知MVC應用程序 - 註銷
如何在我的應用程序中支持註銷場景?有沒有像FormsAuthentication.SignOut
這樣的方法?
這真的很容易,只是呼籲WSFederationAuthenticationModule的SignOut方法:
FederatedAuthentication.WSFederationAuthenticationModule.SignOut("/MyPostSignoutRedirectUrl");
要處理簽出請求,請執行以下步驟:
點擊點登錄後out鏈接,清除聯合cookie: System.Web.HttpContext.Current.Response.Cookies.Remove(stateKey);
將瀏覽器重定向到模擬發行者與WS聯盟簽出參數作爲動作:
https://RelyingParty/SsoLogout.aspx?wa=wsignout1.0&wreply=...
WS聯盟命令-WA = wsignout1.0用於 到退出發行人。
https://RelyingParty1/SsoLogout.aspx?wa=wsignoutcleanup1.0,
https://RelyingParty2/SsoLogout.aspx?wa= wsignoutcleanup1.0,
https://RelyingParty3/SsoLogout.aspx?wa= wsignoutcleanup1.0
這允許所有的依靠各方執行註銷操作。
它的工作原理如下:
佤GET參數 定義的wsignout1.0和wsignoutcleanup1.0行動深受信賴方秉承WS聯合被動請求 檔案的理解。這些操作允許來自領域中所有RP的註銷操作。
如何更改爲持久性cookie並註銷點擊或會話結束期滿fedauth cookie?在RP
永久性Cookies:
<microsoft.identityModel>
<federatedAuthentication>
<wsFederation
persistentCookiesOnPassiveRedirects="true" />
<cookieHandler
persistentSessionLifetime="60.0:0:0" />
</federatedAuthentication>
</microsoft.identityModel>
而且過期餅乾
var c = Request.Cookies["FedAuth"];
c.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(c);
c = Request.Cookies["FedAuth1"];
c.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(c);
您需要在此之後重定向。