Starts in:
0 DAY
9 HRS
1 MIN
40 SEC
Starts in:
0 D
9 H
1 M
40 S
Open Closed

PreConfigure<OpenIddictBuilder> is called twice #8302


User avatar
0
jean@groovejones.com created

The following lambda code:

        PreConfigure<OpenIddictBuilder>(builder =>
        {
            // THIS IS CALLED TWICE
            

            builder.AddValidation(options =>
            {
                options.AddAudiences("AbpSolution1");
                options.UseLocalServer();
                options.UseAspNetCore();
            });
        });

is called twice. This is the code provided by ABP template. This is problematic because I want to attach handler in there and it is being called more than once.

            // If I add this, then my event handler is added twice.
            builder.AddServer(options =>
            {
                options.AllowDeviceCodeFlow();

                options.AddEventHandler(ScanScopedHandler.Descriptor);
            });

Can you please provide a fix or a workaround?

  • UI Type: Angular / MVC /8.3.3
  • Template: app
  • Created ABP Studio Version: 0.9.6
  • Tiered: No
  • UI Framework: mvc
  • Theme: leptonx
  • Theme Style: system
  • Database Provider: ef
  • Database Management System: postgresql
  • Separate Tenant Schema: No
  • Mobile Framework: none
  • Public Website: No
  • Optional Modules:
    • GDPR
    • TextTemplateManagement
    • LanguageManagement
    • AuditLogging
    • SaaS
    • OpenIddictAdmin

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

    Hi,

    We will fix it. https://github.com/abpframework/abp/issues/21377

    you can use this way as a temporary Solution

    public static bool IsOpenIddictBuilderConfigured = false;
        
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        var hostingEnvironment = context.Services.GetHostingEnvironment();
        var configuration = context.Services.GetConfiguration();
    
        PreConfigure<OpenIddictBuilder>(builder =>
        {
            if (!IsOpenIddictBuilderConfigured)
            {
                builder.AddValidation(options =>
                {
                    options.AddAudiences("Qa");
                    options.UseLocalServer();
                    options.UseAspNetCore();
                });
    
                IsOpenIddictBuilderConfigured = true;
            }
        })
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06