fix: trust docker gateway IP for reverse proxy auth
Deploy Dashboard / deploy (push) Successful in 1m35s
Deploy Dashboard / deploy (push) Successful in 1m35s
This commit is contained in:
@@ -60,3 +60,22 @@ def is_lan_ip(ip_str: str) -> bool:
|
||||
return False
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
TRUSTED_PROXIES = os.environ.get("TRUSTED_PROXIES", "127.0.0.1,::1,172.16.0.0/12,10.0.0.0/8").split(",")
|
||||
|
||||
def is_trusted_proxy(ip_str: str) -> bool:
|
||||
import ipaddress
|
||||
try:
|
||||
ip_obj = ipaddress.ip_address(ip_str)
|
||||
for subnet_str in TRUSTED_PROXIES:
|
||||
subnet_str = subnet_str.strip()
|
||||
if "/" in subnet_str:
|
||||
if ip_obj in ipaddress.ip_network(subnet_str):
|
||||
return True
|
||||
else:
|
||||
if ip_obj == ipaddress.ip_address(subnet_str):
|
||||
return True
|
||||
return False
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user