【问题标题】:Enabling both Cookie authentication and ASP.NET Identity authentication in an MVC project在 MVC 项目中同时启用 Cookie 身份验证和 ASP.NET Identity 身份验证
【发布时间】:2018-03-10 13:52:43
【问题描述】:

我有一个 MVC 站点,其中包含使用 cookie 身份验证的 MVC 控制器和 WebApi 控制器。但是,我希望某些 WebApi 控制器使用 Identity 3 服务器进行身份验证。我检查了这个答案,但属性 AuthenticationScheme 不可用可能是因为我使用的是 Identity 3(或者它可能是我当前未使用的 .NET 核心的一部分)。

How do I issue the corresponding Bearer and Cookie identity in ASP.NET with multiple Authorization schemes?

我如何告诉一些 WebApi 控制器对 Identity 3 服务器进行身份验证?

【问题讨论】:

    标签: asp.net-mvc asp.net-web-api asp.net-identity-3


    【解决方案1】:

    想通了,这可以使用方法 app.Map 并在其中指示路径和身份验证方法。类似的东西

            app.Map("/mobile", idsrvApp =>
            {
                idsrvApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
                {
                   ...
                });
            });
    
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
             ...
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-30
      • 2018-05-10
      • 2018-12-30
      • 1970-01-01
      • 2011-08-19
      • 2017-12-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多