【问题标题】:How can I get OpenIdConnectAuthenticationMiddleware to validate the signing certificate validity dates?如何让 OpenIdConnectAuthenticationMiddleware 验证签名证书的有效期?
【发布时间】:2016-05-18 21:30:09
【问题描述】:

我在混合流程中针对 IdentityServer3 使用 Microsoft 的 OpenIdConnectAuthenticationMiddleware。我将跳过 IdentityServer3 设置代码(因为我认为那里没有问题),但这是依赖方启动代码:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = "Cookies"
});

var options = new OpenIdConnectAuthenticationOptions
{
    Authority = "https://localhost:44300/",
    ClientId = "hybridclient",
    ClientSecret = "secret",
    RedirectUri = "https://localhost:44301/",
    ResponseType = "code id_token",
    SignInAsAuthenticationType = "Cookies",
    Scope = "openid profile"
};

app.UseOpenIdConnectAuthentication(options);

我注意到,当 IdentityServer3 使用过期证书进行签名时——它允许,但尽职尽责地记录为警告——证书上的过期被忽略并允许身份验证。这似乎是错误的。

我不知道这是谁的责任(OpenIdConnectAuthenticationMiddleware?ADAL?)因为在我看来,当签名证书过期时,身份验证很容易失败。我一直查看代码,从 Katana 一直到 ADAL 中的 JwtSecurityTokenHandler,但看不到已检查过期。

我可以在TokenValidationParameters.IssuerSigningKeyResolverOpenIdConnectAuthenticationNotifications 上的SecurityTokenValidated 通知中自己滚动一些东西,但这似乎应该是内置的。

有没有办法让 Microsoft OIDC 中间件验证签名证书过期?还是我错过了什么?

更新:鉴于 Brent 的回答,这显然是 gap in the functionality of JwtSecurityTokenHandler that Microsoft would like to fill。我只能说我目前看到了这个,安装了 v4.0.0(因为它是 Microsoft.Owin.Security.OpenIdConnect NuGet 包的依赖项)。

【问题讨论】:

    标签: openid-connect katana adal identityserver3


    【解决方案1】:

    您需要从 JwtSecurityTokenHandler 派生,覆盖 ValidateIssuerSecurityKey 并检查签名。 OpenIdConnectOptions.SecurityTokenHandlers 可用于设置处理程序。

    修复后,这将更容易。 https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/329

    【讨论】:

    • 我想到了类似的东西。感谢您的确认!我将更新我的问题以突出显示适用的特定版本。
    猜你喜欢
    • 2015-11-01
    • 2012-09-08
    • 1970-01-01
    • 1970-01-01
    • 2014-03-16
    • 2011-12-03
    • 1970-01-01
    • 2021-01-09
    • 2015-03-03
    相关资源
    最近更新 更多