Lab 7
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-11-27 20:47:58 +03:00
parent 20afc2c790
commit d995f98446
97 changed files with 8638 additions and 56 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/bin/sh
set -eu
# Operator-run: create the two mTLS service identities in RabbitMQ and give them
# least-privilege ACLs. RabbitMQ maps the client-certificate CN to a username
# (EXTERNAL auth), so the users must exist beforehand.
#
# api-broker configure + write the pipeline queue (it only publishes)
# worker-broker configure + read the pipeline queue (it only consumes)
#
# Neither identity can touch any other queue or exchange. Re-running is safe.
cd "$(dirname "$0")/.."
compose() { docker compose --env-file .env "$@"; }
rmq() { compose exec -T broker rabbitmqctl "$@"; }
Q='attachment\.process\.v1'
rand() { head -c 24 /dev/urandom | od -An -tx1 | tr -d ' \n'; }
rmq add_user api-broker "$(rand)" >/dev/null 2>&1 || true
rmq add_user worker-broker "$(rand)" >/dev/null 2>&1 || true
# EXTERNAL auth sends no password; disable password login so the TLS identity is
# the only way to use these accounts.
rmq clear_password api-broker >/dev/null 2>&1 || true
rmq clear_password worker-broker >/dev/null 2>&1 || true
# Publishing to the default exchange (amq.default) with the queue name as the
# routing key requires write on BOTH the exchange and the routing key, so the
# API is granted exactly those two names. The worker may only read its queue.
# configure write read
rmq set_permissions -p / api-broker "^${Q}$" "^(amq\.default|${Q})$" "^$"
rmq set_permissions -p / worker-broker "^${Q}$" "^$" "^${Q}$"
echo "broker identities ready: api-broker (configure+write), worker-broker (configure+read), queue $Q"