Skip to content

feat: table privileges #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 6, 2023
Merged

feat: table privileges #588

merged 2 commits into from
Jul 6, 2023

Conversation

soedirgo
Copy link
Member

@soedirgo soedirgo commented Jun 15, 2023

Add /table-privileges endpoint to list table (& views, matviews, etc.) privileges.

Example output:

Request:

GET /table-privileges

Response:

[
  {
    "relation_id": 12345,
    "schema": "public"
    "name": "users_audit",
    "kind": "table",
    "privileges": [
      {
        "grantee": "postgres",
        "grantor": "postgres",
        "is_grantable": false,
        "privilege_type": "INSERT",
      },
      {
        "grantee": "postgres",
        "grantor": "postgres",
        "is_grantable": false,
        "privilege_type": "SELECT",
      },
      ...
    ],
  },
  ...
]

Request:

POST /table-privileges
[
  {
    "relation_id": 11111,
    "grantee": "postgres",
    "privilege_type": "ALL"
  },
  {
    "relation_id": 22222,
    "grantee": "postgres",
    "privilege_type": "ALL"
  }
]

Response:

[
  {
    "relation_id": 11111,
    "schema": "public"
    "name": "t1",
    "kind": "table",
    "privileges": [...]
  },
  {
    "relation_id": 22222,
    "schema": "public",
    "name": "t2",
    "kind": "table",
    "privileges": [...]
  }
]

Request:

DELETE /table-privileges
[
  {
    "relation_id": 11111,
    "grantee": "postgres",
    "privilege_type": "ALL"
  },
  {
    "relation_id": 22222,
    "grantee": "postgres",
    "privilege_type": "ALL"
  }
]

Response:

[
  {
    "relation_id": 11111,
    "schema": "public"
    "name": "t1",
    "kind": "table",
    "privileges": []
  },
  {
    "relation_id": 22222,
    "schema": "public",
    "name": "t2",
    "kind": "table",
    "privileges": []
  }
]

TODO:

  • POST for grants
  • DELETE for revokes

@soedirgo soedirgo force-pushed the feat/table-privileges branch from 30ffafd to 95f6f76 Compare June 15, 2023 05:39
@soedirgo soedirgo force-pushed the feat/table-privileges branch from 95f6f76 to 72bd1b8 Compare June 15, 2023 14:00
@soedirgo soedirgo marked this pull request as ready for review June 15, 2023 14:01
@soedirgo soedirgo requested review from a team as code owners June 15, 2023 14:01
@soedirgo soedirgo mentioned this pull request Jul 5, 2023
5 tasks
Copy link
Member

@alaister alaister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

One small style question:

@soedirgo soedirgo merged commit 7b029b7 into master Jul 6, 2023
@soedirgo soedirgo deleted the feat/table-privileges branch July 6, 2023 07:13
avallete pushed a commit that referenced this pull request May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants