Open Closed

Use a different authentication method for specific tenant #6637


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

We have a ABP based application running on azure. Is it supported by ABP to implement a specific authorization method only valid for a special tenant ?

This means the user of this special tenant should able to login with their windows user without using a password for authentication. All users from other tenants need to pass their user and password to login.

Thank you in advance for the help!

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    This can be done, but you will need a custom module code

    For example:

    Configure allowed tenants:

    appsettings.json

     "ExternalTenantProviders": {
        "tenantA" : "windows,google",
        "tenantB" : "google"
     }
    

    Here I used a configuration file, you can create an entity stored to the database

    Replace the ExternalProviderSettingsHelper

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(ExternalProviderSettingsHelper))]
    public class MyExternalProviderSettingsHelper : ExternalProviderSettingsHelper
    {
        private readonly IConfiguration _configuration;
        private readonly ICurrentTenant _currentTenant;
        
        public MyExternalProviderSettingsHelper(ICurrentTenant currentTenant, IOptions<AbpExternalProviderOptions> externalProvidersOptions, ISettingManager settingManager, IJsonSerializer jsonSerializer, IConfiguration configuration) : base(currentTenant, externalProvidersOptions, settingManager, jsonSerializer)
        {
            _currentTenant = currentTenant;
            _configuration = configuration;
        }
    
        public override async Task<List<ExternalProviderSettings>> GetAllAsync()
        {
            var settings = await base.GetAllAsync();
    
            if (_currentTenant.IsAvailable)
            {
                var allowedProviders = _configuration[$"ExternalTenantProviders:{_currentTenant.Name}"];
    
                if (allowedProviders.IsNullOrWhiteSpace())
                {
                    settings.Clear();
                }
                else
                {
                    settings = settings.Where(x => allowedProviders.Split(",").Contains(x.Name)).ToList();
                }
            }
    
            return settings;
        }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    manuel42 created

    Thank you for the example. What do you mean with "custom module code" ? I am not sure If I understand it correct, I need to replace the service in the application template right ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    I am not sure If I understand it correct, I need to replace the service in the application template right ?

    Yes. here is the document: https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Guide

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.