Open Closed

How would I get access to the ExternalProviders settings within my BlazorModule #6095


User avatar
0
joe@tronactive.com created
  • ABP Framework version: v7.4.1
  • UI Type: Blazor Server
  • Database System: EF Core SQL Server
  • Tiered (for MVC) or Auth Server Separated (for Angular): no

How would I get access to the ExternalProviders settings within my BlazorModule? I want to use the settings to configure the AzureOpenId external provder instead of keeping them in appsettings.json likle I am below.

    context.Services.AddAuthentication()
        .AddOpenIdConnect("AzureOpenId", "Azure AD", options =>
        {
            options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
            options.RequireHttpsMetadata = false;
            options.SaveTokens = true;
            options.GetClaimsFromUserInfoEndpoint = true;
            options.Scope.Add("email");
            options.Scope.Add("openid");
            options.Scope.Add("profile");
            options.Scope.Add("User.Read");
            options.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub");
            options.CallbackPath = "/signin-azuread-oidc";
            options.Authority = configuration["AzureAd:Authority"];
            options.ClientId = configuration["AzureAd:ClientId"];
            options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
            options.CallbackPath = "/signin-azuread-oidc";
            options.ClientSecret = configuration["AzureAd:ClientSecret"];
        });

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

    hi

    Do you mean Dynamic ExternalProviders,

    It can't be used in ConfigureServices method.

  • User Avatar
    0
    joe@tronactive.com created

    No I just want to call the AbpSettings and get the stored AzureOpenId settings so I can insert them into the above options section.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can add a IPostConfigureOptions service and inject the services in it.

    Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<OpenIdConnectOptions>, YourOpenIdConnectPostConfigureOptions>());
    

    https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-7.0#options-post-configuration

    https://github.com/dotnet/aspnetcore/blob/release/7.0/src/Security/Authentication/OpenIdConnect/src/OpenIdConnectPostConfigureOptions.cs#L16

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