与Azure中的Active Directory连接服务在现有Asp.Net核心应用程序缺少认证

问题描述 投票:0回答:1

我有现有的Asp.net核心2.0应用程序。我试图与连接服务将其Azure中添加Active Directory认证。当我试图右键点击连接服务和检查验证与Azure中的Active Directory连接服务,我没有找到的选项。我在网上搜索,发现现有的asp.net核心应用有没有连接服务选项。会有什么工作都是围绕在这种情况下?任何提示?

c# azure asp.net-core azure-active-directory
1个回答
1
投票

你可以试试下面的步骤:

  1. 安装软件包:Microsoft.AspNetCore.Authentication.AzureAD.UI
  2. 修改Startup.cs使Azure的AD认证: services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddAuthentication(AzureADDefaults.AuthenticationScheme) .AddAzureAD(options => Configuration.Bind("AzureAd", options)); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  3. 添加认证中间件配置: app.UseAuthentication();
  4. 修改appsettings.json添加Azure的AD应用程序设置 { "AzureAd": { "Instance": "https://login.microsoftonline.com/", "Domain": "xxxxxxx.onmicrosoft.com", "TenantId": "xxxxxx-e83b-4099-93c2-8ae86358d05c", "ClientId": "xxxxxxxx-80c5-4bd4-ad6a-a967ea0066d6", "CallbackPath": "/signin-oidc" }, "Logging": { "LogLevel": { "Default": "Warning" } }, "AllowedHosts": "*" }

另一种方式是手工配置的ID连接中间件,你可以参考以下文章:

https://joonasw.net/view/aspnet-core-2-azure-ad-authentication

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.