Re: Clarification on RLS policy

2025-04-29 Thread Vydehi Ganti
Hi, Checking the documents . Post fetching Boolean can we have a trigger or function which can build up the where filter clause? Or can i have a case statement in the Using which can return such statements? On Fri, Apr 25, 2025 at 7:02 PM Dominique Devienne wrote: > On Fri, Apr 25, 2025 at 3:

Re: Clarification on RLS policy

2025-04-25 Thread Adrian Klaver
On 4/25/25 06:01, Vydehi Ganti wrote: This is my Scenario: *Can you please guide how to achieve this?* CREATE OR REPLACE FUNCTION one.get_country( powner name, ptable_name name)     RETURNS character varying LANGUAGE 'plpgsql' For the below policy statement it created the policy but i c

Re: Clarification on RLS policy

2025-04-25 Thread Achilleas Mantzios - cloud
On 4/25/25 14:01, Vydehi Ganti wrote: This is my Scenario: CREATE OR REPLACE FUNCTION one.get_country( powner name, ptable_name name)     RETURNS character varying LANGUAGE 'plpgsql'     COST 100     STABLE PARALLEL UNSAFE AS $BODY$ DECLARE     lOSUser         varchar(4000) := UPPER(SUBSTR

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 3:29 PM Vydehi Ganti wrote: > Can i know if there is any scenario or ref document for the design you > suggested above? Some docs: https://www.postgresql.org/docs/current/ddl-rowsecurity.html https://satoricyber.com/postgres-security/postgres-row-level-security/ Your Ora

Re: Clarification on RLS policy

2025-04-25 Thread Vydehi Ganti
Can i know if there is any scenario or ref document for the design you suggested above? On Fri, 25 Apr, 2025, 18:56 Dominique Devienne, wrote: > On Fri, Apr 25, 2025 at 3:21 PM Vydehi Ganti wrote: > > So I don't have a possibility to append where clause dynamically and can > only check the bool

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 3:21 PM Vydehi Ganti wrote: > So I don't have a possibility to append where clause dynamically and can only > check the boolean? Indeed. But given that you can run arbitrary SQL inside the function, even dynamic SQL, that ends up pretty much the same. And you have access

Re: Clarification on RLS policy

2025-04-25 Thread Vydehi Ganti
So I don't have a possibility to append where clause dynamically and can only check the boolean? On Fri, 25 Apr, 2025, 18:48 Dominique Devienne, wrote: > On Fri, Apr 25, 2025 at 3:01 PM Vydehi Ganti wrote: > > Then it should build up the lPredicate with the filter condition and > append to the

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 3:01 PM Vydehi Ganti wrote: > Then it should build up the lPredicate with the filter condition and append > to the query user runs on the Activity table. You're not reading us, and asking us to do the work for you... RLS Predicates don't return strings in PostgreSQL, but

Re: Clarification on RLS policy

2025-04-25 Thread Vydehi Ganti
This is my Scenario: I would need a policy on table Activity which has a column country_code . In the policy i would need to call a function get_country as below which queries the users table based on current user and checks which country code that user has access to. Then it should build up the l

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 2:43 PM Laurenz Albe wrote: > On Fri, 2025-04-25 at 12:38 +0530, Vydehi Ganti wrote: > > We are presently using Postgresql:PostgreSQL 15.12 on x86_64-pc-linux-gnu, > > compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-23), 64-bit > > 2.The function would return a charact

Re: Clarification on RLS policy

2025-04-25 Thread Laurenz Albe
On Fri, 2025-04-25 at 12:38 +0530, Vydehi Ganti wrote: > We are presently using Postgresql:PostgreSQL 15.12 on x86_64-pc-linux-gnu, > compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-23), 64-bit > I have a scenario where > 1.I need to enforce RLS policy on a table for Select by calling a Functi

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 9:09 AM Vydehi Ganti wrote: > We are presently using Postgresql:PostgreSQL 15.12 on x86_64-pc-linux-gnu, > compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-23), 64-bit > I have a scenario where > 1.I need to enforce RLS policy on a table for Select by calling a Function

Re: Clarification on RLS policy

2025-04-25 Thread Achilleas Mantzios - cloud
On 4/25/25 08:08, Vydehi Ganti wrote: Hi Team, We are presently using Postgresql:PostgreSQL 15.12 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-23), 64-bit I have a scenario where 1.I need to enforce RLS policy on a table for Select by calling a Function 2.The f