Sig*_*hol 14 asp.net asp.net-core identityserver4
使用IdentityModel执行GET时,我得到以下错误DiscoveryClient,如下所示:
var discoveryResponse = await DiscoveryClient.GetAsync("https://localhost/IdentityServer");
Run Code Online (Sandbox Code Playgroud)
颁发者名称与权限不匹配:https:// localhost/identityserver
目标URL是在使用IdentityServer4启用的IIS上运行的ASP.NET Core Web应用程序.客户端应用程序是在同一台计算机上运行的经典ASP.NET Web应用程序.
显然,GET确实设法从IdentityServer检索值,如以下内容所示discoveryResponse.Raw:
{
"issuer": "https://localhost/identityserver",
"jwks_uri": "https://localhost/IdentityServer/.well-known/openid-configuration/jwks",
"authorization_endpoint": "https://localhost/IdentityServer/connect/authorize",
"token_endpoint": "https://localhost/IdentityServer/connect/token",
"userinfo_endpoint": "https://localhost/IdentityServer/connect/userinfo",
"end_session_endpoint": "https://localhost/IdentityServer/connect/endsession",
"check_session_iframe": "https://localhost/IdentityServer/connect/checksession",
"revocation_endpoint": "https://localhost/IdentityServer/connect/revocation",
"introspection_endpoint": "https://localhost/IdentityServer/connect/introspect",
"frontchannel_logout_supported": true,
"frontchannel_logout_session_supported": true,
"scopes_supported": [ "CustomIdentityResources", "profile", "openid", "MyAPI.full_access", "offline_access" ],
"claims_supported": [],
"grant_types_supported": [ "authorization_code", "client_credentials", "refresh_token", "implicit" ],
"response_types_supported": [ "code", "token", "id_token", "id_token token", "code id_token", "code token", "code id_token token" ],
"response_modes_supported": [ "form_post", "query", "fragment" ],
"token_endpoint_auth_methods_supported": [ "client_secret_basic", "client_secret_post" ],
"subject_types_supported": [ "public" ],
"id_token_signing_alg_values_supported": [ "RS256" ],
"code_challenge_methods_supported": [ "plain", "S256" ]
}
Run Code Online (Sandbox Code Playgroud)
lea*_*ege 17
authority:https:// localhost/IdentityServer issuer:https:// localhost/identityserver
它们不匹配 - 它区分大小写.
And*_*erd 11
如果您无法更改服务器代码以适应策略,您可以更改策略设置以允许名称不匹配。
例如,我试图用DiscoveryClient对Azure的REST API,而且issuer是https://sts.windows.net/{{ tenant_id }}同时端点的所有下手https://login.microsoft.com/{{ tenant_id }}。
只需将字段ValidateIssuerName和设置ValidateEndpoints为 false。
var tenant_id = "8481D2AC-893F-4454-8A3B-A0297D301278"; // Made up for this example
var authority = $"https://login.microsoftonline.com/{tenant_id}";
DiscoveryClient discoveryClient = new DiscoveryClient(authority);
// Accept the configuration even if the issuer and endpoints don't match
discoveryClient.Policy.ValidateIssuerName = false;
discoveryClient.Policy.ValidateEndpoints = false;
var discoResponse = await discoveryClient.GetAsync();
Run Code Online (Sandbox Code Playgroud)
自从发布此消息以来,DiscoveryClient该类已被弃用。
这是新的调用语法:
var client = new HttpClient();
var discoResponse = await client.GetDiscoveryDocumentAsync(
new DiscoveryDocumentRequest
{
Address = authority,
Policy =
{
ValidateIssuerName = false,
ValidateEndpoints = false,
},
}
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5938 次 |
| 最近记录: |