如何配置 OpenIddict 以在访问令牌中包含“iat”声明?

问题描述 投票:0回答:1

我在 .NET Framework 4.8 应用程序中使用 AspNet.Security.OpenIdConnect.Server (OpenIddict)。

这是中间件选项:

app.UseOpenIdConnectServer(options =>
{
    options.Issuer = new Uri(Config.IssuerUrl);
    options.AllowInsecureHttp = false;
    options.ApplicationCanDisplayErrors = true;
    options.TokenEndpointPath = new PathString(Paths.TokenPath);
    options.AuthorizationEndpointPath = new PathString(Paths.AuthorizePath);
    options.UserinfoEndpointPath = new PathString(Paths.UserInfoPath);
    options.LogoutEndpointPath = new PathString(Paths.LogoutPath);
    options.SigningCredentials.AddCertificate(certificate);
    options.Provider = new OpenIdConnectServerProvider();
    options.AccessTokenHandler = new JwtSecurityTokenHandler();
    options.AccessTokenLifetime = TimeSpan.FromMinutes(60);
    options.UseSlidingExpiration = true;
});

生成的访问令牌不包含“iat”(发布于)声明。我如何配置中间件以包含此声明?

或者我是否需要在请求令牌的客户端上以某种方式设置它? 一个客户端应用程序是使用 Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationMiddleware 的 ASP.NET MVC 应用程序。

谢谢你。

asp.net-web-api openid-connect openiddict
1个回答
0
投票

AspNet.Security.OpenIdConnect.Server
不是 OpenIddict:它在 OpenIddict 1.x 和 2.x 中用作 OpenIddict 的低级堆栈,但该项目作为 3.x 工作的一部分合并到 OpenIddict 中,并在不久前被废弃。

最新版本的 OpenIddict 会自动在 JWT 访问令牌中为您添加

iat
声明。

© www.soinside.com 2019 - 2024. All rights reserved.