deploy: the bank callback's controls are in the Caddy example
All checks were successful
Deploy / build-deploy (push) Successful in 7m4s
All checks were successful
Deploy / build-deploy (push) Successful in 7m4s
The README says a bank callback is not signed and that three controls in Caddy "all have to stay in place": a source-IP allowlist, a path of which only the non-secret prefix is in the web server's config, and log_skip. Caddyfile.example had none of them. A host set up from it proxied the callback to the backend from anyone and wrote the secret path to the access log, which feeds the public analytics page. The example now has the block: /hooks/bunq/* answers 403 to anything outside the bank's range, is kept out of the log, and is proxied. It adapts with Caddy 2.11.7 and sorts ahead of the catch-all. Both proxy blocks carry a 64 KiB request_body cap, the same as the backend's. catcrafts-analytics drops /hooks lines from the public tier as well, so the public page does not rest on that one directive. The README no longer says the backend binds loopback, because it does not: ListenerHTTP1 takes a port and no address and binds every IPv4 interface, while the server logs 127.0.0.1 (Crafter.Network issue 11 asks for the address). The firewall on 8081 is what the per-peer limit, the callback's allowlist and the request-size bound rest on, with the two commands that check it. It also documents what the earlier commits changed: the claims file and what to do with a payment that named two orders, the rule that a reference names one order, a payment being counted once whatever the credits file holds, and the ledger being held in memory. The server's copies of the Caddyfile and of the analytics script are installed by hand and are not changed by a deploy. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
3c61116531
commit
5de9107d31
3 changed files with 191 additions and 21 deletions
|
|
@ -169,6 +169,45 @@ catcrafts.net {
|
|||
file_server
|
||||
}
|
||||
|
||||
# ── the bank's callback ──────────────────────────────────────────────
|
||||
#
|
||||
# The bank posts here when money lands (deploy/README.md, "How settlement
|
||||
# actually reaches the shop"). A callback is NOT signed, so what makes one
|
||||
# believable is the controls around the endpoint, and three of the four
|
||||
# are this block. None of it is optional once BANK_CALLBACK_PATH is set:
|
||||
#
|
||||
# remote_ip only the range the bank publishes for its callbacks reaches
|
||||
# the backend. Anyone else is answered 403 here, whatever
|
||||
# follows the prefix, so the answer says nothing about
|
||||
# whether a guessed path was the right one. When the bank
|
||||
# moves its range, callbacks 403 and settlement falls back to
|
||||
# the hourly pull: it fails closed.
|
||||
# the path only the NON-secret prefix is written here. The secret
|
||||
# segment is BANK_CALLBACK_PATH in payments.env and nowhere
|
||||
# else, which is what lets this file be public.
|
||||
# log_skip the request line carries the secret, and the access log
|
||||
# below feeds the PUBLIC analytics report. Without this line
|
||||
# the path is published within the hour. (The analytics
|
||||
# script drops /hooks lines from the public tier as well, so
|
||||
# the report does not rest on this directive alone.)
|
||||
#
|
||||
# remote_ip is the address of the connection itself, which is the right
|
||||
# thing to match while this Caddy faces the internet directly. Behind
|
||||
# another proxy every connection is that proxy's: match client_ip there,
|
||||
# with trusted_proxies set, or this allowlist admits everyone or no one.
|
||||
#
|
||||
# All of it assumes this block is the only way to the backend. See the
|
||||
# note on port 8081 above the catch-all below.
|
||||
log_skip /hooks/bunq/*
|
||||
handle /hooks/bunq/* {
|
||||
@not_the_bank not remote_ip 185.40.108.0/22
|
||||
respond @not_the_bank 403
|
||||
request_body {
|
||||
max_size 64KiB
|
||||
}
|
||||
reverse_proxy 127.0.0.1:8081
|
||||
}
|
||||
|
||||
# ── everything else: server-rendered ─────────────────────────────────
|
||||
#
|
||||
# Pages, /feed.xml, /sitemap.xml and later /api/*. The backend sets its own
|
||||
|
|
@ -178,15 +217,29 @@ catcrafts.net {
|
|||
# possible: reverse_proxy APPENDS the real client address to
|
||||
# X-Forwarded-For, and the backend reads the rightmost entry (see
|
||||
# ClientAddressFromForwarded — the leftmost is whatever the client claimed).
|
||||
# That is only sound while nothing but Caddy can reach 8081, which is why
|
||||
# the backend binds loopback and why the warning at the top of this file
|
||||
# says not to expose the port.
|
||||
# That is only sound while nothing but Caddy can reach 8081, and the same
|
||||
# goes for the bank callback's allowlist above. THE BACKEND DOES NOT
|
||||
# ENFORCE THAT ITSELF: Crafter.Network's ListenerHTTP1 takes a port and no
|
||||
# address and binds every IPv4 interface, whatever the server's startup
|
||||
# line says (Crafter.Network issue #11 asks for the address). Until it can
|
||||
# be given 127.0.0.1 the host firewall is what keeps the port private, so
|
||||
# check it: `ss -ltn 'sport = :8081'` on the box shows 0.0.0.0, and
|
||||
# `curl -m 5 http://<this host>:8081/api/healthz` from anywhere else must
|
||||
# time out.
|
||||
#
|
||||
# request_body is the same 64 KiB the backend sets on its own listener
|
||||
# (kMaxRequestBodyBytes): nothing proxied here is larger than a checkout
|
||||
# form or a bank's callback, and refusing more at the edge means an
|
||||
# oversized upload never crosses to the backend at all.
|
||||
#
|
||||
# Caddy's own rate_limit directive is a third-party module and is NOT in a
|
||||
# standard build — adding it here without rebuilding Caddy stops the server
|
||||
# from starting. If volume ever justifies limiting at the edge, build Caddy
|
||||
# with github.com/mholt/caddy-ratelimit first.
|
||||
handle {
|
||||
request_body {
|
||||
max_size 64KiB
|
||||
}
|
||||
reverse_proxy 127.0.0.1:8081 {
|
||||
health_uri /api/healthz
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue