diff options
author | Erik Johnston <erik@matrix.org> | 2015-07-10 10:25:56 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-07-10 10:25:56 +0100 |
commit | 9158ad1abb8da17a0f463b15e584eb264cb58250 (patch) | |
tree | c835aa4d875cb6fcd493e76edfd2a10cbf4b4e4a /synapse/handlers/register.py | |
parent | We don't want semicolons. (diff) | |
parent | Make SAML2 optional and add some references/comments (diff) | |
download | synapse-9158ad1abb8da17a0f463b15e584eb264cb58250.tar.xz |
Merge pull request #201 from EricssonResearch/msba/saml2-develop
Integrate SAML2 basic authentication - uses pysaml2
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r-- | synapse/handlers/register.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index 7b68585a17..a1288b4252 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -193,6 +193,35 @@ 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. |