slack_helper.py 文件源码

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

项目:chatops_slack 作者: DennyZhang 项目源码 文件源码
def verify_slack_username(http_method, api_method, method_acl_userlist):
    user_name = ''
    if http_method == 'GET':
        user_name = request.args.get('user_name', '')
    elif http_method == 'POST':
        user_name = request.values['user_name']
    else:
        raise Exception("Error: unsupported http_method(%s)" % (http_method))

    if "*" in method_acl_userlist:
        super_name_list = method_acl_userlist["*"]
        if user_name in super_name_list:
            return None

    if api_method in method_acl_userlist:
        allowed_user_list = method_acl_userlist[api_method]
        if user_name not in allowed_user_list:
            content = "Error: user(%s) not allowed to call api_method(%s)" % \
                      (user_name, api_method)
            raise Exception(content)

    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号