Exemplo n.º 1
0
    def inner(*args, **kwargs):
        if not len(args):
            raise custom_exceptions.UnauthorizedException("Missing password")

        if settings.ADMIN_RESTRICT_INTERFACE != None:
            ip = args[0].connection_ref()._get_ip()
            if ip not in settings.ADMIN_RESTRICT_INTERFACE:
                raise custom_exceptions.UnauthorizedException(
                    "RPC call not allowed from your IP")

        if not settings.ADMIN_PASSWORD:
            raise custom_exceptions.UnauthorizedException(
                "Admin password not set, RPC call disabled")

        (password, args) = (args[1], [
            args[0],
        ] + list(args[2:]))

        dlog.debug("Given Password: %s" % password)
        dlog.debug("Admin Password: %s" % settings.ADMIN_PASSWORD)

        if password != settings.ADMIN_PASSWORD:
            raise custom_exceptions.UnauthorizedException("Wrong password")

        return func(*args, **kwargs)
Exemplo n.º 2
0
    def inner(*args, **kwargs):
        if not len(args):
            raise custom_exceptions.UnauthorizedException("Missing password")

        if settings.ADMIN_RESTRICT_INTERFACE != None:
            ip = args[0].connection_ref()._get_ip()
            if settings.ADMIN_RESTRICT_INTERFACE != ip:
                raise custom_exceptions.UnauthorizedException("RPC call not allowed from your IP")
            
        if not settings.ADMIN_PASSWORD_SHA256:
            raise custom_exceptions.UnauthorizedException("Admin password not set, RPC call disabled")

        (password, args) = (args[1], [args[0],] + list(args[2:]))

        if hashlib.sha256(password).hexdigest() != settings.ADMIN_PASSWORD_SHA256:
            raise custom_exceptions.UnauthorizedException("Wrong password")

        return func(*args, **kwargs)