Skip to content

Commit

Permalink
[Fixes #3984] Recurring User 'None' Error Geofence/Geoserver
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Oct 15, 2018
1 parent 07d6e2e commit d821cb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions geonode/security/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def set_permissions(self, perm_spec):
if "AnonymousUser" in geofence_user:
geofence_user = None
if settings.OGC_SERVER['default'].get("GEOFENCE_SECURITY_ENABLED", False):
sync_geofence_with_guardian(self.layer, perms, user=geofence_user)
if self.polymorphic_ctype.name == 'layer':
sync_geofence_with_guardian(self.layer, perms, user=geofence_user)

# All the other groups
if 'groups' in perm_spec:
Expand All @@ -213,4 +214,5 @@ def set_permissions(self, perm_spec):
assign_perm(perm, group, self.get_self_resource())
# Set the GeoFence Owner Rules
if settings.OGC_SERVER['default'].get("GEOFENCE_SECURITY_ENABLED", False):
sync_geofence_with_guardian(self.layer, perms, group=group)
if self.polymorphic_ctype.name == 'layer':
sync_geofence_with_guardian(self.layer, perms, group=group)
4 changes: 3 additions & 1 deletion geonode/security/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,11 @@ def _get_geofence_payload(layer, workspace, access, user=None, group=None,
service=None):
highest_priority = get_highest_priority()
root_el = etree.Element("Rule")
username_el = etree.SubElement(root_el, "userName")
if user is not None:
username_el = etree.SubElement(root_el, "userName")
username_el.text = user
else:
username_el.text = ''
priority_el = etree.SubElement(root_el, "priority")
priority_el.text = str(highest_priority if highest_priority >= 0 else 0)
if group is not None:
Expand Down

0 comments on commit d821cb6

Please sign in to comment.