我正在使用IdentityServer v4,使用资源所有者流来处理ASP.NET应用程序的授权。
我已经实现了IdentityServer4.Core.Services.IProfileService
接口,它有两种方法,GetProfileDataAsync
和IsActiveAsync
。
当向令牌端点发出请求时,会按预期调用GetProfileDataAsync
。我们使用这种方法来提出索赔。
但是,不会调用IsActiveAsync
方法。我想实现这个方法来确定用户在我们的数据库中是否处于活动状态。这个方法应该在什么时候调用?
IdentityServer源中的注释(见下文)建议在令牌发布期间调用该方法,但在请求令牌时不会调用该方法。我怀疑我错过了什么。如有任何帮助,我们将不胜感激。
// Summary:
// This method gets called whenever identity server needs to determine
// if the user is valid or active (e.g. if the user's account has been
// deactivated since they logged in). (e.g. during token issuance or
// validation).
Task IsActiveAsync(IsActiveContext context);
现在IsActiveAsync
不会被资源所有者密码请求调用。我想假设的是,如果用户处于非活动状态,您将无法成功验证该用户。
这些细节还没有决定——如果你对如何运作有强烈的意见——请在github上打开一个问题。我们将在八月底封锁API。