Re: How to hide stored procedure's bodies from specific user

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Berend Tober <btober(at)broadstripe(dot)net>
Cc: Saimon Lim <aimon(dot)slim(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to hide stored procedure's bodies from specific user
Date: 2015-02-14 14:30:07
Message-ID: CAECtzeW6TS2rm_VB+t_ZAXBDkhjzZ7Ym3bpbOr2DEC26JAhb1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2015-02-14 14:07 GMT+01:00 Berend Tober <btober(at)broadstripe(dot)net>:

> Saimon Lim wrote:
>
>> Thanks for your help
>>
>> I want to restrict some postgres users as much as possible and allow
>> them to execute a few my own stored procedures only.
>>
>
> Create the function that you want restrict access to in a separate
> 'private' schema to which usage is not granted.
>
> Create the functions you wish to allow access to in a schema to which the
> role is granted access to.
>
> You original question was different, i.e., you were asking about hiding
> your clever algorithms from inquisitive inspection. For that, similarly use
> as 'private' schema where you keep you super-secret stuff, and then provide
> a sanitized interface in the 'public' schema:
>
>
> CREATE OR REPLACE FUNCTION private.average(a float, b float)
> RETURNS float
> LANGUAGE sql
> AS $$
> SELECT ($1 + $2)/2.;
> $$;
>
>
> CREATE OR REPLACE FUNCTION public.average(a float, b float)
> RETURNS float
> LANGUAGE sql
> as $$
> select private.average(a,b)
> $$
> security definer;
>
>
Unless I misunderstood something, this doesn't protect at all the function
source code. You can still get it by reading pg_proc.

--
Guillaume.
http://blog.guillaume.lelarge.info
http://www.dalibo.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Berend Tober 2015-02-14 14:32:08 Re: How to hide stored procedure's bodies from specific user
Previous Message Berend Tober 2015-02-14 13:07:44 Re: How to hide stored procedure's bodies from specific user