Last active
April 6, 2020 12:33
-
-
Save zaghaghi/ba5e38beaacf244ca659f6a18bcbe9f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import request, abort, Response | |
from functools import wraps | |
def _realy_check_role_is_ok(roles, methods): | |
# all conditions will be checked here. | |
return True | |
def check_role(roles, methods): | |
def inner_function(function): | |
@wraps(function) | |
def wrapper(*args, **kwargs): | |
if _realy_check_roles_is_ok(roles, methods): | |
return function(*args, **kwargs) | |
return Response('Unauthorized Access', 401) # or abort(401) | |
return wrapper | |
return inner_function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment