加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-identity – AspNetCore – 使用Google身份验证时更改Co

发布时间:2020-12-16 06:34:06 所属栏目:asp.Net 来源:网络整理
导读:在ASP.NET 5,MVC 6中,我能够在选项中更改外部身份验证cookie的名称 – 但这似乎是从AspNetCore.Identity RC2库中的新提供程序中删除的. 我有这个设置; class Startup { ... public void ConfigureServices(IServiceCollection services){ services.AddIdenti
在ASP.NET 5,MVC 6中,我能够在选项中更改外部身份验证cookie的名称 – 但这似乎是从AspNetCore.Identity RC2库中的新提供程序中删除的.

我有这个设置;

class Startup {
   ...
   public void ConfigureServices(IServiceCollection services){
      services.AddIdentity<Member,Role> ... // identity wired up
   }

   public void Configure(IApplicationBuilder app,ILoggerFactory logger) {
      // .. other wiring
    app
        .UseIdentity()
        .UseGoogleAuthentication
        (new GoogleOptions {
            ClientId = Constants.Google.Client,ClientSecret = Constants.Google.Secret,Scope = {"email","profile"}
        });

    app.UseMvc(routes => {
        routes.MapRoute(
            name: "default",template: "{controller=Home}/{action=Index}/{id?}");
         });
    }
}

曾经有一个AuthenticationType属性我可以设置为字符串,它将控制cookie名称;但那已经消失了.

我读了其他帖子,说尝试SignInScheme和AuthenticationScheme – 我做了,但那会开始给我一个错误,没有提供商来处理这个方案.

有什么我可以做的吗?

解决方法

以下是如何替换用于外部cookie的默认名称.

services.AddIdentity<Member,Role>(options =>
{
    options.Cookies.ExternalCookie.CookieName = "name";
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读