Added domain strict mode
All checks were successful
Build dev on push / build-redirector (push) Successful in 31s
Build dev on push / build-api (push) Successful in 33s
Build dev on push / build-web (push) Successful in 51s

This commit is contained in:
Sven Heidemann 2025-01-16 18:01:40 +01:00
parent 1b63a9b729
commit c8f9d205b8
2 changed files with 5 additions and 3 deletions

View File

@ -36,12 +36,14 @@ async def _handle_request(path: str):
domains = Environment.get("DOMAINS", list[str], [])
domain = await short_url.domain
logger.debug(f"Domain: {domain.name}, request.host: {request.host}")
logger.debug(f"Domain: {domain.name if domain is not None else None}, request.host: {request.host}")
host = request.host
if ":" in host:
host = host.split(":")[0]
if domain is None or domain.name not in domains and not host.endswith(domain.name):
domain_strict_mode = Environment.get("DOMAIN_STRICT_MODE", bool, False)
if domain is None or domain.name not in domains or (domain_strict_mode and not host.endswith(domain.name)):
return render_template("404.html"), 404
user_agent = request.headers.get("User-Agent", "").lower()

View File

@ -1 +1 @@
1.2.4
1.2.5