Skip to content

Commit

Permalink
Discard invalid layers from Services other than WMS
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Apr 23, 2024
1 parent 7787d53 commit d98b19c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lizmap_server/lizmap_accesscontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,27 @@ def layerPermissions(self, layer: QgsMapLayer) -> QgsAccessControlFilter.LayerPe
# Get default layer rights
rights = super().layerPermissions(layer)

# Get layer name
layer_name = layer.name()

# Get Project
project = QgsProject.instance()

# Get request handler
request_handler = self.iface.requestHandler()

# Discard invalid layers for other services than WMS
if not layer.isValid() and request_handler.parameter('service').upper() != 'WMS':
Logger.info(f"layerPermission: Layer {layer_name} is invalid in {project.fileName()}!")
rights.canRead = False
rights.canInsert = rights.canUpdate = rights.canDelete = False
return rights

# Get Lizmap user groups provided by the request
groups = get_lizmap_groups(request_handler)

# Set lizmap variables
user_login = get_lizmap_user_login(request_handler)
project = QgsProject.instance()
custom_var = project.customVariables()
if custom_var.get('lizmap_user', None) != user_login:
custom_var['lizmap_user'] = user_login
Expand Down Expand Up @@ -101,9 +114,6 @@ def layerPermissions(self, layer: QgsMapLayer) -> QgsAccessControlFilter.LayerPe
# Default layer rights applied
return rights

# Get layer name
layer_name = layer.name()

# Check lizmap edition config
layer_id = layer.id()
if 'editionLayers' in cfg and cfg['editionLayers']:
Expand Down

0 comments on commit d98b19c

Please sign in to comment.