Dipl. Ing. Péter Varkoly 1 год назад
Родитель
Сommit
e05fbeb950
4 измененных файлов с 8 добавлено и 6 удалено
  1. 1 1
      radicale/auth/__init__.py
  2. 4 4
      radicale/auth/ldap.py
  3. 2 0
      radicale/rights/__init__.py
  4. 1 1
      radicale/rights/from_file.py

+ 1 - 1
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
 

+ 4 - 4
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)

+ 2 - 0
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.
 

+ 1 - 1
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