Thinktecture Implicit Flow:注销/注销用户

时间:2013-06-26 21:47:20

标签: thinktecture-ident-server thinktecture-ident-model

我按照这个例子来隐式流程工作。

http://weblogs.thinktecture.com/cweyer/2012/11/oauth2-in-thinktecture-identityserver-v2-implicit-grant-flow-with-javascript.html

我的问题是,我该如何注销用户?我希望那里有人知道,因为我找不到任何例子。现在我可以触发授权窗口并正确处理它并为我的请求使用访问令牌,但我不知道如何制作它以便我可以切换用户。

1 个答案:

答案 0 :(得分:0)

要注销,您必须使用注销方法创建自定义控制器。

public void Logout()
{
   // You should be able to revoke thinktecture token like this. (haven't tested this out)
   var sam = FederatedAuthentication.SessionAuthenticationModule;  
   sam.SignOut();

   // Or you should be able to logoff like this when using a membership provider. (this way works for me)
   //_yourMembership.Logout();
   Thread.CurrentPrincipal = null;
   HttpContext.Current.User = null;
}

以下是令牌撤销的示例: https://github.com/brockallen/BrockAllen.MembershipReboot/blob/master/src/BrockAllen.MembershipReboot/Authentication/SamAuthenticationService.cs