Skip to content

Commit

Permalink
Don't write any info permission entry if map or layer is not permitted
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Apr 12, 2024
1 parent e416d8b commit 4110a6c
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/config_generator/feature_info_service_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,23 @@ def additional_wms_permissions(self, role, session):
for info_service, info_layers in available_info_layers.items():
# lookup permissions
if self.permissions_default_allow:
info_service_restricted_for_public = info_service in \
public_restrictions['info_services'] or \
info_service in public_restrictions['maps']
info_service_restricted_for_public = info_service in public_restrictions['info_services']
map_restricted_for_public = info_service in public_restrictions['maps']
else:
info_service_restricted_for_public = info_service not in \
public_permissions['info_services'] and \
info_service not in public_permissions['maps']
info_service_restricted_for_public = info_service not in public_permissions['info_services']
map_restricted_for_public = info_service not in public_permissions['maps']

info_service_permitted_for_role = info_service in \
role_permissions['info_services']
map_permitted_for_role = info_service in \
role_permissions['maps']

# If map is not permitted, skip
if (
map_restricted_for_public
and not map_permitted_for_role
):
continue

# Special case: if map is restricted for public and info_service not explicitly permitted,
# but info_service is default_allow and map resource is permitted, allow
Expand Down Expand Up @@ -324,15 +331,24 @@ def additional_wms_permissions(self, role, session):
# lookup permissions
if self.permissions_default_allow:
info_layer_restricted_for_public = info_layer in \
public_restrictions['info_layers'].get(info_service, {}) or \
info_layer in public_restrictions['layers'].get(info_service, {})
public_restrictions['info_layers'].get(info_service, {})
layer_restricted_for_public = info_layer in public_restrictions['layers'].get(info_service, {})
else:
info_layer_restricted_for_public = info_layer not in \
public_permissions['info_layers'].get(info_service, {}) and \
info_layer not in public_permissions['layers'].get(info_service, {})
public_permissions['info_layers'].get(info_service, {})
layer_restricted_for_public = info_layer not in public_permissions['layers'].get(info_service, {})

info_layer_permitted_for_role = info_layer in \
role_permissions['info_layers'].get(info_service, {})
layer_permitted_for_role = info_layer in \
role_permissions['layers'].get(info_service, {})

# If layer is not permitted, skip
if (
info_layer_restricted_for_public
and not layer_permitted_for_role
):
continue

# Special case: if layer is restricted for public and info_layer not explicitly permitted,
# but info_layer is default_allow and layer resource is permitted, allow
Expand Down

0 comments on commit 4110a6c

Please sign in to comment.