- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在关注 this tutorial但它没有告诉您如何注销。我试过了
Request.GetOwinContext().Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ExternalCookie);
Request.GetOwinContext().Authentication.SignOut()
Request.GetOwinContext().Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie);
您可以在此处获取示例代码:https://github.com/AndersAbel/SocialLoginWithoutIdentity
只需要再添加一个 Action
public ActionResult SignOut()
{
Request.GetOwinContext().Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ExternalCookie);
return RedirectToAction("Index", "Home");
}
这个方法加上我上面贴的3行中的任意一行
我现在的结果是,我登录,我转到安全页面并可以看到它,然后我继续注销,然后在注销后尝试返回安全页面,我被允许返回该安全页面。
所以它实际上并没有真正让我退出。
最佳答案
如教程中所述,使用的中间件使用默认身份验证类型但不要覆盖它。
通过仅使用 externalCookie 作为 Owin 的参数,您将清除 Asp 的 cookie,但不是用于存储 Google 提供商的 cookie,
为此,您必须获取所有当前 cookie 的数组。可以像这样简单地完成:
Request.GetOwinContext()
.Authentication
.SignOut(HttpContext.GetOwinContext()
.Authentication.GetAuthenticationTypes()
.Select(o => o.AuthenticationType).ToArray());
这就是 Tutorial 上所说的地方:
The call to UseGoogleAuthentication should be quite obvious why it’s needed.
But the first one toSetDefaultSignInAsAuthenticationType is not asobvious.login middleware normally relies on the external cookie middlewareregistered before the social login middleware.external cookie middleware, it sets itself as the default signin type.That’s how the social login middleware knows that it should use theexternal cookie. In this setup there is no external cookie, so we haveto manually set the main cookie middleware as the default signin type.The cookie middleware will only issue a cookie if theAuthenticationType matches the one in the identity created by thesocial login middleware.Looking at the owin external authentication pipeline a socialIn the setup of the
关于c# - 如何注销 Owin 提供商?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38446789/
我在前几天的测验中遇到了以下问题。 Consider the code fragment (assumed to be in a program in which all variables are
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 9 年前。 Improve this qu
我刚开始接触 Objective-C,一般来说是 C,所以我想这也是一个 C 问题。它更像是一个为什么的问题,而不是一个如何做的问题问题。 我注意到,在除以两个整数时,小数部分向下舍入为 0,即使结果
我是一名优秀的程序员,十分优秀!