diff --git a/radicale/auth/__init__.py b/radicale/auth/__init__.py index f15bd020..b4cc7bb5 100644 --- a/radicale/auth/__init__.py +++ b/radicale/auth/__init__.py @@ -52,7 +52,7 @@ def load(configuration: "config.Configuration") -> "BaseAuth": class BaseAuth: - _ldap_groups: set + _ldap_groups: set[str] = set([]) _lc_username: bool _strip_domain: bool diff --git a/radicale/auth/ldap.py b/radicale/auth/ldap.py index 9093fbf0..b536fa68 100644 --- a/radicale/auth/ldap.py +++ b/radicale/auth/ldap.py @@ -35,7 +35,7 @@ class Auth(auth.BaseAuth): _ldap_secret: str _ldap_filter: str _ldap_load_groups: bool - _ldap_version: 3 + _ldap_version: int = 3 def __init__(self, configuration: config.Configuration) -> None: super().__init__(configuration) @@ -81,7 +81,7 @@ class Auth(auth.BaseAuth): conn.protocol_version = 3 conn.set_option(self.ldap.OPT_REFERRALS, 0) conn.simple_bind_s(user_dn, password) - tmp = [] + tmp: list[str] = [] if self._ldap_load_groups: tmp = [] for t in res[0][1]['memberOf']: @@ -143,5 +143,5 @@ class Auth(auth.BaseAuth): In the last step the authentication of the user will be proceeded. """ if self._ldap_version == 2: - return self._login2(self, login, password) - return self._login3(self, login, password) + return self._login2(login, password) + return self._login3(login, password) diff --git a/radicale/rights/__init__.py b/radicale/rights/__init__.py index 1b898659..cc714cea 100644 --- a/radicale/rights/__init__.py +++ b/radicale/rights/__init__.py @@ -57,6 +57,8 @@ def intersect(a: str, b: str) -> str: class BaseRights: + _user_groups: set[str] = set([]) + def __init__(self, configuration: "config.Configuration") -> None: """Initialize BaseRights. diff --git a/radicale/rights/from_file.py b/radicale/rights/from_file.py index 91d487da..03c1799c 100644 --- a/radicale/rights/from_file.py +++ b/radicale/rights/from_file.py @@ -71,7 +71,7 @@ class Rights(rights.BaseRights): collection_pattern = rights_config.get(section, "collection") allowed_groups = rights_config.get(section, "groups", fallback="").split(",") try: - group_match = self._user_groups.intersection(allowed_groups) > 0 + group_match = len(self._user_groups.intersection(allowed_groups)) > 0 except Exception: pass # Use empty format() for harmonized handling of curly braces