【发布时间】:2015-07-09 22:34:13
【问题描述】:
我的 Azure Active Directory 应用程序 URI 包含一个星号,类似于 https://*.mywebapp.com"。
AAD 可以成功获取此应用的 https://test.mywebapp.com 资源的令牌。
在服务端,我使用 OWIN 和 WindowsAzureActiveDirectoryBearerAuthenticationOptions 来验证令牌。
问题是不支持用星号指定受众。
使用以下代码,令牌验证会为受众 https://test.mywebapp.com 的令牌返回 false
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Tenant = c_azureActiveDirectoryTenant,
TokenValidationParameters = new TokenValidationParameters
{
ValidAudiences = new[] { "https://*.mywebapp.com" },
SaveSigninToken = true,
},
});
查看 GitHub 上的 AudienceValidator 和 IssuerValidator 代码,我很容易理解原因——代码比较了精确的字符串。我希望代码尊重通配符,这是设计使然还是只是一个错误?有什么解决方法吗?
【问题讨论】: