fix(security): scope row locks and add explicit expiry recovery

This commit is contained in:
2026-11-20 19:51:42 +03:00
parent 93e5a915d5
commit 5c91f605fb
12 changed files with 193 additions and 26 deletions
+13
View File
@@ -111,6 +111,10 @@ def postgres(raw):
],
},
}
if "compose.test.yaml" in os.getenv("COMPOSE_FILE", ""):
for role in ["api", "relay"]:
grants[role]["SELECT"].append("pipeline_faults")
grants[role]["UPDATE"].append("pipeline_faults")
# SQL literals use psycopg's own adapter; names are fixed local roles.
for role, permissions in grants.items():
name = "svc_" + role
@@ -152,6 +156,15 @@ def postgres(raw):
+ name
+ ";"
)
# PostgreSQL row locks also need UPDATE privilege on at least one
# column. Grant a key column, not attachment processing state.
for table in {
"api": ["attachments", "upload_reservations"],
"reconciler": ["upload_reservations"],
}.get(role, []):
statements.append(
"GRANT UPDATE(id) ON " + table + " TO " + name + ";"
)
# Only append-only technical event/outbox IDs use sequences.
sequences = {
"api": ["outbox_id_seq"],