Пример #1
0
    def master_cmd_failauth(self, args):
        auth_id = int(args[1])
        context = self.pending_auths.get(auth_id, None)
        if context is None: return None

        exception = AuthFailedException(
            "Master server refused authentication attempt.")
        return self._auth_failed(context, exception)
Пример #2
0
 def answer_challenge(self, auth_domain, auth_id, answer):
     auth_service = self._get_auth_service(auth_domain)
     if auth_service is None:
         return defer.fail(
             AuthFailedException(
                 "Could not determine which master server to send your request to."
             ))
     return auth_service.answer_challenge(auth_domain, auth_id, answer)
Пример #3
0
 def try_authenticate(self, auth_domain, auth_name):
     auth_service = self._get_auth_service(auth_domain)
     if auth_service is None:
         return defer.fail(
             AuthFailedException(
                 "Could not determine which master server to send your request to."
             ))
     return auth_service.try_authenticate(auth_domain, auth_name)
Пример #4
0
    def answer_challenge(self, auth_id, answer):
        context = self.pending_auths.get(auth_id, None)
        if context is None: return None

        if context.state is not authentication_states.PENDING_ANSWER:
            logger.error(
                "Answer challenge called when another state was expected.")
            exception = AuthFailedException(
                "Master server client protocol error.")
            return self._auth_failed(context, exception)

        if self.active_connection is None:
            return defer.fail(
                AuthFailedException("No Master server connection."))

        self.active_connection.send_confauth(auth_id, answer)
        context.state = authentication_states.PENDING_RESPONSE
        context.deferred = defer.Deferred()
        return context.deferred
Пример #5
0
    def master_cmd_succauth(self, args):
        auth_id = int(args[1])
        context = self.pending_auths.get(auth_id, None)
        if context is None: return None

        if context.state is not authentication_states.PENDING_RESPONSE:
            logger.error(
                "Master server sent authentication success when another state was expected."
            )
            exception = AuthFailedException("Master server protocol error.")
            return self._auth_failed(context, exception)

        self._auth_succeeded(context)
Пример #6
0
    def try_auth(self, auth_domain, authname):
        logger.debug(
            "Attempting client auth request; authname = {!r}".format(authname))

        if self.active_connection is None:
            return defer.fail(
                AuthFailedException("No Master server connection."))

        context = AuthenticationContext(next(self._auth_id), auth_domain,
                                        authname)
        self.active_connection.send_reqauth(context.auth_id, context.auth_name)
        self.pending_auths[context.auth_id] = context
        context.timeout_deferred = self.clock.callLater(
            5, self._auth_timeout, context)
        return context.deferred
Пример #7
0
    def master_cmd_chalauth(self, args):
        auth_id = int(args[1])
        context = self.pending_auths.get(auth_id, None)
        if context is None: return None

        if context.state is not authentication_states.PENDING_CHALLENGE:
            logger.error(
                "Master server sent challenge when another state was expected."
            )
            exception = AuthFailedException("Master server protocol error.")
            return self._auth_failed(context, exception)

        challenge = args[2]

        if len(challenge) != AUTHCHALLEN:
            logger.error(
                "Master server sent challenge with an invalid length of {}.".
                format(len(challenge)))
            return self._auth_failed(
                context, AuthFailedException("Master server protocol error."))

        context.state = authentication_states.PENDING_ANSWER
        auth_challenge = AuthChallenge(auth_id, context.auth_domain, challenge)
        context.deferred.callback(auth_challenge)
Пример #8
0
 def _auth_failed(self, context, exception=None):
     exception = exception or AuthFailedException("Authentication failed.")
     if not context.deferred.called:
         context.deferred.errback(exception)
     self._auth_finished(context)
Пример #9
0
 def _auth_timeout(self, context):
     self._auth_failed(context,
                       AuthFailedException("Authentication timed out."))
Пример #10
0
 def answer_challenge(self, auth_domain, auth_id, answer):
     return defer.fail(
         AuthFailedException(
             "Could not determine which master server to send your request to."
         ))
Пример #11
0
 def try_authenticate(self, auth_domain, auth_name):
     return defer.fail(
         AuthFailedException(
             "Could not determine which master server to send your request to."
         ))