First, implement the IProfileService interface and make an implementation class for expanding information.
/// <summary>
/// IDS4获取用户信息服务实现
/// </summary>
public class YourProfileService : IProfileService
{
public YourProfileService ()
{
}
public async Task GetProfileDataAsync(ProfileDataRequestContext context)
{
var claims = context.Subject.Claims.ToList();
// xxx (你的业务逻辑,一般用来获取claim值,然后通过下面代码添加到claim数组里)
claims.Add(new System.Security.Claims.Claim("拓展claim名称", "拓展claim值"));
context.IssuedClaims = claims.ToList();
}
public async Task IsActiveAsync(IsActiveContext context)
{
await Task.Run(() =>
{
context.IsActive = true;
});
}
}
Then, configure it in DomainModule, as follows:
public class XXXDomainModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
// xxx
context.Services.AddTransient<IProfileService, YourProfileService>();
PreConfigure<IdentityServerBuilder>(builder =>
{
builder.AddProfileService<YourProfileService>();
});
}
}