dalibo / ldap2pg

:elephant: :busts_in_silhouette: Manage PostgreSQL roles and privileges from YAML or LDAP
https://labs.dalibo.com/ldap2pg
PostgreSQL License
208 stars 34 forks source link

ERROR: ldap2pg.script: TypeError: unhashable type: 'dict' #582

Closed fmatvhv closed 6 months ago

fmatvhv commented 9 months ago

What do you want?

I would like to add a privilege 'cod' for CREATE ON DATABASE (as described in https://ldap2pg.readthedocs.io/en/latest/config/#privileges) to the default ldap2pg.yml . The privilege 'cod' is not referenced anywhere in the sync_map section.

ldap2pg.yml

#
#       2.   P R I V I L E G E S   D E F I N I T I O N
#
# See https://ldap2pg.readthedocs.io/en/latest/privileges/. Privileges wrapped
# in double underscores are well-known privileges built-in ldap2pg. See
# https://ldap2pg.readthedocs.io/en/latest/wellknown/ for a documentation of
# each of them.
#

privileges:
  cod:
  - type: CREATE
    on: DATABASE

  # Define `ro` privilege group with read-only grants
  ro:
  - __connect__
  - __select_on_tables__
  - __select_on_sequences__
  - __usage_on_schemas__
  - __usage_on_types__

  # `rw` privilege group lists write-only grants
  rw:
  - __temporary__
  - __all_on_tables__
  - __all_on_sequences__

  # `ddl` privilege group lists DDL only grants.
  ddl:
  - __create_on_schemas__

If I call ldap2pg it throws an error. Am I doing something wrong?

LDAP2PG_VERBOSITY=DEBUG ldap2pg --verbose --real -c ldap2pg.yml
2024-01-17 15:25:40,204 INFO:  ldap2pg.config: Starting ldap2pg 5.9 at 2024-01-17 15:25:40.
2024-01-17 15:25:40,205 DEBUG:  ldap2pg.config: Trying ldap2pg.yml.
2024-01-17 15:25:40,205 INFO:  ldap2pg.config: Using /var/lib/pgx15/X01/etc/ldap2pg.yml.
2024-01-17 15:25:40,220 DEBUG:  ldap2pg.config: Read dry from argv.
2024-01-17 15:25:40,220 DEBUG:  ldap2pg.config: Read verbosity from argv.
2024-01-17 15:25:40,220 DEBUG:  ldap2pg.config: Read version from YAML.
2024-01-17 15:25:40,220 DEBUG:  ldap2pg.config: Read postgres:dsn from PGDSN.
2024-01-17 15:25:40,220 DEBUG:  ldap2pg.config: Read postgres:managed_roles_query from YAML.
2024-01-17 15:25:40,220 DEBUG:  ldap2pg.config: Read postgres:owners_query from YAML.
2024-01-17 15:25:40,220 DEBUG:  ldap2pg.config: Read postgres:schemas_query from YAML.
2024-01-17 15:25:40,221 DEBUG:  ldap2pg.config: Read privileges from YAML.
2024-01-17 15:25:40,221 DEBUG:  ldap2pg.config: Read sync_map from YAML.
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script: Unhandled error:
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script: Traceback (most recent call last):
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:   File "/usr/lib/python3.6/site-packages/ldap2pg/script.py", line 36, in main
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:     config.load()
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:   File "/usr/lib/python3.6/site-packages/ldap2pg/config.py", line 571, in load
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:     self.merge(file_config=file_config, environ=os.environ, args=args)
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:   File "/usr/lib/python3.6/site-packages/ldap2pg/config.py", line 611, in merge
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:     postprocess_privilege_options(self, default_privileges)
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:   File "/usr/lib/python3.6/site-packages/ldap2pg/config.py", line 215, in postprocess_privilege_options
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:     privileges, _, self['privilege_aliases'] = process_privileges(privileges)
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:   File "/usr/lib/python3.6/site-packages/ldap2pg/privilege.py", line 366, in process_definitions
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:     check_group_definitions(privileges, groups)
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:   File "/usr/lib/python3.6/site-packages/ldap2pg/privilege.py", line 350, in check_group_definitions
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:     unknown = [c for c in children if c not in known]
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:   File "/usr/lib/python3.6/site-packages/ldap2pg/privilege.py", line 350, in <listcomp>
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script:     unknown = [c for c in children if c not in known]
2024-01-17 15:25:40,222 ERROR:  ldap2pg.script: TypeError: unhashable type: 'dict'
2024-01-17 15:25:40,223 ERROR:  ldap2pg.script: Please file an issue at https://github.com/dalibo/ldap2pg/issues with full log.
bersace commented 9 months ago

Hi @fmatvhv , did you try ldap2pg 6.0 ? latest documentation refers to 6.0, not 5.9.

bersace commented 6 months ago

Closing stale issue.