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
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
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(); });Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
As I know we have no plan yet.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
:)
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)