Azure authentication 端点属于不同的权限
正在尝试使用Azure AD作为包的OpenID提供程序 然而,问题是它产生了错误的端点配置Azure authentication 端点属于不同的权限,azure-authentication,identitymodel,Azure Authentication,Identitymodel,正在尝试使用Azure AD作为包的OpenID提供程序 然而,问题是它产生了错误的端点配置 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 = aw
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;
}
返回错误
端点属于不同的权限:
输出为
{"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配置返回正确的元数据
关于您能找到解决方案吗?我能找到的唯一方法(远不是最佳解决方案)是将端点添加到其他端点基址列表中。否则,您必须将验证设置为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"
}
},
}
);
我也遇到了同样的问题,当我将IdentityModel升级到2.16.1版时,问题得到了解决有专门的测试
DiscoveryPolicyTests。如果IdentityModel源代码中有白名单
,则端点不在授权之下必须被允许。看来这项检查是故意的。但是,可以使用policy.ValidateEndpoints=false关闭此功能。但是,我非常怀疑是否进行端点检查是一个好主意。好吧,这看起来不错——至少它可以正确地验证端点。但是,应进行其他配置更改,以在配置文件中存储备选端点路径