Open Closed

API Key Authorization Filter #8952


User avatar
0
stephanobalbinot created
  • ABP Framework version: v8.3.4
  • UI Type: Angular
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Some of my tenants have a worker service implemented on-premises. I am authenticating them via the Client Credentials flow in my AuthServer. Now, I need to implement an authorization filter using an API key that is configured as a SettingDefinition for each tenant that needs to use these worker services.

My question is: How can I retrieve the provider key (tenant ID) based on the value of the API key setting? Then, I need to adjust the request scope to the tenant obtained from that provider key.


1 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi,

    It seems there is no built-in way to retrieve it. But you can override SettingProvider in your application and add another method that applies your custom query by using re https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs

    but still you won't be able to access to data source directly to apply a custom query with value, you can also override on of the existing Setting Value Providers https://abp.io/docs/9.0/framework/infrastructure/settings#setting-value-providers

    which is TenantSettingValueProvider in this case: https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantSettingValueProvider.cs

    Or you can create your own value provider according to your custom requirements and configure it:

    Configure<AbpSettingOptions>(options =>
    {
        options.ValueProviders.Add<CustomSettingValueProvider>();
    });
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 18, 2025, 10:42