Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
U
unify_api2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chaonan
unify_api2
Commits
d3b3699e
Commit
d3b3699e
authored
Apr 03, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整为公共登录
parent
04552a63
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
26 deletions
+43
-26
login_auth.py
unify_api/modules/common/procedures/login_auth.py
+20
-19
login_pds.py
unify_api/modules/users/procedures/login_pds.py
+9
-3
auth.py
unify_api/modules/users/views/auth.py
+1
-1
current_user_info.py
unify_api/modules/users/views/current_user_info.py
+2
-1
logout.py
unify_api/modules/users/views/logout.py
+6
-1
recive_refresh_token.py
unify_api/modules/users/views/recive_refresh_token.py
+5
-1
No files found.
unify_api/modules/common/procedures/login_auth.py
View file @
d3b3699e
...
...
@@ -21,7 +21,7 @@ def authorized():
# run some method that checks the request
# for the client's authorization status
is_authorized
=
await
user_product_auth
.
check_user_auth
(
request
)
if
is_authorized
:
# the user is authorized.
# run the handler method and return the response
...
...
@@ -30,9 +30,9 @@ def authorized():
else
:
# the user is not authorized.
return
json
({
'status'
:
'not_authorized'
},
403
)
return
decorated_function
return
decorator
...
...
@@ -46,54 +46,54 @@ def is_need_verify(path):
log
.
info
(
"is_or_not_need_verify path:
%
s"
,
path
)
if
"swagger"
in
path
:
return
False
if
re
.
match
(
"^/unify-api/auth/?$"
,
path
):
log
.
info
(
"auth not need verify"
)
return
False
if
re
.
match
(
"^/unify-api/upgrade/?"
,
path
):
log
.
info
(
"upgrade device not need verify"
)
return
False
if
re
.
match
(
"^/unify-api/uassistant/?"
,
path
):
log
.
info
(
"uassistant not need verify"
)
return
False
if
re
.
match
(
"^/unify-api/device-cloud/?"
,
path
):
log
.
info
(
"device_cloud not need verify"
)
return
False
if
re
.
match
(
"^/unify-api/users/current-user-info/send-sms?"
,
path
):
log
.
info
(
"send-sms not need verify"
)
return
False
if
re
.
match
(
"^/unify-api/users/current-user-info/save-userinfo?"
,
path
):
log
.
info
(
"save-userinfo not need verify"
)
return
False
if
re
.
match
(
"^/unify-api/users/current-user-info/auth-phone?"
,
path
):
log
.
info
(
"auth-phone not need verify"
)
return
False
if
re
.
match
(
"^/unify-api/users/current-user-info/back-password?"
,
path
):
log
.
info
(
"back-password not need verify"
)
return
False
if
re
.
match
(
"^/unify-api/users/current-user-info/update-password?"
,
path
):
log
.
info
(
"update-password not need verify"
)
return
False
if
re
.
match
(
"^/api/common/wechat/mp"
,
path
):
log
.
info
(
"/api/common/wechat/mp not need verify"
)
return
False
if
re
.
search
(
"/qk-website"
,
path
):
log
.
info
(
f
"{path} not need verify"
)
return
False
# if re.match("^/unify-api/users/logout/user-logout/?$", path):
# log.info("logout not need verify")
# return False
return
True
...
...
@@ -119,11 +119,12 @@ async def auth_verify(request):
# 直接将请求转发到auth
resp_str
,
status
=
await
AioHttpUtils
()
.
post
(
SETTING
.
verify_url
,
data
=
{},
data
=
{
"db"
:
SETTING
.
mysql_db
},
timeout
=
50
,
headers
=
{
"Authorization"
:
f
"Bearer {token}"
}
)
log
.
info
(
f
"request auth_url resp_str={resp_str} {type(resp_str)} status={status}"
)
log
.
info
(
f
"request auth_url resp_str={resp_str} {type(resp_str)} status={status}"
)
if
status
==
200
:
payload
=
ujson
.
loads
(
resp_str
)
setattr
(
request
.
ctx
,
"user_id"
,
payload
[
"user_id"
])
...
...
@@ -178,7 +179,7 @@ async def auth_verify_cid(request):
# 3. 如果参数中包含cid或者cids,cid_list
if
cid
or
cids
or
cid_list
:
user_id
=
request
.
ctx
.
user_id
proxy_id
=
args
.
get
(
"proxy_id"
)
# 2.2 从mysql获取
if
proxy_id
:
...
...
@@ -190,7 +191,7 @@ async def auth_verify_cid(request):
# if cid_info:
# cid_res_list = [int(cid) for cid in cid_info.get("product")]
# else:
# cid_res_list = await get_cids(user_id, product)
# 2.3 参数中的cid_args
cid_args
=
None
...
...
unify_api/modules/users/procedures/login_pds.py
View file @
d3b3699e
...
...
@@ -20,7 +20,8 @@ async def wechat_login(args, host):
"user_info"
:
args
.
get
(
"user_info"
),
"client_name"
:
args
.
get
(
"client_name"
),
"host"
:
host
,
"product"
:
args
.
get
(
"product"
)
"product"
:
args
.
get
(
"product"
),
"db"
:
SETTING
.
mysql_db
}
try
:
...
...
@@ -45,7 +46,8 @@ async def app_login(args, host):
"client_name"
:
args
.
get
(
"client_name"
),
"unionid"
:
args
.
get
(
"unionid"
),
"host"
:
host
,
"product"
:
args
.
get
(
"product"
)
"product"
:
args
.
get
(
"product"
),
"db"
:
SETTING
.
mysql_db
}
if
not
args
.
get
(
"unionid"
):
return
401
,
{
"code"
:
40001
,
"data"
:
None
,
"message"
:
"unionid is None"
}
...
...
@@ -72,6 +74,7 @@ async def web_login(args, host):
"code"
:
args
[
'code'
],
"client_name"
:
args
.
get
(
"client_name"
),
"host"
:
host
,
"db"
:
SETTING
.
mysql_db
}
try
:
# auth_url = "http://0.0.0.0:9000/unify-api/auth"
...
...
@@ -110,7 +113,8 @@ async def third_login(args, host):
"password"
:
password
,
"client_name"
:
args
.
get
(
"client_name"
),
"host"
:
host
,
"product"
:
args
.
get
(
"product"
)
"product"
:
args
.
get
(
"product"
),
"db"
:
SETTING
.
mysql_db
}
try
:
log
.
info
(
...
...
@@ -148,6 +152,7 @@ async def web_third_login(args, host):
"password"
:
password
,
"client_name"
:
args
.
get
(
"client_name"
),
"host"
:
host
,
"db"
:
SETTING
.
mysql_db
}
try
:
log
.
info
(
...
...
@@ -197,6 +202,7 @@ async def validation_login(args, host):
"user_id"
:
user
[
"user_id"
],
"client_name"
:
client_name
,
"host"
:
host
,
"db"
:
SETTING
.
mysql_db
}
try
:
log
.
info
(
SETTING
.
auth_url
,
f
"request auth_url={SETTING.auth_url} "
...
...
unify_api/modules/users/views/auth.py
View file @
d3b3699e
...
...
@@ -28,7 +28,7 @@ class AuthView(HTTPMethodView):
resp_str
,
status_code
=
await
AioHttpUtils
()
.
post
(
SETTING
.
auth_url
,
{
"user_name"
:
"balabala"
,
"password"
:
"balabala"
,
"client_name"
:
client_name
},
"client_name"
:
client_name
,
"db"
:
SETTING
.
mysql_db
},
timeout
=
50
,
)
print
(
f
"resp_str = {resp_str} status={status_code}"
)
...
...
unify_api/modules/users/views/current_user_info.py
View file @
d3b3699e
...
...
@@ -152,7 +152,8 @@ async def post_save_userinfo(request, body: SaveUserReq):
"phone"
:
phone
,
"client_name"
:
"validation"
,
"host"
:
request
.
host
,
"user_id"
:
user
[
"user_id"
]
"user_id"
:
user
[
"user_id"
],
"db"
:
SETTING
.
mysql_db
}
resp_str
,
status
=
await
AioHttpUtils
()
.
post
(
SETTING
.
auth_url
,
...
...
unify_api/modules/users/views/logout.py
View file @
d3b3699e
...
...
@@ -54,8 +54,13 @@ async def get_user_logout(request) -> Success:
# await jwt_utils.store_token_blacklist(token)
try
:
log
.
info
(
f
"request logout_url={SETTING.logout_url}"
)
resp_str
,
status
=
await
AioHttpUtils
()
.
get
(
request_body
=
{
"db"
:
SETTING
.
mysql_db
}
resp_str
,
status
=
await
AioHttpUtils
()
.
post
(
SETTING
.
logout_url
,
request_body
,
timeout
=
50
,
headers
=
{
"Authorization"
:
f
"Bearer {token}"
},
)
log
.
info
(
f
"request auth_url resp_str={resp_str} status={status}"
)
...
...
unify_api/modules/users/views/recive_refresh_token.py
View file @
d3b3699e
...
...
@@ -21,7 +21,11 @@ class RefreshView(HTTPMethodView):
status
=
200
)
resp
,
status_code
=
await
AioHttpUtils
()
.
post
(
SETTING
.
refresh_token_url
,
{
"refresh_token"
:
refresh_token
,
"client_name"
:
client_name
},
{
"refresh_token"
:
refresh_token
,
"client_name"
:
client_name
,
"db"
:
SETTING
.
mysql_db
},
timeout
=
50
,
headers
=
{
"Authorization"
:
f
"Bearer {token}"
}
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment