Authorization
S3 IAM users, policies, and service accounts are part of the core pgsilo MVP. SQL application role grants (silo_api / silo_bucket) and joint S3-to-PostgreSQL authorization (iam_and_pg mode) are Preview features in the MVP release.
pgsilo separates three kinds of identities:
- Database owner (
silo_owner): the trusted ordinary PostgreSQL role used bysilo servergateways viaSILO_PG_DSN. - SQL application logins (e.g.,
app_sql): independent unprivileged PostgreSQL roles that callsilo_apifunctions. - S3 identities: S3 root credentials, IAM users, service accounts, and STS temporary sessions.
Never connect applications or S3 bindings as the installation owner (silo_owner) or a PostgreSQL superuser.
SQL application privileges
Create an unprivileged login role for SQL callers:
As the installation owner (silo_owner), grant schema USAGE, function EXECUTE, and table privileges on the target bucket’s ACL relation in silo_bucket:
| SQL operation | Required bucket ACL privilege |
|---|---|
stat_object, get_object, read_object, list_objects | SELECT |
put_object (including unconditional overwrite) | INSERT |
Conditional put_object, copy_object, delete_object | Operation privileges plus SELECT |
copy_object | Source SELECT and destination INSERT |
delete_object, drop_bucket | DELETE (drop_bucket also requires an empty bucket) |
bucket_info, list_buckets | At least one of SELECT, INSERT, or DELETE |
create_bucket | EXECUTE on silo_api.create_bucket(text, text) |
Callers must connect directly as app_sql (session_user is checked; SET ROLE is rejected). Recreating a dropped bucket generates a new ACL relation in silo_bucket and requires fresh GRANT statements.
Joint authorization (iam_and_pg)
By default (iam mode), S3 requests are authorized solely by S3 IAM and bucket policies. Optional iam_and_pg mode requires both S3 IAM evaluation and the bound PostgreSQL role’s silo_bucket privileges to succeed:
- An explicit IAM
Deny, service-account policy restriction, or STS session policy restriction always denies the request; PostgreSQLGRANTstatements never override an IAM denial. - The authorization mode is stored in the shared database (
silo.set_native_auth_mode) and applies across all gateways connected to that database. - Anonymous S3 requests have no PostgreSQL role binding and are rejected in
iam_and_pgmode.
Bound PostgreSQL roles must be independent ordinary roles (NOLOGIN roles are recommended for S3-only principals) and must not:
- Hold
SUPERUSER,CREATEDB,CREATEROLE,REPLICATION, orBYPASSRLS - Inherit the installation owner (
silo_owner), schema owners,pg_read_all_data, orpg_write_all_data - Hold privileges on the private
siloschema - Hold
WITH GRANT OPTIONonsilo_apifunctions orCREATEonsilo_api/silo_bucket
Enabling iam_and_pg mode
After creating the IAM user app-s3 and granting bucket privileges to app_sql, create a dedicated NOLOGIN role for the S3 root identity and bind both principals inside a transaction as silo_owner:
Before switching an active deployment to iam_and_pg, bind every required root and IAM user identity and grant privileges on all target buckets.
S3-to-PostgreSQL privilege mapping
| S3 operation class | Required PostgreSQL privilege in iam_and_pg mode |
|---|---|
Object GET/HEAD, version reads, listings, tag/retention/bucket-config reads | SELECT on bucket ACL relation |
Object PUT, tag writes, retention/legal-hold writes, annotation PUT | INSERT on bucket ACL relation |
Object/version DELETE, AbortMultipartUpload, annotation DELETE | DELETE on bucket ACL relation |
| Bucket configuration changes, governance-retention bypass | UPDATE on bucket ACL relation (plus operation-specific privileges) |
DeleteBucket, ForceDeleteBucket | DELETE and UPDATE on bucket ACL relation |
CreateBucket | EXECUTE on silo_api.create_bucket(text, text) |
Conditional writes/deletes and annotation mutations with x-amz-object-if-match | Operation privilege plus SELECT on bucket ACL relation |
CopyObject | Source SELECT and destination INSERT (plus annotation IAM actions when copying annotations) |
Service accounts and STS temporary credentials inherit the PostgreSQL role binding of their parent IAM user while enforcing their own IAM and session-policy restrictions.
Revoking bindings and restoring default mode
As silo_owner, unbind principals or switch back to iam mode:
Bindings track both the PostgreSQL role OID and the IAM user generation. Dropping and recreating a role or IAM user with the same name requires re-running silo.bind_native_principal. Switching S3 back to iam mode does not relax privileges on the silo_api SQL functions.
