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}"));
claimsId?.AddClaim(new Claim(AbpClaimTypes.Email, $@"{email}"));
return Task.FromResult(0);
}
};
I am trying to extend tenant management to store subdomain names in the database. Same as in this article https://blog.antosubash.com/posts/abp-extend-tenant-with-custom-host However, not able to achieve fully in my project.
Can you please share any sample and/or reference link and/or guideline to achieve the same functionality in the Microservice template?