lab4: S3-вложения, presigned upload и проверки

This commit is contained in:
Vladislav Kunetskiy
2026-10-21 22:42:48 +03:00
parent d342b2a227
commit 49c2fe3071
79 changed files with 12266 additions and 910 deletions
+25
View File
@@ -0,0 +1,25 @@
# SeaweedFS identities
`infra/s3/s3.json` is mounted read-only into the `seaweedfs` container and is
the single source of truth for S3 credentials and permissions.
- `admin` is used only by the one-shot `s3-init` service (bucket creation and
probing). It is never given to the API.
- `app` is used by the API and by presigned uploads. It can read/write only
`messenger-attachments/attachments/*` and `messenger-attachments/staging/*`,
and list the bucket for the orphan sweeper.
The credentials are synthetic values for the local stand. `.env.example`
carries the same values for the API and `scripts/check_s3_creds.py` fails the
offline check if they drift. Replace them in `.env` for any non-local run.
Verify manually:
```sh
# anonymous requests are denied
docker compose exec -T seaweedfs \
wget -qO- http://127.0.0.1:8333/messenger-attachments/attachments/missing
# the app identity cannot write outside its prefixes
docker compose run --rm s3-init # probes this and exits non-zero on violation
```
+24
View File
@@ -0,0 +1,24 @@
{
"identities": [
{
"name": "admin",
"credentials": [
{"accessKey": "lab4admin", "secretKey": "lab4admin-secret"}
],
"actions": ["Admin", "Read", "Write", "List", "Tagging"]
},
{
"name": "app",
"credentials": [
{"accessKey": "lab4app", "secretKey": "lab4app-secret"}
],
"actions": [
"Read:messenger-attachments/attachments/*",
"Write:messenger-attachments/attachments/*",
"Read:messenger-attachments/staging/*",
"Write:messenger-attachments/staging/*",
"List:messenger-attachments"
]
}
]
}