剑轩

identityServer4携带自定义的Claim

电脑版发表于:2019/12/21 12:23


identityServer4要携带自定义的Claim,仅仅传递Claim是不行的

还需要实现IProfileService方法才行

public class ImplicitProfileService : IProfileService
{
    public Task GetProfileDataAsync(ProfileDataRequestContext context)
    {
        //获取IdentityServer给我们定义的Cliams和我们在SignAsync添加的Claims
        var claims = context.Subject.Claims.ToList();

        context.IssuedClaims = claims;

        return Task.CompletedTask;
    }
    public Task IsActiveAsync(IsActiveContext context)
    {
        context.IsActive = true;
        return Task.CompletedTask;
    }
}

在ConfigureServices去添加自定义的IProfileService



关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢