Esempio n. 1
0
 def authenticate(self, request):
     a = ILoginPassword(request, None)
     if a is not None:
         login = a.getLogin()
         if login is not None:
             p = self.__principalsByLogin.get(login, None)
             if p is not None:
                 password = a.getPassword()
                 if p.validate(password):
                     return p
     return None
 def authenticate(self, request):
     a = ILoginPassword(request, None)
     if a is not None:
         login = a.getLogin()
         if login is not None:
             # The login will be in bytes, but the registry stores them
             # using strings.
             p = self.__principalsByLogin.get(login.decode(), None)
             if p is not None:
                 password = a.getPassword()
                 if p.validate(password):
                     return p
     return None
Esempio n. 3
0
    def authenticate(self, request):
        """Identify a principal for request.

        Retrieves the username and password from the session.
        """
        session = ISession(request)[self.session_name]
        if 'username' in session and 'password' in session:
            if self._checkHashedPassword(session['username'], session['password']):
                self.restorePOSTData(request)
                return self.getPrincipal('sb.person.' + session['username'])

        # Try HTTP basic too
        creds = ILoginPassword(request, None)
        if creds:
            login = creds.getLogin()
            if self._checkPlainTextPassword(login, creds.getPassword()):
                return self.getPrincipal('sb.person.' + login)