diff options
author | B. Stack <bgstack15@gmail.com> | 2022-05-15 15:13:47 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-05-15 15:13:47 -0400 |
commit | d26c3d9c79232aa5c633cd727716d7cf5ee4d88f (patch) | |
tree | 7adc5edf81dfff2026d32e21ec948a632b299a2a | |
parent | Exposed missing configuration options and reverted ldap logic to bring back a... (diff) | |
download | radicale_auth_ldap-d26c3d9c79232aa5c633cd727716d7cf5ee4d88f.tar.gz radicale_auth_ldap-d26c3d9c79232aa5c633cd727716d7cf5ee4d88f.tar.bz2 radicale_auth_ldap-d26c3d9c79232aa5c633cd727716d7cf5ee4d88f.zip |
add multi-server support from holczert
https://github.com/holczert/radicale-auth-ldap/commits/master
-rw-r--r-- | radicale_auth_ldap/__init__.py | 14 | ||||
-rw-r--r-- | setup.py | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/radicale_auth_ldap/__init__.py b/radicale_auth_ldap/__init__.py index 4a3b6dc..6a86c2c 100644 --- a/radicale_auth_ldap/__init__.py +++ b/radicale_auth_ldap/__init__.py @@ -39,7 +39,7 @@ PLUGIN_CONFIG_SCHEMA = { "auth": { "ldap_url": { "value": "ldap://localhost:389", - "help": "LDAP server URL, with protocol and port", + "help": "LDAP server URL, with protocol and port (multiple servers can be separated by spaces)", "type": str }, "ldap_base": { @@ -140,8 +140,16 @@ class Auth(BaseAuth): def login(self, login, password): """Check if ``login``/``password`` couple is valid.""" - SERVER = ldap3.Server(self.ldap_url) - + servers = self.configuration.get("auth", "ldap_url") + if ' ' in servers: # Handle for multiple LDAP server defined in ldap_url with space separation + servers = servers.split(' ') + logger.debug("Multiple servers: %s" % servers) + SERVER = ldap3.ServerPool(None) + for s in servers: + SERVER.add(ldap3.Server(s)) + else: # only one server is defined + logger.debug("Single server: %s" % servers) + SERVER = ldap3.Server(servers) if self.ldap_binddn and self.ldap_password: conn = ldap3.Connection(SERVER, self.ldap_binddn, self.ldap_password) else: @@ -4,7 +4,7 @@ from distutils.core import setup setup( name="radicale-auth-ldap", - version="0.2", + version="0.3", description="LDAP Authentication Plugin for Radicale 3", author="Raoul Thill", license="GNU GPL v3", |