Exemple #1
0
def verify_request( request ):

    config = get_config()
    if 'password' in config:
        password = config['password']

        method = request.method
        uri = request.path
        request_args = {}
        for name in request.arguments:
            request_args[name] = request.arguments[name][0].decode('utf-8')

        #use password directly auth
        if a.get('password') == password:
            return True

        #use password sign auth
        request_time = int(request_args['time'])
        if abs(request_time - time.time()) > 60:
            return False
        
        sign = request_args['sign']
        del request_args['sign']

        sign_right = auth.sign( method, uri, request_args, password, time_stamp = request_args['time'] )['sign']
        print( 'sign_right:',sign_right )

        if sign_right != sign:
            return False

        return True
Exemple #2
0
def verify_request(request):

    config = get_config()
    if 'password' in config:
        password = config['password']

        method = request.method
        uri = request.path
        request_args = {}
        for name in request.arguments:
            request_args[name] = request.arguments[name][0].decode('utf-8')

        #use password directly auth
        if a.get('password') == password:
            return True

        #use password sign auth
        request_time = int(request_args['time'])
        if abs(request_time - time.time()) > 60:
            return False

        sign = request_args['sign']
        del request_args['sign']

        sign_right = auth.sign(method,
                               uri,
                               request_args,
                               password,
                               time_stamp=request_args['time'])['sign']
        print('sign_right:', sign_right)

        if sign_right != sign:
            return False

        return True
Exemple #3
0
    def request_sign(self, method, uri, args):
        
        if self.password != None:
            args = auth.sign( method, uri, args, self.password )

        return args
Exemple #4
0
    def request_sign(self, method, uri, args):

        if self.password != None:
            args = auth.sign(method, uri, args, self.password)

        return args