Beispiel #1
0
    def authenticate(self, userstore):
        request_user_id, request_password = \
            utils.get_basic_http_authentication_info()
        stored_user = userstore.get_user(request_user_id)
        if not stored_user:
            # user not found
            raise Exception(
                'authentication of user "{0}" failed'.format(request_user_id))

        verified = self.crypt_ctx.verify(request_password,
                                         stored_user['password'])
        if not verified:
            # wrong password
            raise Exception(
                'authentication of user "{0}" failed'.format(request_user_id))

        return stored_user['username']
Beispiel #2
0
    def authenticate(self, userstore):
        request_user_id, request_password = \
            utils.get_basic_http_authentication_info()
        stored_user = userstore.get_user(request_user_id)
        if not stored_user:
            # user not found
            raise Exception('authentication of user "{0}" failed'.
                            format(request_user_id))

        verified = self.crypt_ctx.verify(request_password,
                                         stored_user['password'])
        if not verified:
            # wrong password
            raise Exception('authentication of user "{0}" failed'.
                            format(request_user_id))

        return stored_user['username']
    def authenticate(self, userstore=None):
        username, password = utils.get_basic_http_authentication_info()
        # initialize connection to the LDAP server
        try:
            conn = ldap.initialize(self.directory_url)
        except Exception as e:
            raise Exception(
                'Failed to initialize LDAP connection to {0}; {1}'.format(
                    self.directory_url, str(e)))

        # trying to bind with the given user and password
        try:
            conn.bind_s(username, password)
            return username
        except Exception as e:
            raise Exception('Failed to authenticate user {0}; {1}'.format(
                username, str(e)))
        finally:
            conn.unbind_s()
    def authenticate(self, userstore=None):
        username, password = utils.get_basic_http_authentication_info()
        # initialize connection to the LDAP server
        try:
            conn = ldap.initialize(self.directory_url)
        except Exception as e:
            raise Exception(
                'Failed to initialize LDAP connection to {0}; {1}'
                .format(self.directory_url, str(e)))

        # trying to bind with the given user and password
        try:
            conn.bind_s(username, password)
            return username
        except Exception as e:
            raise Exception(
                'Failed to authenticate user {0}; {1}'
                .format(username, str(e)))
        finally:
            conn.unbind_s()
 def get_creds_from_request():
     return utils.get_basic_http_authentication_info()