Merge pull request #3414 from fieldOfView/fix_allows_multiple_needs

Fix checking against multiple Needs on OctoPrintPermission
This commit is contained in:
Gina Häußge authored and GitHub committed 2020-01-14 12:44:18 +01:00
commit 7fa4ebd1ec
1 file changed
+16
+16
View File
@@ -79,6 +79,22 @@ class OctoPrintPermission(Permission):
def get_description(self):
return self._description
def allows(self, identity):
"""Whether the identity can access this permission.
Overridden from Permission.allows to make sure the Identity provides ALL
required needs instead of ANY required need.
:param identity: The identity
"""
if self.needs and len(self.needs.intersection(identity.provides)) != len(self.needs):
return False
if self.excludes and self.excludes.intersection(identity.provides):
return False
return True
def union(self, other):
"""Create a new OctoPrintPermission with the requirements of the union of this
and other.