Implement Lab 7 service security
Application / https-smoke (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
dmice9
2026-12-03 20:56:06 +03:00
parent 20afc2c790
commit 9bf101b322
57 changed files with 3802 additions and 53 deletions
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
set -eu
mkdir -p /tmp/mc/certs/CAs
cp /run/tls/ca.crt /tmp/mc/certs/CAs/lab.crt
export MC_CONFIG_DIR=/tmp/mc
attempt=0
until mc alias set store https://s3:9000 "$(cat /run/secrets/minio_root_user)" "$(cat /run/secrets/minio_root_password)" >/dev/null 2>&1; do
attempt=$((attempt + 1))
if [ "$attempt" -ge 60 ]; then
echo "MinIO unavailable over trusted HTTPS" >&2
exit 1
fi
sleep 1
done
mc mb --ignore-existing store/messenger-attachments >/dev/null
printf messenger-ready | mc pipe store/messenger-attachments/system/readiness >/dev/null
for role in api worker; do
mc admin user add store "lab7-$role" "$(cat "/run/secrets/s3_$role")" >/dev/null
mc admin policy create store "lab7-$role" "/policies/$role.json" >/dev/null
if ! mc admin user info --json store "lab7-$role" | grep -q "\"policyName\":\"lab7-$role\""; then
mc admin policy attach store "lab7-$role" --user "lab7-$role" >/dev/null
fi
done
echo "MinIO bucket and two scoped policies are ready."