【发布时间】:2020-05-22 10:32:48
【问题描述】:
我有一个ASP NET Core 3.0 应用程序,我正在使用Azure Active Directory 进行身份验证。参见下面的autentication配置
services.AddAuthentication(options =>
{
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddOpenIdConnect(options =>
{
options.Authority = auth.Authority;
options.ResponseType = OpenIdConnectResponseType.IdToken;
options.SignedOutRedirectUri = auth.SignedOutRedirectUri;
options.CallbackPath = auth.CallbackPath;
options.ClientId = auth.ClientId;
})
.AddCookie(options =>
{
options.AccessDeniedPath = "/Home/AccessDenied/";
options.ExpireTimeSpan = TimeSpan.FromMinutes(20);
});
当我在 20 分钟不活动后更改页面时,cookie 会自动重新生成,但如果我调用 API Controller,则不会发生这种情况。当我进行AJAX 调用并且令牌已过期时,我该怎么做才能自动刷新令牌?我是否忘记在配置中添加一些东西?
【问题讨论】:
标签: api asp.net-core cookies token openid-connect