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
评论列表
文章目录