fix: handle Caddy-proxied payment webhooks and method selection

This commit is contained in:
3252a8
2026-05-18 22:45:42 +03:00
parent 49cf5ebad8
commit e3643ee9a0
7 changed files with 56 additions and 7 deletions
+12 -1
View File
@@ -274,7 +274,18 @@ class FreeKassaService(HttpClientMixin):
try:
client_ip = request_client_ip(request, trusted_proxies=self.settings.trusted_proxies)
if not ip_in_allowlist(client_ip, self.config.trusted_ips_list):
trusted = self.config.trusted_ips_list
if not ip_in_allowlist(client_ip, trusted):
logging.warning(
"FreeKassa webhook denied from unauthorized IP source "
"(client_ip=%s remote=%s x_forwarded_for=%s trusted_ips=%s "
"trusted_proxies=%s).",
client_ip,
request.remote,
request.headers.get("X-Forwarded-For"),
trusted,
self.settings.trusted_proxies,
)
return web.Response(status=403)
raw_body = await request.read()
+9 -1
View File
@@ -308,7 +308,15 @@ class HeleketService(HttpClientMixin):
client_ip = request_client_ip(request, trusted_proxies=self.settings.trusted_proxies)
trusted = self.config.trusted_ips_list
if trusted and not ip_in_allowlist(client_ip, trusted):
logging.warning("Heleket webhook denied from unauthorized IP source.")
logging.warning(
"Heleket webhook denied from unauthorized IP source "
"(client_ip=%s remote=%s x_forwarded_for=%s trusted_ips=%s trusted_proxies=%s).",
client_ip,
request.remote,
request.headers.get("X-Forwarded-For"),
trusted,
self.settings.trusted_proxies,
)
return web.Response(status=403, text="forbidden")
raw_body = await request.read()
+9 -1
View File
@@ -263,7 +263,15 @@ class WataService(HttpClientMixin):
client_ip = request_client_ip(request, trusted_proxies=self.settings.trusted_proxies)
trusted = self.config.trusted_ips_list
if trusted and not ip_in_allowlist(client_ip, trusted):
logging.warning("Wata webhook denied from unauthorized IP source.")
logging.warning(
"Wata webhook denied from unauthorized IP source "
"(client_ip=%s remote=%s x_forwarded_for=%s trusted_ips=%s trusted_proxies=%s).",
client_ip,
request.remote,
request.headers.get("X-Forwarded-For"),
trusted,
self.settings.trusted_proxies,
)
return web.Response(status=403, text="forbidden")
raw_body = await request.read()
+9 -1
View File
@@ -861,7 +861,15 @@ async def yookassa_webhook_route(request: web.Request):
client_ip = request_client_ip(request, trusted_proxies=settings.trusted_proxies)
if not ip_in_allowlist(client_ip, YOOKASSA_WEBHOOK_ALLOWED_IPS):
logging.warning("YooKassa webhook denied from unauthorized IP source.")
logging.warning(
"YooKassa webhook denied from unauthorized IP source "
"(client_ip=%s remote=%s x_forwarded_for=%s trusted_ips=%s trusted_proxies=%s).",
client_ip,
request.remote,
request.headers.get("X-Forwarded-For"),
YOOKASSA_WEBHOOK_ALLOWED_IPS,
settings.trusted_proxies,
)
return web.Response(status=403)
try: