Skip to content
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

feat(dashboard): Add column-level privileges management #13745

Merged
merged 57 commits into from Jan 10, 2024

Conversation

HTMHell
Copy link
Contributor

@HTMHell HTMHell commented Apr 15, 2023

New Feature: Column-level Privileges Management in Supabase Dashboard

This Pull Request introduces a new feature for managing column-level privileges in the Supabase Dashboard. With this enhancement, users can now seamlessly view and modify table privileges for each role.

Key Benefits

Column-level security comes in handy when you want to grant specific actions to certain roles, but restrict access to specific columns. For instance, this is particularly useful when you allow authenticated users to insert or update records but want to prevent them from modifying the values of certain critical columns (e.g. created_at or updated_at).

Features include

  • Effortlessly view and edit column-level privileges in the dashboard
  • Improve security and control by specifying permissions per column for each role
  • Enhance overall flexibility and customization in managing database access and operations

Here is a quick demo:

Screenshare.-.2023-04-15.2_45_09.PM.mp4

@HTMHell HTMHell requested a review from a team as a code owner April 15, 2023 12:01
@vercel
Copy link

vercel bot commented Apr 15, 2023

@HTMHell is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Apr 15, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
studio-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 6:28am
supabase-studio-prod ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 6:28am
supabase-studio-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 6:28am
6 Ignored Deployments
Name Status Preview Comments Updated (UTC)
database-new ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 6:28am
docs ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 6:28am
studio ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 6:28am
studio-self-hosted ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 6:28am
ui-storybook ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 6:28am
zone-www-dot-com ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 6:28am

@alaister
Copy link
Member

Hey @HTMHell,

First off, what an awesome PR! Thanks for the hard work here 💪🏻

We've been planning this feature for a while now, along with refactoring our RLS interface (possibly consolidating the two). The frontend team will need to discuss how to best get your changes in, as they'll be a fair amount of overlap.

We'll keep you updated, and thanks again! 🙌🏻

@HTMHell
Copy link
Contributor Author

HTMHell commented Apr 15, 2023

Hey @HTMHell,

First off, what an awesome PR! Thanks for the hard work here 💪🏻

We've been planning this feature for a while now, along with refactoring our RLS interface (possibly consolidating the two). The frontend team will need to discuss how to best get your changes in, as they'll be a fair amount of overlap.

We'll keep you updated, and thanks again! 🙌🏻

cool, thank you!

@squallsama
Copy link

This functionality could be really useful. Hope that Supa ase team will merge this pull request.

@alaister alaister self-assigned this Apr 20, 2023
@eqoram
Copy link

eqoram commented Apr 26, 2023

This is awesome! Highly appreciate it @HTMHell

@saltcod
Copy link
Contributor

saltcod commented May 1, 2023

Hey @HTMHell !

  1. Amazing github handle!
  2. Also amazing first PR! Thank you so much for it!

While we continue to debate the UI for this, wondering if you could have a peek at the data handling. It looks like you're loading it’s currently loading all the permissions for all tables on load. Could you limit that to just the table in the current view. Some of these tables could be loading MBs of data.

with thanks!

@HTMHell
Copy link
Contributor Author

HTMHell commented May 1, 2023

Thank you!
Yes, that makes sense. At first, I loaded the data for all tables because I listed all the tables on the screen. However, it introduced UI performance issues because of the many toggles, so I limited it to one table.

I will probably have time for this in a few days.

@HTMHell
Copy link
Contributor Author

HTMHell commented May 1, 2023

@saltcod I've made the changes, it will load the data for the selected table only

@saltcod
Copy link
Contributor

saltcod commented May 15, 2023

Hey @HTMHell let's try and get this in this week! Just had a look and things are looking great.

Noticed this in light mode:
CleanShot 2023-05-15 at 17 15 45@2x

Wondering if we also need any kind of docs for this?

@HTMHell
Copy link
Contributor Author

HTMHell commented May 16, 2023

@saltcod Good call, I've never noticed there is a light theme! Can you elaborate on the docs, what were you thinking about?

@saltcod
Copy link
Contributor

saltcod commented May 26, 2023

Sorry @HTMHell — for docs, I meant should we write something to indicate how users should use this feature, and how it would interact with RLS

What does it impact, and how. How should people use this. Those sorts of questions.

@akarshghale
Copy link

Looks like you guys are ready to merge this branch soon. Any updates on it?

@vercel vercel bot temporarily deployed to Preview – studio-staging January 9, 2024 13:14 Inactive
@alaister alaister merged commit 6d121f1 into supabase:master Jan 10, 2024
16 checks passed
@cco3
Copy link

cco3 commented Jan 10, 2024

Thanks! This looks really cool!

@alaister
Copy link
Member

Hey everyone,

We've released this as a feature preview. You can toggle it on for your projects here:

Screenshot 2024-01-10 at 17 43 50

Please send us any feedback on this discussion: https://github.com/orgs/supabase/discussions/20295

@akarshghale
Copy link

Hey @alaister,

Thanks for the feature! I have a few questions regarding this:

  1. I can see the SELECT '*' will break the queries. But what if the privileges have only been revoked for UPDATE & INSERT? From my testing I don't think it applies there. Can you confirm?

  2. Can you please elaborate on this? If you remove a column privilege for a role, that role will lose all access to that column. If i remove INSERT privilege only I can still UPDATE the column so I don't understand the message here.

Thanks!

@alaister
Copy link
Member

Hi @akarshghale,

  1. As long as you're not trying to insert or update those revoked columns both operations should be fine.
  2. You're right the wording could be clearer here. It should be lose all access to that column for that operation.

Hope this helps!

@bitnom
Copy link

bitnom commented Jan 16, 2024

This has made my life

@rohankm
Copy link

rohankm commented Jan 26, 2024

is there any way to SELECT '*' to return only the columns the role has access to it?

@rohankm
Copy link

rohankm commented Jan 28, 2024

other roles or custom roles are not being shown in the select option

@jdgamble555
Copy link

The link at the bottom in the preview toggle popup does not go to the right place fwi:

It goes here:
https://supabase.com/project/YOUR_PROJECT_ID/auth/column-privileges

Instead of here:
https://supabase.com/dashboard/project/YOUR_PROJECT_ID/auth/column-privileges

J

@xleddyl
Copy link

xleddyl commented Feb 22, 2024

It would be cool if the SELECT(*) automatically returned only the columns for which one has authorization

@bombillazo
Copy link

That would require some sort of dynamic query, I don't think there is such a construct at the SQL level to "auto-hide" columns with no privileges (that I know of). While there's no luck in the DB domain, the JS client could abstract that, but it would need to know the privileges beforehand to construct the dynamic query fields...

@xleddyl
Copy link

xleddyl commented Feb 22, 2024

That would require some sort of dynamic query, I don't think there is such a construct at the SQL level to "auto-hide" columns with no privileges (that I know of). While there's no luck in the DB domain, the JS client could abstract that, but it would need to know the privileges beforehand to construct the dynamic query fields...

Yes, perhaps a mechanism similar to the one for generating types from the database schema, which is able to understand which columns are visible to a specific role. Definitely needs to be handled at the library level.

@jdgamble555
Copy link

This might could be a good postgREST feature request.

J

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.

None yet