Open Closed

azure AD integration Issue #7043


User avatar
0
s.alshammari.c created

HI , I am using asp and angular I am trying to integrate Azure AD for Authentication.

 private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)  
{  
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();  
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Add("sub", ClaimTypes.NameIdentifier);  
context.Services.AddAuthentication()  
  
.AddAzureAD(options => configuration.Bind("AzureAd", options));

context.Services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>  
{  
options.Authority = "[https://login.microsoftonline.com/"](https://login.microsoftonline.com/%22 "https://login.microsoftonline.com/%22") + configuration["AzureAd:TenantId"] + "/v2.0/";  
options.ClientId = configuration["AzureAd:ClientId"];  
options.CallbackPath = configuration["AzureAd:CallbackPath"];  
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;  
options.RequireHttpsMetadata = false;

options.TokenValidationParameters.ValidateIssuer = false;  
options.GetClaimsFromUserInfoEndpoint = true;  
options.SaveTokens = true;  
options.SignInScheme = IdentityConstants.ExternalScheme;

options.Scope.Add("email");  
options.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub");

});  
}

I get the following errors


9 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    This doesn't seem to be an abp problem. Can you test your code in a plain ASP Net core app?

  • User Avatar
    0
    s.alshammari.c created

    openid configrations are correct but i get this error .

    swagger is work fine. the issue with angular

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Http failure response

    Please check the browser console/network panel to see if there are any messages.

  • User Avatar
    0
    s.alshammari.c created

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share the logs.txt ?

    liming.ma@volosoft.com

  • User Avatar
    0
    s.alshammari.c created

    i sent to your email

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Do you have code like below in your FormsHttpApiHostModule?

    If so can you share the steps to reproduce this error in a new angular and aspnet core template app?

    context.Services.AddCors(options =>
    {
        options.AddDefaultPolicy(builder =>
        {
            builder
                .WithOrigins(
                    configuration["App:CorsOrigins"]?
                        .Split(",", StringSplitOptions.RemoveEmptyEntries)
                        .Select(o => o.Trim().RemovePostFix("/"))
                        .ToArray() ?? Array.Empty<string>()
                )
                .WithAbpExposedHeaders()
                .SetIsOriginAllowedToAllowWildcardSubdomains()
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials();
        });
    });
    

    app.UseCors();

    
    app.UseStaticFiles();
    app.UseRouting();
    app.UseCors();
    
  • User Avatar
    0
    s.alshammari.c created

    yes I have the code like the one you sent.

    I don't know how to reproduce the problem .

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Can you share a simple project to reproduce?

    Thanks

    liming.ma@volosoft.com

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07