.Net Core和Azure AD B2C设置

时间:2018-02-15 20:00:29

标签: azure authentication .net-core azure-ad-b2c

是否有在.Net Core中设置Azure AD B2C的教程或设置指南? sample code提供的official documentation已过时且无法解释。

2 个答案:

答案 0 :(得分:2)

您必须在ASP.NET核心应用程序上配置mutch。主要部分(配置您的AAD B2C)是添加/设置身份验证中间件以使用jwt承载并将您的租户/策略传递给它。

Tutorial link

示例配置(摘自教程):

services.AddAuthentication(options =>
  { 
    options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; 
  })
  .AddJwtBearer(jwtOptions =>
  {
    jwtOptions.Authority = $"https://login.microsoftonline.com/tfp/{Configuration["AzureAdB2C:Tenant"]}/{Configuration["AzureAdB2C:Policy"]}/v2.0/";
    jwtOptions.Audience = Configuration["AzureAdB2C:ClientId"];
    jwtOptions.Events = new JwtBearerEvents
    {
      OnAuthenticationFailed = AuthenticationFailed
    };
  });

答案 1 :(得分:1)