forked from mtusi2026/mtusi2026lab7
лабораторная работа 7
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# lab7: broker (Redis Streams, AOF fsync always — как в lab5). Слушает ТОЛЬКО
|
||||
# 127.0.0.1:6379 своего сетевого namespace; снаружи доступен лишь через broker-gate
|
||||
# (mTLS + allowlist identity api/worker, infra/haproxy/broker-gate.cfg).
|
||||
# ACL — раздельные пользователи для producer (API) и consumer (worker):
|
||||
# api_producer — XADD и создание группы в потоке attachments.jobs; читать/ack/удалять не может
|
||||
# worker_consumer — XREADGROUP/XACK/XAUTOCLAIM/XPENDING/XTRIM + XADD (relay outbox в worker)
|
||||
# ни у кого нет FLUSHALL/CONFIG/DEBUG/KEYS (-@dangerous -@admin), default отключён.
|
||||
set -eu
|
||||
umask 077
|
||||
api_hash=$(tr -d '\r\n' < /run/secrets/broker_api_password | sha256sum | cut -d' ' -f1)
|
||||
worker_hash=$(tr -d '\r\n' < /run/secrets/broker_worker_password | sha256sum | cut -d' ' -f1)
|
||||
cat > /tmp/users.acl <<ACL
|
||||
user default off
|
||||
user healthcheck on nopass -@all +ping
|
||||
user api_producer on #${api_hash} resetkeys ~attachments.jobs resetchannels -@all +@connection -@dangerous -@admin +xadd +xgroup|create +ping
|
||||
user worker_consumer on #${worker_hash} resetkeys ~attachments.jobs ~attachments.jobs:* resetchannels -@all +@connection -@dangerous -@admin +xadd +xgroup|create +xreadgroup +xack +xautoclaim +xpending +xtrim +xlen +xinfo|groups +xinfo|stream +ping
|
||||
ACL
|
||||
exec redis-server \
|
||||
--bind 127.0.0.1 --port 6379 --protected-mode yes \
|
||||
--aclfile /tmp/users.acl \
|
||||
--dir /data --appendonly yes --appendfsync always --save "" \
|
||||
--maxmemory 256mb --maxmemory-policy noeviction
|
||||
Reference in New Issue
Block a user