[英]IdentityServer4 and UserInfo endpoint customization
我创建了一个IdentityServer4应用程序,如果我在该应用程序内登录,用户声称这些应用程序都很好。 如果我从另一个客户端应用程序(MVC)登录,则UserInfo端点不会返回相同的声明。
IdentityServer配置了ASP.NET标识,因此UserProfile已配置为返回所有UserClaims,就像我创建的那样。
我不明白为什么它没有显示在同意视图上,或者它没有包含在UserInfo端点结果中
如果他们可以解决您的问题,请检查以下几点
1.)您的Identity资源和API资源应具有所需的UserClaims。
2.)检查是否有一些自定义逻辑在您的配置文件服务中为userinfo端点发出请求的声明。
public class ProfileService : IProfileService
{
public async Task GetProfileDataAsync(ProfileDataRequestContext context)
{
if (context.Caller == IdentityServerConstants.ProfileDataCallers.UserInfoEndpoint)
{
//custom logic to add requested claims
context.AddRequestedClaims(claims);
}
}
}
3.)尝试在MVC客户端AddOpenIdConnect配置中创建属性“GetClaimsFromUserInfoEndpoint = true”。
你配置了你的IdentityResources
吗? 就像是:
services.AddIdentityServer()
.AddInMemoryIdentityResources(GetIdentityResources())
//where
public static List<IdentityResource> GetIdentityResources()
{
// Claims automatically included in OpenId scope
var openIdScope = new IdentityResources.OpenId();
openIdScope.UserClaims.Add(JwtClaimTypes.Locale);
// Available scopes
return new List<IdentityResource>
{
openIdScope,
new IdentityResources.Profile(),
new IdentityResources.Email(),
new IdentityResource(Constants.RolesScopeType, Constants.RolesScopeType,
new List<string> {JwtClaimTypes.Role, Constants.TenantIdClaimType})
{
//when false (default), the user can deselect the scope on consent screen
Required = true
}
};
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.