lab7: Argon2id из env (замер bench/argon2_bench.py), лимит неудачных входов в Valkey (429 + Retry-After), cap_drop ALL и no-new-privileges, X-Instance-Id = случайный alias

This commit is contained in:
Alexey Bodanyuk
2026-11-27 16:57:24 +03:00
parent 876f610847
commit 05df1695fe
16 changed files with 431 additions and 50 deletions
+4
View File
@@ -89,6 +89,10 @@ frontend public
# API echoes it, and errors generated by the LB itself carry the same value.
http-request set-header X-Request-Id %[uuid()] unless { req.hdr(x-request-id) -m reg ^[A-Za-z0-9._:-]{1,128}$ }
http-request set-var(txn.request_id) req.hdr(x-request-id)
# Lab 7: the client address for the API's login rate limit. OVERWRITTEN (never appended to a
# client-supplied value), so a client cannot pick its own "IP"; the API trusts it only because
# nobody but this LB (mTLS identity lb) can connect to the API.
http-request set-header X-Forwarded-For %[src]
log-format "%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq rid=%[var(txn.request_id)] \"%HM %HPO\""
use_backend api if { nbsrv(api) gt 0 }
default_backend api_core
+2 -2
View File
@@ -4,7 +4,7 @@
# user default off no anonymous/shared-password access at all
# user api SHA-256 of its password only (the plain password never lands in a file here),
# keys session:* (sessions.py) and ratelimit:* (login limit), commands it uses:
# GET/SET/DEL (sessions), INCR/PEXPIRE/PTTL in MULTI/EXEC (rate limit), PING
# GET/SET/DEL (sessions), INCR(BY)/PEXPIRE/PTTL in MULTI/EXEC (rate limit), PING
# (readiness), CLIENT SETINFO (sent by redis-py on connect). FLUSHALL, CONFIG,
# KEYS, DEBUG, ACL, ... are refused with NOPERM.
set -eu
@@ -12,7 +12,7 @@ umask 077
mkdir -p /tmp/valkey
hash="$(tr -d '\r\n' < /run/secrets/valkey_api_password | sha256sum | cut -d' ' -f1)"
printf 'user default off\n' > /tmp/valkey/users.acl
printf 'user api on #%s resetkeys ~session:* ~ratelimit:* resetchannels -@all +get +set +del +incr +pexpire +pttl +multi +exec +discard +ping +client|setinfo\n' \
printf 'user api on #%s resetkeys ~session:* ~ratelimit:* resetchannels -@all +get +set +del +incr +incrby +pexpire +pttl +multi +exec +discard +ping +client|setinfo\n' \
"$hash" >> /tmp/valkey/users.acl
chown -R valkey /tmp/valkey
exec docker-entrypoint.sh valkey-server /etc/valkey/valkey.conf