【发布时间】:2019-06-05 11:54:24
【问题描述】:
尝试使用 Azure AD 作为带有 IdentityModel 包的 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 = await client.GetDiscoveryDocumentAsync(identityUrl);
if (disco.IsError)
{
Console.WriteLine(disco.Error);
return;
}
返回错误
端点属于不同的权限: https://login.microsoftonline.com/00edae13-e792-4bc1-92ef-92a02ec1d939/oauth2/v2.0/authorize
{"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 返回正确的元数据?
问候
【问题讨论】:
-
IdentityModel 源代码中有专门的测试
DiscoveryPolicyTests.Endpoints_not_beneath_authority_must_be_allowed_if_whitelisted。似乎这个检查是有目的的。但是,可以使用policy.ValidateEndpoints = false将其关闭。但我非常怀疑转向端点检查是个好主意。
标签: azure-authentication identitymodel