0
portx-dev created
I would like to specify the IP address that can be used to log in for each tenant. Is this possible with ABP Commercial's functions?
ABP Framework version: Commercial 7.4 UI type: Angular DB provider: EF Core
5 Answer(s)
-
0
Hi,
Just an idea:
First, custom the tenant entity:
ObjectExtensionManager.Instance.Modules() .ConfigureSaas(saas => { saas.ConfigureTenant(tenant => { tenant.AddOrUpdateProperty<string>( //property type: string "AllowedIpAddress", //property name property => { } ); }); });
Then, you can create a middleware that checks the login IP address:
app.Use(async (httpContext, next) => { if(httpContext.Request.Path.ToString().Contains("account/login", StringComparison.InvariantCultureIgnoreCase)) { var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>(); if (currentTenant.IsAvailable) { var tenant = await context.ServiceProvider.GetRequiredService<ITenantRepository>().FindAsync(currentTenant.GetId()); var allowedIp = tenant.GetProperty<string>("AllowedIpAddress"); if (!string.IsNullOrEmpty(allowedIp)) { var remoteIp = httpContext.Connection.RemoteIpAddress.ToString(); if (!remoteIp.Equals(allowedIp, StringComparison.InvariantCultureIgnoreCase)) { throw new Exception("You are not allowed to login from this IP address."); } } } } await next(); });
-
0
thx
Are there any plans to implement this kind of functionality in ABP Commercial?
-
0
Hi,
As I know we have no plan yet.
-
0
ok,thx
-
0
:)