Example #1
0
 def doauth(request):
     un = username_from_path(request.path)
     rows = server.send('db',
         'SELECT id, password FROM auth_user WHERE username = %s', [un]).wait()
     if rows:
         return User(rows[0][0], un, rows[0][1])
     raise UnauthenticatedUser()
Example #2
0
    def doauth(request):
        username = username_from_path(request.path)
        if 'woome-sig' in request.headers:
            sig = request.headers['woome-sig']
            # get username
            h = hmac.new(secret_key, request.body, sha1)
            h.update(username)
            if h.hexdigest() == sig:
                request.environ['woome.signed'] = True
                return urlauth(request)
            else:
                raise UnauthenticatedUser()

        user = mcauth(request)
        if user.username != username:
            raise UnauthenticatedUser()
        return user