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:
@@ -33,6 +33,9 @@ name: ${COMPOSE_PROJECT_NAME:-mtusi-lab7}
|
||||
# database_url, cache_url, broker_url and the S3 key pair are NOT mounted as files into api, relay,
|
||||
# worker any more (src/messenger/bao.py).
|
||||
x-bao-env: &bao-env
|
||||
# Not a secret: the random X-Instance-Id alias of the process (config.py), for the operator's
|
||||
# alias -> container mapping (scripts/stop-one.sh).
|
||||
INSTANCE_ID_FILE: /tmp/instance_id
|
||||
BAO_ADDR: https://openbao:8200
|
||||
BAO_CACERT: /run/secrets/internal-ca.crt
|
||||
BAO_ROLE_ID_FILE: /run/secrets/bao_role_id
|
||||
@@ -49,6 +52,16 @@ x-api-env: &api-env
|
||||
DB_TIMEOUT_SECONDS: ${DB_TIMEOUT_SECONDS:-3}
|
||||
CACHE_TIMEOUT_SECONDS: ${CACHE_TIMEOUT_SECONDS:-0.5}
|
||||
PASSWORD_HASH_CONCURRENCY: ${PASSWORD_HASH_CONCURRENCY:-2}
|
||||
# Lab 7: Argon2id parameters, chosen by a measurement on this stand (bench/argon2_bench.py,
|
||||
# REPORT.md); the application refuses values below m=19456 KiB, t=2, p=1.
|
||||
ARGON2_MEMORY_KIB: ${ARGON2_MEMORY_KIB:-19456}
|
||||
ARGON2_ITERATIONS: ${ARGON2_ITERATIONS:-2}
|
||||
ARGON2_PARALLELISM: ${ARGON2_PARALLELISM:-1}
|
||||
# Lab 7: failed-login limits (src/messenger/ratelimit.py) -> 429 + Retry-After.
|
||||
LOGIN_RATE_LIMIT_USER: ${LOGIN_RATE_LIMIT_USER:-5}
|
||||
LOGIN_RATE_LIMIT_USER_WINDOW_SECONDS: ${LOGIN_RATE_LIMIT_USER_WINDOW_SECONDS:-60}
|
||||
LOGIN_RATE_LIMIT_IP: ${LOGIN_RATE_LIMIT_IP:-50}
|
||||
LOGIN_RATE_LIMIT_IP_WINDOW_SECONDS: ${LOGIN_RATE_LIMIT_IP_WINDOW_SECONDS:-300}
|
||||
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
|
||||
# Graceful stop: 3 s drain (readiness 503, still serving) + up to 8 s for in-flight requests.
|
||||
DRAIN_SECONDS: ${DRAIN_SECONDS:-3}
|
||||
@@ -166,6 +179,11 @@ services:
|
||||
start_period: 10s
|
||||
stop_grace_period: 30s # clean shutdown checkpoint instead of crash recovery
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: the image starts as root only to chown its data and drop to its own user
|
||||
# (gosu/su-exec): exactly the capabilities for that, nothing else (no NET_RAW, MKNOD, ...).
|
||||
cap_drop: [ALL]
|
||||
cap_add: [CHOWN, DAC_OVERRIDE, FOWNER, SETGID, SETUID]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [data]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -192,6 +210,11 @@ services:
|
||||
retries: 30
|
||||
start_period: 5s
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: the image starts as root only to chown its data and drop to its own user
|
||||
# (gosu/su-exec): exactly the capabilities for that, nothing else (no NET_RAW, MKNOD, ...).
|
||||
cap_drop: [ALL]
|
||||
cap_add: [CHOWN, DAC_OVERRIDE, FOWNER, SETGID, SETUID]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [data]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -232,6 +255,11 @@ services:
|
||||
start_period: 10s
|
||||
stop_grace_period: 30s
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: the image starts as root only to chown its data and drop to its own user
|
||||
# (gosu/su-exec): exactly the capabilities for that, nothing else (no NET_RAW, MKNOD, ...).
|
||||
cap_drop: [ALL]
|
||||
cap_add: [CHOWN, DAC_OVERRIDE, FOWNER, SETGID, SETUID]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [storage]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -262,6 +290,11 @@ services:
|
||||
start_period: 20s
|
||||
stop_grace_period: 30s
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: the image starts as root only to chown its data and drop to its own user
|
||||
# (gosu/su-exec): exactly the capabilities for that, nothing else (no NET_RAW, MKNOD, ...).
|
||||
cap_drop: [ALL]
|
||||
cap_add: [CHOWN, DAC_OVERRIDE, FOWNER, SETGID, SETUID]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [queue]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -287,6 +320,9 @@ services:
|
||||
healthcheck:
|
||||
disable: true
|
||||
restart: "no"
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [data]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -329,6 +365,9 @@ services:
|
||||
healthcheck:
|
||||
disable: true
|
||||
restart: "no"
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [storage]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -381,6 +420,9 @@ services:
|
||||
condition: service_healthy # healthy = unsealed (see the openbao healthcheck)
|
||||
stop_grace_period: 15s # > DRAIN_SECONDS + SHUTDOWN_TIMEOUT_SECONDS (11 s)
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [edge, data, storage, telemetry, vault]
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
@@ -418,6 +460,9 @@ services:
|
||||
api:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [edge]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -456,6 +501,9 @@ services:
|
||||
condition: service_healthy
|
||||
stop_grace_period: 10s
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [data, queue, telemetry, vault]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -504,6 +552,9 @@ services:
|
||||
condition: service_healthy
|
||||
stop_grace_period: 30s # > WORKER_SHUTDOWN_SECONDS (20 s) + release
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [data, storage, queue, telemetry, vault]
|
||||
deploy:
|
||||
replicas: ${WORKER_REPLICAS:-1}
|
||||
@@ -541,6 +592,9 @@ services:
|
||||
s3:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [data, storage]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -563,6 +617,9 @@ services:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [data]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -588,6 +645,9 @@ services:
|
||||
- {source: pki_foreign_lb_crt, target: foreign-lb.crt}
|
||||
- {source: pki_foreign_lb_key, target: foreign-lb.key}
|
||||
restart: "no"
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [edge]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -622,6 +682,9 @@ services:
|
||||
start_period: 5s
|
||||
stop_grace_period: 15s
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [vault]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -646,6 +709,9 @@ services:
|
||||
volumes:
|
||||
- ./infra/otel:/etc/otelcol:ro
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [telemetry]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -681,6 +747,9 @@ services:
|
||||
start_period: 10s
|
||||
stop_grace_period: 30s
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [telemetry]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -700,6 +769,9 @@ services:
|
||||
- lokidata:/loki
|
||||
stop_grace_period: 30s
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [telemetry]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -719,6 +791,9 @@ services:
|
||||
- tempodata:/var/tempo
|
||||
stop_grace_period: 30s
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [telemetry]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -778,6 +853,9 @@ services:
|
||||
tempo:
|
||||
condition: service_started
|
||||
restart: unless-stopped
|
||||
# Lab 7 hardening: no Linux capabilities at all, no privilege gain via setuid binaries.
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks: [telemetry, ui]
|
||||
deploy:
|
||||
resources:
|
||||
|
||||
Reference in New Issue
Block a user