UW-Macrostrat / macrostrat

A geological data platform for exploration, integration, and analysis
Apache License 2.0
4 stars 1 forks source link

Declarative management for PostgreSQL roles #46

Open davenquinn opened 7 months ago

davenquinn commented 7 months ago

We're increasingly encoding access control in PostgreSQL roles. This is great, but means we need to have good ways to manage/apply these roles on database startup and changes (e.g., migrations).

Here's an example of some role configuration for PostgREST: https://github.com/UW-Macrostrat/macrostrat/blob/main/cli/macrostrat/cli/subsystems/knowledge_graph/fixtures/roles.sql

We need to figure out how to centralize and generalize this, in tandem with defining finer-grained roles and potentially row-level security for data access management.

Context:

davenquinn commented 6 months ago

@brianaydemir we can worry more about this later, but this is a lane in which I feel there must be some existing software solution? Keeping a set of roles consistent seems like a really general problem for postgres-based systems...

davenquinn commented 2 months ago

@amyfromandi just making you aware of this issue, as we need to get better at managing roles in Macrostrat in order to use PostgreSQL "row-level-security" in conjunction with PostgREST.

We could use a pre-existing library for this... sqlauthz seems like it could work. A few points

Overall, this might be worth taking a deeper look at as we start on the v3 API design.

davenquinn commented 1 month ago

We've created a start to GRANT functionality in the Macrostrat CLI in #97. We'll see if this is adequate. Currently, it doesn't check the current state or remove grants in excess of requirements. But these capabilities could be added.