forked from mtusi2026/mtusi2026lab7
fix(security): scope row locks and add explicit expiry recovery
This commit is contained in:
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user