Esempio n. 1
0
 def identify(self, request):
     token = self.get_token(request)
     if token is None or not self.token_is_valid(
         token, self.encryption_key
     ):
         return NO_IDENTITY
     return Identity('Testuser')
Esempio n. 2
0
 def log_in(self, request):
     response = Response()
     generic.remember_identity(response, request,
                               Identity(userid='user',
                                        payload='Amazing'),
                               lookup=request.lookup)
     return response
Esempio n. 3
0
 def default(self, request):
     # will not actually do anything as it's a no-op for basic
     # auth, but at least won't crash
     response = Response()
     generic.remember_identity(response, request, Identity('foo'),
                               lookup=request.lookup)
     return response
Esempio n. 4
0
    def identify(self, request):
        """Establish claimed identity using request.

        :param request: Request to extract identity information from.
        :type request: :class:`morepath.Request`.
        :returns: :class:`morepath.security.Identity` instance.
        """
        if Users.no_auth:
            return Identity(userid='anonymous', sessionId='')

        try:
            authorization = request.authorization
        except ValueError:
            return None
        if authorization is None:
            return None
        authtype, params = authorization
        auth = parse_auth(authtype, params)
        if auth is None:
            return None
        return Identity(userid=auth.username, sessionId=auth.sessionId)
Esempio n. 5
0
 def identify(self, request):
     return Identity('testidentity')
Esempio n. 6
0
 def identify(self, request):
     data = request.cookies.get('dumb_id', None)
     if data is None:
         return NO_IDENTITY
     data = json.loads(base64.b64decode(data).decode())
     return Identity(**data)