【问题标题】:Debian: No authentication handler is configured to handle the scheme: AutomaticDebian:没有配置身份验证处理程序来处理该方案:自动
【发布时间】:2017-06-06 21:32:51
【问题描述】:

我有一些像this 这样的问题,但我不明白如何为 Debian 解决它。

首先,我如下所述配置我的应用程序

app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme =MyAuthSchemeName,
                CookieName = MyCookiName,
                AutomaticAuthenticate = true,
                AutomaticChallenge = false,
                SlidingExpiration = true,
                ExpireTimeSpan = TimeSpan.FromDays(1),
                DataProtectionProvider = DataProtectionProvider.Create(MyApplicationName)
            });

app.UseJwtBearerAuthentication(new JwtBearerOptions
            { 
                AutomaticChallenge = false,
                AutomaticAuthenticate = true,
                Authority = IdentityServerConnectionString,
                RequireHttpsMetadata = false,
                BackchannelHttpHandler = new HttpClientHandler().ServerCertificateCustomValidationCallback = (request, cert, chain, errors) => true,
                TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateAudience = false,
                    ValidateIssuer = false,
                }
            });

app.UseMvc();

对于 Windows,它可以完美运行(我使用 Host 来启动此代码,而不是 IIS!),但对于 Debian,它会失败。 有什么想法吗?

UPD: 我在日志中看到下一条消息:Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware MyAuthSchemeName 未通过身份验证。失败消息:取消保护票证失败

【问题讨论】:

    标签: .net asp.net-core debian asp.net-core-mvc .net-core


    【解决方案1】:

    我找到了解决这个问题的方法。 关键原因是 DataProtectionProvider 的设置。 对于 Debian,需要使用下面的代码

    Startup.cs:

    public void ConfigureServices(IServiceCollection services)
        {
          services.AddDataProtection().SetApplicationName(ApplicationName).
                   PersistKeysToFileSystem(
                        new DirectoryInfo(Configuration["/some_path_to_folder_for_keys"]))
        }
    

    并且应该删除 cookie 的 dataprovider 初始化(来自 UseCookieAuthentication());

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      相关资源
      最近更新 更多