使用SPA的aspnetboilerplate中的WebApi身份验证使用Azure AD B2C

时间:2018-12-14 20:48:10

标签: azure-ad-b2c aspnetboilerplate

我有一个用Vue编写的SPA Web应用程序,该应用程序无需ABP就可以直接登录AADB2C,并且得到了很好的api令牌响应。

对于我的后端WebApi项目,我想使用ABP的所有不错的功能,但是我想用AADB2C调用替换ABP的身份验证部分。为此,我将Startup中的AddAuthentication()调用替换为…(.net核心)

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

    IdentityRegistrar.Register(services);  // ABP generated

    // I removed this code …
    //  AuthConfigurer.Configure(services, _appConfiguration);     // ABP generated

    // I added this code from a generated webapi project startup file that I know works separately …
    services.AddAuthentication(AzureADB2CDefaults.BearerAuthenticationScheme)
       .AddAzureADB2CBearer(options => Configuration.Bind("AzureAdB2C", options));
...
}

如何让ABP识别这一点并验证外部jwt令牌并创建新的AbpUser?这样,可以在abp应用程序服务上使用所有AbpAuthorize属性。

我看到了这个建议,但似乎我需要自己用这种方式向B2C打电话…… https://aspnetboilerplate.com/Pages/Documents/Zero/User-Management?searchKey=authentication#external-authentication

谢谢

-安迪

0 个答案:

没有答案
相关问题