News for hackers. Stuff that matters.
Re:How We Turn Authorization Logic into SQL by catmanjan on Tuesday November 23, 2021 @06:24PM (#29324876)
Do you have much experience with it? Can you comment on the performance hit?
Re:How We Turn Authorization Logic into SQL by jansommer on Wednesday November 24, 2021 @05:59AM (#29328794)
The performance hit can be quite big. I had a query that went from 1s to 400ms by disabling RLS. The security policy was a simple where org = abc. When I encounter performance hits like these, I refactor the slow query into a function with SECURITY DEFINER and a huge warning that you're on your own regarding security. Besides that, it's nice not having to worry if your SQL is accessing stuff the current role isn't allowed to see.
Re:How We Turn Authorization Logic into SQL by agentultra on Wednesday November 24, 2021 @09:34AM (#29330298)
I do and the answer is always it depends. I'm not being glib! There are a lot of variables at play that will affect performances.

In general it moves computation closer to the data and in aggregate that generally offsets most increases in query times.

If you design your schemas carefully the performance cost is easy to swallow. As always analyze your queries under different table sizes and see what works for you.

The benefit is that your application code doesn't have to use any complex RBAC->SQL compilation. You can just 'select foo, bar, baz from mytable;` and RLS will take care of making sure your application servers never see the data that the user doesn't have access to.

Re:How We Turn Authorization Logic into SQL by SahAssar on Wednesday November 24, 2021 @03:58AM (#29328145)
In my experience the performance hit is not much larger than having the permission check part of your SELECT/UPDATE/DELETE query, but I don't have hard numbers.