【问题标题】:How can I get WindowsAzureActiveDirectoryBearerAuthenticationOptions to accept an audience with an asterisk如何让 WindowsAzureActiveDirectoryBearerAuthenticationOptions 接受带有星号的受众
【发布时间】: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 上的 AudienceValidatorIssuerValidator 代码,我很容易理解原因——代码比较了精确的字符串。我希望代码尊重通配符,这是设计使然还是只是一个错误?有什么解决方法吗?

【问题讨论】:

    标签: c# owin katana adal


    【解决方案1】:

    您可以通过设置 TokenValidationParameters.AudienceValidator 委托来控制 AudienceValidation。然后,您可以做任何您需要做的事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-28
      • 1970-01-01
      • 2017-10-16
      相关资源
      最近更新 更多