我正在使用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);
答案 0 :(得分:3)
现在没有为资源所有者密码请求调用IsActiveAsync
。我猜这个假设是,如果用户处于非活动状态,您将无法成功验证用户身份。
这些细节尚未确定 - 如果您对如何运作有强烈意见 - 请在github上打开一个问题。我们将在8月底锁定API。