Open Closed

SignInManager is not providing Provider key - Azure B2C #3661


0
[email protected] created
  • ABP Framework version: v4.4.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • *Architecture: Micro service

I am trying to implement Azure B2C authentication. With current implementation, I am successfully receiving loginInfo from SignInManager.GetExternalLoginInfoAsync() except ProviderKey value. On first time login, registration entries are adding properly. But, due to blank provider key, UserManager is retuning first user every time. Any help would be grateful. Please check my code snapshot in AbpAccountPublicWebModule.cs :

.AddOpenIdConnect("AzureOpenId","Azure B2C",options =>
 {
     options.SignInScheme = IdentityConstants.ExternalScheme;

     options.ClientId = configuration["AzureAD:ClientId"];
     options.Authority = configuration["AzureAD:Authority"];
     options.SignedOutRedirectUri = configuration["App:SelfUrl"] + "Account/Logout";
     options.ResponseType = OpenIdConnectResponseType.IdToken;

     options.SaveTokens = true;

     options.MetadataAddress = configuration["AzureAD:Instance"];//"https://<tennant>.b2clogin.com/<tennant>.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_SignUp_SignIn";

     options.GetClaimsFromUserInfoEndpoint = true;
     options.ClaimActions.MapAll();

     var clientSecret = configuration["AzureAD:ClientSecret"];
     if (!clientSecret.IsNullOrEmpty())
     {
         options.ClientSecret = clientSecret;
     }

     options.Events = new OpenIdConnectEvents()
     {

         OnTokenValidated = (context) =>
         {

             var email = context.Principal.FindFirstValue("emails"); //initial test:emails => email first when multiple emails
             ClaimsIdentity claimsId = context.Principal.Identity as ClaimsIdentity;
             claimsId?.AddClaim(new Claim(ClaimTypes.NameIdentifier, [email protected]"{email}"));
             claimsId?.AddClaim(new Claim(AbpClaimTypes.Email, [email protected]"{email}"));

             return Task.FromResult(0);
         }
     };

1 Answer(s)
  • 0
    maliming created
    Support Team

    hi

    , I am successfully receiving loginInfo from SignInManager.GetExternalLoginInfoAsync() except ProviderKey value.

    Can you share a brand new project that can reproduce the problem, [email protected]