summary refs log tree commit diff
path: root/synapse/handlers/register.py
diff options
context:
space:
mode:
authorMuthu Subramanian <muthu.subramanian.karunanidhi@ericsson.com>2015-07-07 17:40:30 +0530
committerMuthu Subramanian <muthu.subramanian.karunanidhi@ericsson.com>2015-07-08 15:36:54 +0530
commit81682d0f820a6209535267a45ee28b8f66ff7794 (patch)
treef5cda857c38fe8af6291eb58f937f62280232738 /synapse/handlers/register.py
parentOops: underride rule had an identifier with override in it. (diff)
downloadsynapse-81682d0f820a6209535267a45ee28b8f66ff7794.tar.xz
Integrate SAML2 basic authentication - uses pysaml2
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r--synapse/handlers/register.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py
index 7b68585a17..4c6c5e2972 100644
--- a/synapse/handlers/register.py
+++ b/synapse/handlers/register.py
@@ -193,6 +193,36 @@ class RegistrationHandler(BaseHandler):
             logger.info("Valid captcha entered from %s", ip)
 
     @defer.inlineCallbacks
+    def register_saml2(self, localpart):
+        """
+        Registers email_id as SAML2 Based Auth.
+        """
+        if urllib.quote(localpart) != localpart:
+            raise SynapseError(
+                400,
+                "User ID must only contain characters which do not"
+                " require URL encoding."
+                )
+        user = UserID(localpart, self.hs.hostname)
+        user_id = user.to_string()
+
+        yield self.check_user_id_is_valid(user_id)
+        token = self._generate_token(user_id)
+        try:
+            yield self.store.register(
+                user_id=user_id,
+                token=token,
+                password_hash=None
+            )
+            yield self.distributor.fire("registered_user", user)
+        except Exception, e:
+            yield self.store.add_access_token_to_user(user_id, token)
+            # Ignore Registration errors
+            logger.exception(e)
+        defer.returnValue((user_id, token))
+        
+
+    @defer.inlineCallbacks
     def register_email(self, threepidCreds):
         """
         Registers emails with an identity server.