summary refs log tree commit diff
path: root/synapse/handlers/auth.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-10-13 10:33:00 +0100
committerMark Haines <mark.haines@matrix.org>2015-10-13 10:33:00 +0100
commitf96b48067065b12654f60a7d8849eebeb5338a73 (patch)
tree1b9edd18e4e8c4f2218756b501292fde1fcb252e /synapse/handlers/auth.py
parentStart spliting out the rooms into joined and invited in v2 sync (diff)
parentMerge pull request #299 from stevenhammerton/sh-cas-required-attribute (diff)
downloadsynapse-f96b48067065b12654f60a7d8849eebeb5338a73.tar.xz
Merge branch 'develop' into markjh/v2_sync_api
Diffstat (limited to 'synapse/handlers/auth.py')
-rw-r--r--synapse/handlers/auth.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py
index 793b3fcd8b..484f719253 100644
--- a/synapse/handlers/auth.py
+++ b/synapse/handlers/auth.py
@@ -296,6 +296,38 @@ class AuthHandler(BaseHandler):
         defer.returnValue((user_id, access_token, refresh_token))
 
     @defer.inlineCallbacks
+    def login_with_cas_user_id(self, user_id):
+        """
+        Authenticates the user with the given user ID,
+        intended to have been captured from a CAS response
+
+        Args:
+            user_id (str): User ID
+        Returns:
+            A tuple of:
+              The user's ID.
+              The access token for the user's session.
+              The refresh token for the user's session.
+        Raises:
+            StoreError if there was a problem storing the token.
+            LoginError if there was an authentication problem.
+        """
+        user_id, ignored = yield self._find_user_id_and_pwd_hash(user_id)
+
+        logger.info("Logging in user %s", user_id)
+        access_token = yield self.issue_access_token(user_id)
+        refresh_token = yield self.issue_refresh_token(user_id)
+        defer.returnValue((user_id, access_token, refresh_token))
+
+    @defer.inlineCallbacks
+    def does_user_exist(self, user_id):
+        try:
+            yield self._find_user_id_and_pwd_hash(user_id)
+            defer.returnValue(True)
+        except LoginError:
+            defer.returnValue(False)
+
+    @defer.inlineCallbacks
     def _find_user_id_and_pwd_hash(self, user_id):
         """Checks to see if a user with the given id exists. Will check case
         insensitively, but will throw if there are multiple inexact matches.