Commit eb25c449 authored by wang.wenrong's avatar wang.wenrong

debug_login_auth

parent d3b3699e
Subproject commit 05cfad9387871294a0215dabeccad37adbc487e3 Subproject commit a878a1f82788f11deea04f8e64f668a83ed3a449
...@@ -21,7 +21,7 @@ def authorized(): ...@@ -21,7 +21,7 @@ def authorized():
# run some method that checks the request # run some method that checks the request
# for the client's authorization status # for the client's authorization status
is_authorized = await user_product_auth.check_user_auth(request) is_authorized = await user_product_auth.check_user_auth(request)
if is_authorized: if is_authorized:
# the user is authorized. # the user is authorized.
# run the handler method and return the response # run the handler method and return the response
...@@ -30,9 +30,9 @@ def authorized(): ...@@ -30,9 +30,9 @@ def authorized():
else: else:
# the user is not authorized. # the user is not authorized.
return json({'status': 'not_authorized'}, 403) return json({'status': 'not_authorized'}, 403)
return decorated_function return decorated_function
return decorator return decorator
...@@ -42,62 +42,69 @@ async def get_test(request): ...@@ -42,62 +42,69 @@ async def get_test(request):
def is_need_verify(path): def is_need_verify(path):
# return False
if SETTING.debug_mode == 1:
return False
if "swagger" in path:
return False
log.info("is_or_not_need_verify path:%s", path) log.info("is_or_not_need_verify path:%s", path)
if "swagger" in path: if "swagger" in path:
return False return False
if re.match("^/unify-api/auth/?$", path): if re.match("^/unify-api/auth/?$", path):
log.info("auth not need verify") log.info("auth not need verify")
return False return False
if re.match("^/unify-api/upgrade/?", path): if re.match("^/unify-api/upgrade/?", path):
log.info("upgrade device not need verify") log.info("upgrade device not need verify")
return False return False
if re.match("^/unify-api/uassistant/?", path): if re.match("^/unify-api/uassistant/?", path):
log.info("uassistant not need verify") log.info("uassistant not need verify")
return False return False
if re.match("^/unify-api/device-cloud/?", path): if re.match("^/unify-api/device-cloud/?", path):
log.info("device_cloud not need verify") log.info("device_cloud not need verify")
return False return False
if re.match("^/unify-api/users/current-user-info/send-sms?", path): if re.match("^/unify-api/users/current-user-info/send-sms?", path):
log.info("send-sms not need verify") log.info("send-sms not need verify")
return False return False
if re.match("^/unify-api/users/current-user-info/save-userinfo?", path): if re.match("^/unify-api/users/current-user-info/save-userinfo?", path):
log.info("save-userinfo not need verify") log.info("save-userinfo not need verify")
return False return False
if re.match("^/unify-api/users/current-user-info/auth-phone?", path): if re.match("^/unify-api/users/current-user-info/auth-phone?", path):
log.info("auth-phone not need verify") log.info("auth-phone not need verify")
return False return False
if re.match("^/unify-api/users/current-user-info/back-password?", path): if re.match("^/unify-api/users/current-user-info/back-password?", path):
log.info("back-password not need verify") log.info("back-password not need verify")
return False return False
if re.match("^/unify-api/users/current-user-info/update-password?", path): if re.match("^/unify-api/users/current-user-info/update-password?", path):
log.info("update-password not need verify") log.info("update-password not need verify")
return False return False
if re.match("^/api/common/wechat/mp", path): if re.match("^/api/common/wechat/mp", path):
log.info("/api/common/wechat/mp not need verify") log.info("/api/common/wechat/mp not need verify")
return False return False
if re.search("/qk-website", path): if re.search("/qk-website", path):
log.info(f"{path} not need verify") log.info(f"{path} not need verify")
return False return False
# if re.match("^/unify-api/users/logout/user-logout/?$", path): # if re.match("^/unify-api/users/logout/user-logout/?$", path):
# log.info("logout not need verify") # log.info("logout not need verify")
# return False # return False
return True return True
async def auth_verify(request): async def auth_verify(request):
if SETTING.debug_mode == 1:
return False
path = request.path path = request.path
if is_need_verify(path): if is_need_verify(path):
token = request.token token = request.token
...@@ -136,6 +143,10 @@ async def auth_verify(request): ...@@ -136,6 +143,10 @@ async def auth_verify(request):
def is_need_auth_verify_cid(path): def is_need_auth_verify_cid(path):
if SETTING.debug_mode == 1:
return False
if "swagger" in path:
return False
if re.match("^/unify-api/auth/", path): if re.match("^/unify-api/auth/", path):
return False return False
if re.match("^/api/common/wechat/mp", path): if re.match("^/api/common/wechat/mp", path):
...@@ -148,6 +159,8 @@ def is_need_auth_verify_cid(path): ...@@ -148,6 +159,8 @@ def is_need_auth_verify_cid(path):
async def auth_verify_cid(request): async def auth_verify_cid(request):
"""增加工厂权限校验""" """增加工厂权限校验"""
if SETTING.debug_mode == 1:
return False
path = request.path path = request.path
# if not re.match("^/unify-api/auth/?$", path): # if not re.match("^/unify-api/auth/?$", path):
if is_need_auth_verify_cid(path): if is_need_auth_verify_cid(path):
...@@ -191,7 +204,7 @@ async def auth_verify_cid(request): ...@@ -191,7 +204,7 @@ async def auth_verify_cid(request):
# if cid_info: # if cid_info:
# cid_res_list = [int(cid) for cid in cid_info.get("product")] # cid_res_list = [int(cid) for cid in cid_info.get("product")]
# else: # else:
# cid_res_list = await get_cids(user_id, product) # cid_res_list = await get_cids(user_id, product)
# 2.3 参数中的cid_args # 2.3 参数中的cid_args
cid_args = None cid_args = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment