gpt4 book ai didi

c# - 'sub' 是 openid 范围还是配置文件范围的一部分?

转载 作者:行者123 更新时间:2023-12-04 06:48:04 26 4
gpt4 key购买 nike

根据 OpenID Connect specificationsub claim 部分 openid范围或 profile范围?我找不到那个信息

更新 1
我正在使用 IdentityServer3 进行身份验证。客户端向服务器发出请求,如下所示。作为回应,我没有收到 sub根据 Open ID Connect 规范要求的声明。但是响应确实包括 http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifiersub 具有相同的值是nameidentifiersub宣称。

这是客户请求

    public void Configuration(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = "https://localhost:44314/identity",
Scope = "openid",
ClientId = "LocalHostMvcClient",
RedirectUri = "http://localhost:34937/",
ResponseType = "id_token",
SignInAsAuthenticationType = "Cookies",
}
}

id_token 响应

enter image description here

更新 2
根据下面的评论,我更新了客户端的启动文件
    private void TurnOffMicrosoftJWTMapping()
{
//The long claim names come from Microsoft’s JWT handler trying to map some claim types to .NET’s ClaimTypes class types.
//We can turn off this behavior with the following line of code (in Startup).
//This also means that we need to adjust the configuration for anti-CSRF protection to the new unique sub claim type:
AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Subject;
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
}

然后在客户端启动时调用这个方法
public class Startup
{
public void Configuration(IAppBuilder app)
{
TurnOffMicrosoftJWTMapping();

//configure OpenIDConnect request here
}
}

最佳答案

sub 是 id_token 的必需声明 - openid 范围是发出 OpenID Connect 身份验证请求所需的最小范围。您可以将 openid 与其他范围混合使用 - 但必须存在 openid。

这就是他们的关系。

IdentityServer 根据以下内容发出标准声明类型(例如 sub):

https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims

正是 Microsoft JWT 处理程序将这些标准声明转换为 Microsoft 专有声明。您可以通过以下方式关闭这种烦人的行为:
JwtSecurityTokenHandler.InboundClaimTypeMap.Clear()

关于c# - 'sub' 是 openid 范围还是配置文件范围的一部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38510592/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com