Learn Labs
Security

Access Control

Identities, actions, bucket scopes, presigned URLs, and TLS

Every S3 request is signed with an access key and its secret key (AWS Signature Version 4). The server recomputes the signature, finds the identity the key belongs to, and checks whether that identity may perform the action on that bucket.

Identities as code

config/s3.json is mounted into the filer and passed with -s3.config:

{"identities": [{"name": "admin","credentials": [{"accessKey": "admin", "secretKey": "admin12345"}],"actions": ["Admin", "Read", "Write", "List", "Tagging"]},everything, every bucket{"name": "app","credentials": [{"accessKey": "app", "secretKey": "app12345"}],"actions": ["Read:app-data", "Write:app-data", "List:app-data",action:bucket"Read:backups", "Write:backups", "List:backups"]},{"name": "readonly","credentials": [{"accessKey": "readonly", "secretKey": "readonly12345"}],"actions": ["Read", "List"]}every bucket, no writes]}
ActionAllows
ReadGET and HEAD objects
WritePUT, DELETE, multipart uploads
ListList objects (and buckets)
TaggingObject tags
AdminCreate and delete buckets, bucket settings, everything else

An action without a bucket applies to all buckets; Write:app-data applies to one. An identity can have several credential pairs, which is how you rotate keys: add the new pair, deploy clients with it, remove the old one.

Tested

docker compose -f compose_prod.yaml run --rm labs python access_control.py

app       PUT app-data/report.txt                allowed
app       GET app-data/report.txt                allowed
app       PUT backups/db.bak                     allowed
app       GET finance/salaries.csv               AccessDenied
app       CREATE bucket app-new                  AccessDenied
readonly  GET finance/salaries.csv               allowed
readonly  PUT app-data/x                         AccessDenied
admin     DELETE finance/salaries.csv            allowed
requestadminAdminapp2 bucketsreadonlyRead, ListPUT app-data/…✓✓✗GET app-data/…✓✓✓PUT backups/…✓✓✗GET finance/…✓✗✓CREATE bucket✓✗✗DELETE finance/…✓✗✗

Note the second-to-last column: readonly can read finance. "Read everything" really means everything, including buckets created later. Scope read access to buckets too, unless it's genuinely meant to be global.

Least privilege in practice

  • One identity per application or job, never a shared admin key. When a key leaks you revoke one service's access, and logs say who did what.
  • Applications never get Admin. Buckets are created by whoever manages infrastructure (a script, Terraform), not by app code at startup.
  • Backup writers shouldn't be able to delete. A ransomware attack or a buggy script with the backup job's key shouldn't be able to erase the backups. In SeaweedFS Write includes delete, so protect backups with versioning and a copy in a second place.
  • Browsers get presigned URLs, never keys.

Managing identities at runtime

Instead of a file, identities can live in the filer, managed from weed shell:

> s3.configure -user=reports -access_key=reports -secret_key=... \
  -actions=Read,List -buckets=app-data -apply
> s3.configure        # print the current configuration

The file approach keeps access reviewable in git; the shell approach needs no restart. Pick one per cluster so there's a single source of truth.

TLS

S3 signatures protect requests from being altered, not from being read. Without TLS, object contents and presigned URLs travel in clear text. The S3 gateway takes -s3.cert.file and -s3.key.file; more often a reverse proxy (the Nginx module) terminates TLS in front of several gateways. Inside the cluster, SeaweedFS's gRPC traffic between masters, volume servers and filers can use mutual TLS, configured in security.toml (weed scaffold -config=security).

Lab

  1. Add an identity reports that can only read app-data and test it.
  2. Give app a second credential pair, switch the lab to it, and remove the first. Did anything else need to change?
  3. With the readonly key, try to create a presigned PUT URL and use it. Who is the request checked against?

On this page