utilities.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Casper-HC 作者: jamfit 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号