forked from Github-Mirrors/canaille
fix: a crash when no ACL was defined
This commit is contained in:
parent
45df2ec553
commit
3255eaa31c
5 changed files with 9 additions and 4 deletions
|
@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
|
||||
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.
|
||||
|
||||
Fixed
|
||||
*****
|
||||
|
||||
- Crash when no ACL were defined
|
||||
|
||||
[0.0.38] - 2023-12-15
|
||||
=====================
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ def build_hash(*args):
|
|||
def default_fields():
|
||||
read = set()
|
||||
write = set()
|
||||
for acl in current_app.config["ACL"].values():
|
||||
for acl in current_app.config.get("ACL", {}).values():
|
||||
if "FILTER" not in acl:
|
||||
read |= set(acl.get("READ", []))
|
||||
write |= set(acl.get("WRITE", []))
|
||||
|
|
|
@ -178,7 +178,7 @@ class User(canaille.core.models.User, LDAPObject):
|
|||
self.read = set()
|
||||
self.write = set()
|
||||
|
||||
for access_group_name, details in current_app.config["ACL"].items():
|
||||
for access_group_name, details in current_app.config.get("ACL", {}).items():
|
||||
filter_ = self.acl_filter_to_ldap_filter(details.get("FILTER"))
|
||||
if not filter_ or (
|
||||
self.id and conn.search_s(self.id, ldap.SCOPE_SUBTREE, filter_)
|
||||
|
|
|
@ -233,7 +233,7 @@ class User(canaille.core.models.User, MemoryModel):
|
|||
self.permissions = set()
|
||||
self.read = set()
|
||||
self.write = set()
|
||||
for access_group_name, details in current_app.config["ACL"].items():
|
||||
for access_group_name, details in current_app.config.get("ACL", {}).items():
|
||||
if self.match_filter(details.get("FILTER")):
|
||||
self.permissions |= set(details.get("PERMISSIONS", []))
|
||||
self.read |= set(details.get("READ", []))
|
||||
|
|
|
@ -168,7 +168,7 @@ class User(canaille.core.models.User, Base, SqlAlchemyModel):
|
|||
self.permissions = set()
|
||||
self.read = set()
|
||||
self.write = set()
|
||||
for access_group_name, details in current_app.config["ACL"].items():
|
||||
for access_group_name, details in current_app.config.get("ACL", {}).items():
|
||||
if self.match_filter(details.get("FILTER")):
|
||||
self.permissions |= set(details.get("PERMISSIONS", []))
|
||||
self.read |= set(details.get("READ", []))
|
||||
|
|
Loading…
Reference in a new issue