我有现有的Asp.net核心2.0应用程序。我试图与连接服务将其Azure中添加Active Directory认证。当我试图右键点击连接服务和检查验证与Azure中的Active Directory连接服务,我没有找到的选项。我在网上搜索,发现现有的asp.net核心应用有没有连接服务选项。会有什么工作都是围绕在这种情况下?任何提示?
你可以试试下面的步骤:
Microsoft.AspNetCore.Authentication.AzureAD.UI
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);
app.UseAuthentication();
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