forked from mtusi2026/mtusi2026lab7
ЛР 7: TLS, mTLS, OpenBao и безопасность — на 3
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
export HOME=/tmp
|
||||
export SSL_CERT_FILE=/run/ca/server.crt
|
||||
export AWS_CA_BUNDLE=/run/ca/server.crt
|
||||
mkdir -p /tmp/.config
|
||||
bucket=lab7/messenger-attachments
|
||||
run() {
|
||||
step=$1
|
||||
shift
|
||||
if ! "$@" >/dev/null 2>&1; then
|
||||
echo "RustFS bootstrap step failed: $step" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
run alias rc alias set lab7 https://s3:9000 "$(cat /run/admin/access)" "$(cat /run/admin/password)"
|
||||
buckets=$(rc bucket list lab7 --json)
|
||||
if ! printf '%s' "$buckets" | python -c 'import json,sys; sys.exit(not any(i["key"]=="messenger-attachments" for i in json.load(sys.stdin)["items"]))'; then
|
||||
run bucket rc mb "$bucket"
|
||||
fi
|
||||
run private rc bucket anonymous set private "$bucket"
|
||||
printf 'ready\n' | run readiness rc pipe "$bucket/health/ready"
|
||||
for role in api worker; do
|
||||
run "create-$role" rc admin user add lab7/ "lab7-$role" "$(cat "/run/scoped/$role")"
|
||||
run "policy-$role" rc admin policy create lab7/ "lab7-$role" "/run/scoped/$role.json"
|
||||
run "attach-$role" rc admin policy attach lab7/ "lab7-$role" --user "lab7-$role"
|
||||
done
|
||||
echo 'PASS: RustFS private bucket and separate scoped identities'
|
||||
Reference in New Issue
Block a user