Ejemplo n.º 1
0
    def requestAvatarId(self, c):
        creds = credentials.IUsernamePassword(c, None)

        if creds is not None:
            locks = []
            pool = HTTPConnectionPool(reactor, persistent=False)
            pool.cachedConnectionTimeout = self.timeout
            if self.max_concurrency:
                pool.persistent = True
                pool.maxPersistentPerHost = self.max_concurrency
                locks.append(defer.DeferredSemaphore(self.max_concurrency))

            if self.global_max_concurrency:
                locks.append(
                    defer.DeferredSemaphore(self.global_max_concurrency))

            conn = ThrottledSwiftConnection(locks,
                                            self.auth_url,
                                            creds.username,
                                            creds.password,
                                            pool=pool,
                                            extra_headers=self.extra_headers,
                                            verbose=self.verbose)
            conn.user_agent = USER_AGENT

            d = conn.authenticate()
            d.addCallback(self._after_auth, conn)
            d.addErrback(eb_failed_auth)
            return d
        return defer.fail(error.UnauthorizedLogin())
Ejemplo n.º 2
0
    def requestAvatarId(self, c):
        up = credentials.IUsernamePassword(c, None)

        client = self.userbase.authuser(up.username, up.password)

        if client:
            return defer.succeed(client)
        else:
            return defer.fail(error.UnauthorizedLogin())
Ejemplo n.º 3
0
 def requestAvatarId(self, c):
     try:
         u, p = self.getUser(c.username)
     except KeyError:
         return defer.fail(error.UnauthorizedLogin())
     else:
         up = credentials.IUsernamePassword(c, None)
         if self.hash:
             if up is not None:
                 h = self.hash(up.username, up.password, p)
                 if h == p:
                     return defer.succeed(u)
             return defer.fail(error.UnauthorizedLogin())
         else:
             return defer.maybeDeferred(c.checkPassword, p).addCallback(
                 self._cbPasswordMatch, u)
Ejemplo n.º 4
0
Archivo: auth.py Proyecto: allo-/otfbot
 def _checkpw(self, user, creds):
     up = credentials.IUsernamePassword(creds)
     if user.checkPasswd(up.password):
         return defer.succeed(user.name)
     else:
         return defer.fail(error.UnauthorizedLogin())