Azure AD 应用程序注册将重定向 URI 限制为 256

标签 azure asp.net-core multi-tenant azure-authentication

是否可以通过单个 Azure AD 应用程序注册为多个租户和多个 Web 应用程序使用单个重定向 URI?

我的 Azure Multi-Tenancy 应用程序注册已达到 256 个 URI 的限制,其中每个注册租户都有自己的一组重定向 URI。

重定向 URI 遵循此模式

阅读后Use a state parameter我的想法是创建一个新的 Web 应用程序,该应用程序仅进行身份验证,然后将用户重定向到最初请求的 URI。但无法将 OpenId CallbackPath 配置到新的 auth/authorize/redirect 应用程序。

我该如何解决这个问题?

ASP.NET Core
authenticationBuilder.Services.AddSingleton<IConfigureOptions<OpenIdConnectOptions>, ConfigureAzureOptions>();
authenticationBuilder.AddOpenIdConnect();

private class ConfigureAzureOptions : IConfigureNamedOptions<OpenIdConnectOptions>
{
   public void Configure( string name, OpenIdConnectOptions options )
   {
      options.ClientId     = "555-xxx";
      options.Authority    = "https://login.microsoftonline.com/common";
      options.CallbackPath = "https://mydomain/myauth-redir-app/signin-iodc" // this is not allowed
      options.Events       = new OpenIdConnectEvents
      {
         OnRedirectToIdentityProvider = ctx => 
         {
             // remember the URL the user requested, to be picked upp later after AAD auth
             ctx.ProtocolMessage.SetParameter("state", "set_org_url"); 
         }
         OnTokenValidated = ctx =>
         {
            // this code should run in myauth-redir-app and pick up the state 
            // and redirect the user to the originally requested URL
            var stateValue = ctx.ProtocolMessage.GetParameter("state");
         }
      }
   }
}

被拒绝的解决方案

  1. 不再支持在 URI 中使用通配符
  2. 为每个 Web 应用程序创建应用程序注册仍然将我的租户限制为 256 个,这太少了。
  3. 为每个租户创建新的应用注册对于维护和配置来说太麻烦了。
  4. 我不想在租户服务主体中注册重定向 URI,我必须能够添加和删除 URI,而无需客户采取任何操作。

最佳答案

通过在 Azure 中应用程序注册的身份验证 Pane 中找到支持的帐户类型开关,您的注册是否可以实现 Multi-Tenancy 门户并将其设置为任何组织目录中的帐户

对于 Multi-Tenancy 应用程序,您只需要一个重定向网址(原始网址)。对于 Multi-Tenancy 应用程序,应用程序的初始注册位于开发人员使用的 Azure AD 租户中。当来自不同租户的用户首次登录应用程序时,Azure AD 会要求他们同意应用程序请求的权限。如果他们同意,则会在用户的租户中创建称为服务主体的应用程序表示,并且可以继续登录。还会在记录用户对应用程序的同意的目录中创建委托(delegate)。

参见文档:https://learn.microsoft.com/en-us/azure/active-directory/develop/howto-convert-app-to-be-multi-tenant#update-registration-to-be-multi-tenant

关于Azure AD 应用程序注册将重定向 URI 限制为 256,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58804421/

相关文章:

azure - 暂时增加 Azure 数据资源管理器中 .set 引入查询的限制

c# - 为什么 BrokeredMessage.RenewLock() 只更新几秒钟的锁?

c# - 转换 ASP.Net Core 中的 Open Id Connect 声明

c# - ASP.NET Core 服务范围工厂未定义行为

java - Grails3 单元测试不适用于 Multi-Tenancy

azure - 从浏览器应用程序联系我的 ASP.NET Core 3.1 API 时,无法在访问 token 中看到角色声明

node.js - Azure 未使用正确版本的 Node

asp.net - WindowsIdentity.RunImpersonated 导致 ASP.NET Core 3.1 上的 System.Net.Http.HttpRequestException

node.js - 使用 nodejs sequelize 的 Multi-Tenancy (SAAS)

php - 使用 Behat/Mink 和 Behat Laravel Extension 测试 Multi-Tenancy Laravel 应用程序