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

Privileges for PostgreSQL procedures #655

Open
kkrasnov1 opened this issue May 28, 2024 · 7 comments
Open

Privileges for PostgreSQL procedures #655

kkrasnov1 opened this issue May 28, 2024 · 7 comments

Comments

@kkrasnov1
Copy link

ldap2pg.yml

privileges:
  connect:
  - __connect__
  priv_readers:
  - __connect__
  - __select_on_tables__
  - __select_on_sequences__
  - __usage_on_schemas__
  - __usage_on_types__

  priv_writers:
  - priv_readers
  - __temporary__
  - __delete_on_tables__
  - __insert_on_tables__
  - __truncate_on_tables__
  - __update_on_tables__
  - __execute_on_functions__
  - __usage_on_sequences__


  priv_owners:
  - priv_writers
  - __all_on_schemas__
  - __all_on_tables__
  - __all_on_sequences__
  - __all_on_functions__

Expectations

Hi,

We use procedures in PostgreSQL and builtin priviledge execute_on_functions. If there are procedures, ldap2pg constantly tries to grant privileges to all functions, but cannot.

If privileges for procedures are granted manually, then ldap2pg no longer tries to grant privileges for all functions.

ldap2pg probably correctly determines that there are not enough privileges for procedures, but tries to issue them for functions.

Verbose output of ldap2pg execution

Grant privilege.  grant="EXECUTE ON ALL FUNCTIONS IN SCHEMA xxxx.schema1 TO owner_group" database=xxxx
@bersace
Copy link
Member

bersace commented May 28, 2024

Hi @kkrasnov1 , thanks for reaching. Can you share a sample procedure object, with ACL and owner ? Use \df+ for example.

@kkrasnov1
Copy link
Author

DDL

CREATE SCHEMA ldap2pg_test AUTHORIZATION xxx;

create or replace procedure ldap2pg_test.proc1()
language plpgsql    
as $$
begin

    commit;
end;$$;;

psql

xxx=# \df+ ldap2pg_test.proc1
List of functions
-[ RECORD 1 ]-------+-------------
Schema              | ldap2pg_test
Name                | proc1
Result data type    |
Argument data types |
Type                | proc
Volatility          | volatile
Parallel            | unsafe
Owner               | postgres
Security            | invoker
Access privileges   |
Language            | plpgsql
Source code         |             +
                    | begin       +
                    |             +
                    |     commit; +
                    | end;
Description         |

ldap2pg output

GE Revoke privilege.                                grant="EXECUTE ON ALL FUNCTIONS IN SCHEMA xxx.ldap2pg_test TO public" database=xxx
GE Grant privilege.                                 grant="EXECUTE ON ALL FUNCTIONS IN SCHEMA xxx.ldap2pg_test TO db_pg_test_xxx_datawriter" database=xxx
GE Grant privilege.                                 grant="EXECUTE ON ALL FUNCTIONS IN SCHEMA xxx.ldap2pg_test TO db_pg_test_xxx_owner" database=xxx
GE Grant privilege.                                 grant="EXECUTE ON ALL FUNCTIONS IN SCHEMA xxx.ldap2pg_test TO db_pg_test_xxx_owner" database=xxx

@kkrasnov1
Copy link
Author

kkrasnov1 commented Jun 13, 2024

Hi @bersace,
Is it possible to grant privileges to stored procedures?

@bersace
Copy link
Member

bersace commented Jun 17, 2024

Hi @bersace, Is it possible to grant privileges to stored procedures?

You can manage EXECUTE on all functions with __execute_on_functions__ privilege.
See https://ldap2pg.readthedocs.io/en/latest/builtins/#execute-on-functions

@bersace
Copy link
Member

bersace commented Jun 17, 2024

Hi @bersace, Is it possible to grant privileges to stored procedures?

You can manage only privileges per schema. No finer granularity.

@kkrasnov1
Copy link
Author

Hi @bersace, Is it possible to grant privileges to stored procedures?

You can manage EXECUTE on all functions with __execute_on_functions__ privilege. See https://ldap2pg.readthedocs.io/en/latest/builtins/#execute-on-functions

Thank you. It works correctly.

@kkrasnov1
Copy link
Author

@bersace, every time I start, I get a message
CHANGE Revoke privilege. grant="EXECUTE ON ALL FUNCTIONS IN SCHEMA userdb.ldap2pg_test TO myuser" database=userdb

Am I doing something wrong or is it a bug in ldap2pg?

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

No branches or pull requests

2 participants