summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorChristoph Witzany <christoph@web.crofting.com>2016-04-05 17:26:37 +0200
committerChristoph Witzany <christoph@web.crofting.com>2016-04-06 18:23:45 +0200
commit3d95405e5fe4ef1b795dbfd63a3532cac65b8cd4 (patch)
tree8af4ede163017465eb5781159f66c31f8afaf9e4 /synapse/config
parentMerge pull request #702 from matrix-org/markjh/slaveII (diff)
downloadsynapse-3d95405e5fe4ef1b795dbfd63a3532cac65b8cd4.tar.xz
Introduce LDAP authentication
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/homeserver.py3
-rw-r--r--synapse/config/ldap.py48
2 files changed, 50 insertions, 1 deletions
diff --git a/synapse/config/homeserver.py b/synapse/config/homeserver.py
index acf74c8761..9a80ac39ec 100644
--- a/synapse/config/homeserver.py
+++ b/synapse/config/homeserver.py
@@ -30,13 +30,14 @@ from .saml2 import SAML2Config
 from .cas import CasConfig
 from .password import PasswordConfig
 from .jwt import JWTConfig
+from .ldap import LDAPConfig
 
 
 class HomeServerConfig(TlsConfig, ServerConfig, DatabaseConfig, LoggingConfig,
                        RatelimitConfig, ContentRepositoryConfig, CaptchaConfig,
                        VoipConfig, RegistrationConfig, MetricsConfig, ApiConfig,
                        AppServiceConfig, KeyConfig, SAML2Config, CasConfig,
-                       JWTConfig, PasswordConfig,):
+                       JWTConfig, LDAPConfig, PasswordConfig,):
     pass
 
 
diff --git a/synapse/config/ldap.py b/synapse/config/ldap.py
new file mode 100644
index 0000000000..86528139e2
--- /dev/null
+++ b/synapse/config/ldap.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+# Copyright 2015 Niklas Riekenbrauck
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from ._base import Config
+
+
+class LDAPConfig(Config):
+    def read_config(self, config):
+        ldap_config = config.get("ldap_config", None)
+        if ldap_config:
+            self.ldap_enabled = ldap_config.get("enabled", False)
+            self.ldap_server = ldap_config["server"]
+            self.ldap_port = ldap_config["port"]
+            self.ldap_search_base = ldap_config["search_base"]
+            self.ldap_search_property = ldap_config["search_property"]
+            self.ldap_email_property = ldap_config["email_property"]
+            self.ldap_full_name_property = ldap_config["full_name_property"]
+        else:
+            self.ldap_enabled = False
+            self.ldap_server = None
+            self.ldap_port = None
+            self.ldap_search_base = None
+            self.ldap_search_property = None
+            self.ldap_email_property = None
+            self.ldap_full_name_property = None
+
+    def default_config(self, **kwargs):
+        return """\
+        # ldap_config:
+        #    server: "ldap://localhost"
+        #    port: 389
+        #    search_base: "ou=Users,dc=example,dc=com"
+        #    search_property: "cn"
+        #    email_property: "email"
+        #    full_name_property: "givenName"
+        """