0
- ABP Framework version: v5.1.3
- UI type: Blazor
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
I'd like to override CreateExternalUserAsync to add some custom logic when new users are created from Azure AD. How can I accomplish this with Blazor as UI?
3 Answer(s)
-
0
-
0
Thanks. I hade made two mistakes:
- I put my custom LoginModel in the wrong project, this pointed me in the right direction:
https://community.abp.io/posts/how-to-customize-the-login-page-of-an-abp-blazor-application-by4o9yms
- I didn't decorate my custom LoginModel with the correct attributes, I found instructions here:
https://docs.abp.io/en/abp/latest/UI/AspNetCore/Customization-User-Interface#overriding-a-page-model-c
Now it's working 👍
My next question is how can I (in CreateExternalUserAsync()) access the claims I received via OpenIdConnect? My config looks like this:
private void ConfigureExternalProviders(ServiceConfigurationContext context, IConfiguration configuration) { context.Services.AddAuthentication() .AddOpenIdConnect("AzureOpenId", "Azure AD OpenId", options => { options.Authority = "https://login.microsoftonline.com/" + configuration["AzureAd:TenantId"] + "/v2.0/"; options.ClientId = configuration["AzureAd:ClientId"]; options.ResponseType = OpenIdConnectResponseType.CodeIdToken; options.CallbackPath = configuration["AzureAd:CallbackPath"]; options.ClientSecret = configuration["AzureAd:ClientSecret"]; options.RequireHttpsMetadata = false; options.SaveTokens = true; options.GetClaimsFromUserInfoEndpoint = true; options.Scope.Add("email"); options.Scope.Add("profile"); options.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub"); })
-
0
I found them in ExternalLoginInfo.Principal.Claims