![](/img/trans.png)
[英]OpenIddict Asp.net Core 5.0 How to Get Principal Associated in Refresh Token Flow
[英]OpenIddict Refresh Token Flow issue ASP.NET Core
我正在嘗試將刷新令牌的生存時間設置為2周。 我已經嘗試通過.. FromSeconds,FromMinutes,FromHours,但是它始終將刷新令牌設置為與訪問令牌相同的生存期。 我將不勝感激任何幫助。 這是我當前在configureServices中擁有的:
services.AddOpenIddict(options =>
{
// Register the Entity Framework stores.
options.AddEntityFrameworkCoreStores<AppDbContext>();
// Register the ASP.NET Core MVC binder used by OpenIddict.
// Note: if you don't call this method, you won't be able to
// bind OpenIdConnectRequest or OpenIdConnectResponse parameters.
options.AddMvcBinders();
// Enable the token endpoint.
options.EnableTokenEndpoint("/connect/token");
// Enable the password flow.
options.AllowPasswordFlow()
.AllowRefreshTokenFlow()
.SetAccessTokenLifetime(TimeSpan.FromMinutes(1))
.SetRefreshTokenLifetime(TimeSpan.FromMinutes(20160));
// During development, you can disable the HTTPS requirement.
options.DisableHttpsRequirement();
});
請注意:以下帖子無法解決問題: http : //kosmisch.net/Blog/DotNetEssential/Archive/2017/9/11/openiddict-refresh-token-flow-issue-aspnet-core-20.html
關於該問題的最新摘要:使用用戶名和密碼登錄時,以下數據插入到openiddicttoken表中:
Id ApplicationId AuthorizationId Ciphertext End Hash Start Status Subject Type
1 NULL NULL NULL 2017-10-12 11:24:26.0000000 +00:00 NULL 2017-09-12 11:24:26.0000000 +00:00有效1 refresh_token
然后完成了refresh_token授予類型請求。 上面的記錄已更新,唯一的更改是“狀態”列,該列已從“ 有效”更改為“已兌換”
Id ApplicationId AuthorizationId Ciphertext End Hash Start Status Subject Type
1 NULL NULL NULL 2017-10-12 11:24:26.0000000 +00:00 NULL 2017-09-12 11:24:26.0000000 +00:00兌換1 refresh_token
並且響應JSON不包含新的刷新令牌屬性。
我認為對於第二次刷新,我認為自從配置為使用滑動到期后,“開始”或“結束”列中的至少一個應該更改。
但事實並非如此。 因此,我認為這種刷新令牌方法可能存在一個問題。 你能看看嗎?
在示例中: https : //github.com/openiddict/openiddict-samples/tree/dev/samples/RefreshFlow
我下載了文件,每次刷新后都可以看到,將插入一個新令牌,這與我的行為有很大不同。 順便說一句,我也更改了示例代碼以也使用幻燈片過期。
主要區別是我的模型使用int作為TKey,而示例使用GUID。 所以我想知道這是否與此有關?
options.UseOpenIddict<int>();
找出造成我問題的根本原因:
// Create a new authentication ticket holding the user identity.
var ticket = new AuthenticationTicket(principal, *new AuthenticationProperties(),* OpenIdConnectServerDefaults.AuthenticationScheme);
雖然應該是:
// Create a new authentication ticket holding the user identity.
var ticket = new AuthenticationTicket(principal, properties, OpenIdConnectServerDefaults.AuthenticationScheme);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.