我正在使用带有自定义STS的Windows Azure访问控制服务.我可以通过ACS登录我的应用程序,但是我在登出功能方面遇到了麻烦.我在我的应用程序中尝试过这段代码.
WSFederationAuthenticationModule fam = FederatedAuthentication.WSFederationAuthenticationModule;
try
{
FormsAuthentication.SignOut();
}
finally
{
fam.SignOut(true);
}
Page.Response.Redirect("default.aspx");
Run Code Online (Sandbox Code Playgroud)
但似乎它从ACS注销用户而不是从自定义STS注销.从STS注销我该怎么办?应用(RP),ACS或STS中的问题可能出在哪里?
我认为ACS应该要求自定义STS注销用户,但似乎它没有这样做.我错过了什么?
我已经为FederatedSignout创建了一个帮助方法,在代码中注释了我在路上发现的内容(hth)
public static void FederatedSignOut(string reply = null)
{
WSFederationAuthenticationModule fam = FederatedAuthentication.WSFederationAuthenticationModule;
// Native FederatedSignOut doesn't seem to have a way for finding/registering realm for singout, get it from the FAM
string wrealm = string.Format("wtrealm={0}", fam.Realm);
// Create basic url for signout (wreply is set by native FederatedSignOut)
string signOutUrl = WSFederationAuthenticationModule.GetFederationPassiveSignOutUrl(fam.Issuer, null, wrealm);
// Check where to return, if not set ACS will use Reply address configured for the RP
string wreply = !string.IsNullOrEmpty(reply) ? reply : (!string.IsNullOrEmpty(fam.Reply) ? fam.Reply : null);
WSFederationAuthenticationModule.FederatedSignOut(new Uri(signOutUrl), !string.IsNullOrEmpty(wreply) ? new Uri(wreply) : null);
// Remarks! Native FederatedSignout has an option for setting signOutUrl to null, even if the documentation tells otherwise.
// If set to null the method will search for signoutUrl in Session token, but I couldn't find any information about how to set this. Found some Sharepoint code that use this
// Michele Leroux Bustamante had a code example (from 2010) that also uses this form.
// Other examples creates the signout url manually and calls redirect.
// FAM has support for wsignoutcleanup1.0 right out of the box, there is no need for code to handle this.
// That makes it even harder to understand why there are no complete FederatedSignOut method in FAM
// When using native FederatedSignOut() no events for signout will be called, if you need this use the FAM SignOut methods instead.
}
Run Code Online (Sandbox Code Playgroud)
此代码用于我们为带有ACS的Web SSO创建的标准RP库中.
| 归档时间: |
|
| 查看次数: |
3937 次 |
| 最近记录: |