Open Closed

Cannot extend ExternalProviders list with WithDynamicOptions extension #5611


User avatar
0
raif created
  • ABP Framework version: v7.3.2
  • UI Type: MVC
  • Database System: EF Core SQL Server
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
context.Services.AddAuthentication()
    //.AddAbpOpenIdConnect("myAuthSchema", "myAuth AD", options =>
    .AddOpenIdConnect("myAuthSchema", "myAuth AD", options =>
    {
        options.Authority = configuration["AzureAd:Authority"].EnsureEndsWith('/') + configuration["AzureAd:TenantId"].EnsureEndsWith('/') + "v2.0".TrimEnd('/');
        options.MetadataAddress = configuration["AzureAd:MetadataAddress"].EnsureEndsWith('/') + configuration["AzureAd:TenantId"].EnsureEndsWith('/') + "v2.0".EnsureEndsWith('/') + ".well-known/openid-configuration";
        options.ResponseType = OpenIdConnectResponseType.CodeIdToken;

        options.ClientId = configuration["AzureAd:ClientId"];
        options.ClientSecret = configuration["AzureAd:ClientSecret"];

        options.UsePkce = true;
        options.GetClaimsFromUserInfoEndpoint = true;

        options.TokenValidationParameters = new TokenValidationParameters()
        {
            ValidateIssuer = true,
        };

        options.TokenValidationParameters.ValidIssuers = new[]
        {
            configuration["AzureAd:MetadataAddress"],
            configuration["AzureAd:Authority"]
        };

        options.Scope.Add("openid");
        options.Scope.Add("profile");
        options.Scope.Add("offline_access");
        options.Scope.Add("email");
    });
    .WithDynamicOptions < OpenIdConnectOptions, OpenIdConnectHandler > (
        "myAuthSchema",
        options =>
        {
            options.WithProperty(x => x.ClientId);
            options.WithProperty(x => x.ClientSecret, isSecret: true);
        }
    );

I would like to provide ClientId and ClientSecret values via Account External Provider Settings

/api/account/external-provider endpoint keeps returning only Google, Twitter and Microsoft values

I also tried to extend provider list via AbpExternalProviderOptions but no luck

context.Services.Configure < AbpExternalProviderOptions > (options =>
{
    options.Definitions.Add(new ExternalProviderDefinition()
    {
        Name = "Test",
        Properties = new List < ExternalProviderDefinitionProperty >()
    });
});

What am i missing ?


2 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You need to configure AddDynamicExternalLoginProviderOptions in HttpApiHostModule module class

  • User Avatar
    0
    raif created

    Doh, thx

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