azure-authentication - 端点属于不同的权限

标签 azure-authentication identitymodel

尝试使用 Azure AD 作为 OpenID 提供程序 IdentityModel包裹

然而问题是它产生了错误的端点配置

var client = new HttpClient();

const string identityUrl = "https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/v2.0";
const string restUrl = "https://localhost:44321";

var disco = await client.GetDiscoveryDocumentAsync(identityUrl);
if (disco.IsError)
{
    Console.WriteLine(disco.Error); 
    return;
}

返回错误

Endpoint belongs to different authority: https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/oauth2/v2.0/authorize



openid-configuration输出是
{"authorization_endpoint":"https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/oauth2/v2.0/authorize",
"token_endpoint":"https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/oauth2/v2.0/token" ... }
oauth2在tenatID和版本之间添加。我想这就是 openid 元数据验证失败的原因。

是否可以将 AzureAD 配置为为 openid-configuration 返回正确的元数据?

问候

最佳答案

你能找到解决办法吗?我能找出的唯一方法(远不是最佳解决方案)是将端点添加到附加端点基地址列表中。否则,您必须按照上述评论中的说明将验证设置为 false。

var client = httpClientFactory.CreateClient();
       var disco = await client.GetDiscoveryDocumentAsync(
            new DiscoveryDocumentRequest
            {
                Address = "https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/v2.0",
                Policy =
                {
                    ValidateIssuerName = true,
                    ValidateEndpoints = true,
                    AdditionalEndpointBaseAddresses = { "https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/oauth2/v2.0/token",
                                                        "https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/oauth2/v2.0/authorize",
                                                        "https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/discovery/v2.0/keys",
                                                        "https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/oauth2/v2.0/devicecode",
                                                        "https://graph.microsoft.com/oidc/userinfo",
                                                        "https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/oauth2/v2.0/logout"
                                                      }
                },
            }
        );

关于azure-authentication - 端点属于不同的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56459997/

相关文章:

azure - 如何使用证书凭据获取 "x5t"的值进行应用程序身份验证

c# - 如何在本地测试 Azure Functions 身份验证

c# - 使用带有 IdentityModel 4.1.1 的刷新 token 请求访问 token

c# - IDX10503 : Signature validation failed. token 没有 child 。尝试的 key : 'System.Text.StringBuilder'

azure - 不支持关键字 : 'authentication' error for azure integrated connection

Azure 身份验证 token - AADSTS500113 : No reply address is registered for the application

Azure kubernetes - 如何使用 Azure API 管理来验证 kubernetes API?