def validate_room_jwt(function=None, requires_jamf_configured=True):
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
try:
token = flask.request.headers.get('Authorization').split()[1]
except:
flask.abort(401)
hipchat_room = verify_jwt(token)
if requires_jamf_configured and not hipchat_room.jamf_configured:
message = "You must first configure a Jamf Pro service account to use this feature."
send_notification(hipchat_room.hipchat_token, hipchat_room.hipchat_room_id, message, color='yellow')
flask.abort(400)
return f(hipchat_room, *args, **kwargs)
return wrapper
return decorator(function) if function else decorator
评论列表
文章目录