首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IdentityServer4添加IdentityClaim

IdentityServer4添加IdentityClaim
EN

Stack Overflow用户
提问于 2019-03-17 05:06:43
回答 1查看 170关注 0票数 0

在config.cs的IdentityServer4示例中,您有添加Client, IdentityResources, etc的代码,我想知道如何添加IdentityClaims。因为只有find选项才能添加客户端、IdentityResources、ApiResources。谁能给我指个正确的方向。谢谢

EN

回答 1

Stack Overflow用户

发布于 2019-03-18 01:22:35

如果我理解正确的话,那么您可能正在寻找一个新的IdentityResource来封装您的用户可能具有的某种自定义身份声明类型。下面是一个这样的例子:

代码语言:javascript
复制
return new List<IdentityResource>
{
    //..Your other configured identity resources

    new IdentityResource(
    name: "custom.name",
    displayName: "Custom Name",
    claimTypes: new[] { "custom.name" });
};

然后,您可以将其添加为用户声明:

代码语言:javascript
复制
        new TestUser
        {
            SubjectId = "1",
            Username = "alice",
            Password = "password",

            Claims = new []
            {
                new Claim("custom.name", "SomeCustomNameValue")
            }
        },
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55201487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档