.net - 如何将 Azure 应用服务的访问权限限制为仅在 Azure Ad 的用户和组设置中添加的用户?

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

我的 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 应用程序服务中启用了以下设置。 enter image description here

此外,我还在 Azure AD 企业应用程序中启用了需要用户分配设置。全氟硼酸 enter image description here

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

enter image description here

最佳答案

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

尝试禁用 AAD 应用的身份验证和授权功能,启用 AAD 应用的需要用户分配,并让应用程序中的 OIDC 中间件控制身份验证过程。

关于.net - 如何将 Azure 应用服务的访问权限限制为仅在 Azure Ad 的用户和组设置中添加的用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57913244/

相关文章:

azure - 如何将 KeyVault secret 传递到 Azure Pipelines 中的模板或脚本文件?

c# - 如何在 EF Core 中实例化 DbContext

c# - 如何从 C# System.DirectoryService 调用抛出的异常中识别 LDAP 错误?

c# - 谁应该负责关闭流

c# - Dispatcher 的实用性和良好实践

javascript - Jest React - 新快照未写入。必须显式传递更新标志才能写入新快照

c# - 使用不产生任何结果的 Include 将关闭阅读器

c# - 创建 Enumerable<KeyValuePair<TKey, TValue>> 的扩展方法 TryGetValue(TKey, out TValue) 就像 Dictionary<TKey, TValue> 一样

Azure Web应用程序静态出站 IP

.net - "You must add a reference to assembly ' 系统.Data.Services.Client,版本=3.5.0.0 '"