【问题标题】:How to restrict access of Azure App Service to only users added in user and group setting in Azure Ad?如何将 Azure App Service 的访问权限限制为仅在 Azure Ad 中的用户和组设置中添加的用户?
【发布时间】:2020-01-14 17:12:32
【问题描述】:

我的 Angular .net core 2.0 应用程序使用 oauth2.0 身份验证,我在 startup.cs 中配置了相同的。 PFB代码

   services.AddAuthentication(options =>
            {
                options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
                options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            })
            .AddCookie()

            .AddOpenIdConnect(options =>
            {
                options.ClientId = azureAdConfig.ClientId;
                options.ClientSecret = azureAdConfig.ClientSecret;
                options.Authority = string.Format(azureAdConfig.AADInstance, azureAdConfig.Tenant);
                options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
                options.Resource = azureAdConfig.ResourceURI_Graph;
              options.Events = new AuthEvents(azureAdConfig, connectionStringsConfig);
            });

应用程序运行良好,但现在我想限制应用程序供一组用户使用。为此,我在 Azure AD 应用程序中添加了所需的用户和组。

然后我在 azure app 服务中启用了以下设置。

我还在 Azure AD 企业应用程序中启用了需要用户分配设置。 PFB

但是现在,当我访问应用程序时,我收到以下错误:(我已添加所需的回复网址)

【问题讨论】:

  • 这是 Azure B2C 吗?
  • @TiagoBrenck No

标签: .net azure asp.net-core azure-active-directory azure-web-app-service


【解决方案1】:

由于您使用 OpenID Connect 从 AAD 登录用户,因此在 Web 应用程序中使用 ASP.Net OpenID Connect OWIN 中间件,您无需配置 built-in authentication and authorization support of App Service

尝试禁用authentication and authorization功能,启用AAD应用的user assignment required,让OIDC中间件在你的应用中控制认证过程。

【讨论】:

  • 成功了,谢谢!!!但唯一的问题是它向用户显示登录页面,并且在用户点击登录后它说无法登录
  • 那将是其他东西阻止登录,检查错误消息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-12
  • 1970-01-01
  • 2020-10-21
  • 2021-08-23
  • 2019-11-05
  • 2021-02-12
相关资源
最近更新 更多