Skip to content

Check incoming requests for permissions #16

Description

@mdevrees

Some routes are not open for everybody, in the case of roles and permissions endpoints we need the system to check the current users' permissions to actually check if they are allowed to perform the requested operation.

Dev notes:
create a new decorator function which checks the current users' permissions for a specific required permission which should come with the decorated function

current example:

@jwt_required
def get(self):
    schema = UserSchema(many=True)
    query = User.query
    return paginate(query, schema)

required example:

@jwt_required
@permission_required("LOGIN_GET_USER")
def get(self):
    schema = UserSchema(many=True)
    query = User.query
    return paginate(query, schema)

def permission_required(fn, **args):
pass # implement function here

dev notes:
https://www.artima.com/weblogs/viewpost.jsp?thread=240845#decorator-functions-with-decorator-arguments

def decoratorFunctionWithArguments(arg1, arg2, arg3):
    def wrap(f):
        print "Inside wrap()"
        def wrapped_f(*args):
            print "Inside wrapped_f()"
            print "Decorator arguments:", arg1, arg2, arg3
            f(*args)
            print "After f(*args)"
        return wrapped_f
    return wrap

@decoratorFunctionWithArguments("hello", "world", 42)
def sayHello(a1, a2, a3, a4):
    print 'sayHello arguments:', a1, a2, a3, a4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions