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
Show 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
...
@@ -119,11 +119,12 @@ async def auth_verify(request):
...
@@ -119,11 +119,12 @@ async def auth_verify(request):
# 直接将请求转发到auth
# 直接将请求转发到auth
resp_str
,
status
=
await
AioHttpUtils
()
.
post
(
resp_str
,
status
=
await
AioHttpUtils
()
.
post
(
SETTING
.
verify_url
,
SETTING
.
verify_url
,
data
=
{},
data
=
{
"db"
:
SETTING
.
mysql_db
},
timeout
=
50
,
timeout
=
50
,
headers
=
{
"Authorization"
:
f
"Bearer {token}"
}
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
:
if
status
==
200
:
payload
=
ujson
.
loads
(
resp_str
)
payload
=
ujson
.
loads
(
resp_str
)
setattr
(
request
.
ctx
,
"user_id"
,
payload
[
"user_id"
])
setattr
(
request
.
ctx
,
"user_id"
,
payload
[
"user_id"
])
...
...
unify_api/modules/users/procedures/login_pds.py
View file @
d3b3699e
...
@@ -20,7 +20,8 @@ async def wechat_login(args, host):
...
@@ -20,7 +20,8 @@ async def wechat_login(args, host):
"user_info"
:
args
.
get
(
"user_info"
),
"user_info"
:
args
.
get
(
"user_info"
),
"client_name"
:
args
.
get
(
"client_name"
),
"client_name"
:
args
.
get
(
"client_name"
),
"host"
:
host
,
"host"
:
host
,
"product"
:
args
.
get
(
"product"
)
"product"
:
args
.
get
(
"product"
),
"db"
:
SETTING
.
mysql_db
}
}
try
:
try
:
...
@@ -45,7 +46,8 @@ async def app_login(args, host):
...
@@ -45,7 +46,8 @@ async def app_login(args, host):
"client_name"
:
args
.
get
(
"client_name"
),
"client_name"
:
args
.
get
(
"client_name"
),
"unionid"
:
args
.
get
(
"unionid"
),
"unionid"
:
args
.
get
(
"unionid"
),
"host"
:
host
,
"host"
:
host
,
"product"
:
args
.
get
(
"product"
)
"product"
:
args
.
get
(
"product"
),
"db"
:
SETTING
.
mysql_db
}
}
if
not
args
.
get
(
"unionid"
):
if
not
args
.
get
(
"unionid"
):
return
401
,
{
"code"
:
40001
,
"data"
:
None
,
"message"
:
"unionid is None"
}
return
401
,
{
"code"
:
40001
,
"data"
:
None
,
"message"
:
"unionid is None"
}
...
@@ -72,6 +74,7 @@ async def web_login(args, host):
...
@@ -72,6 +74,7 @@ async def web_login(args, host):
"code"
:
args
[
'code'
],
"code"
:
args
[
'code'
],
"client_name"
:
args
.
get
(
"client_name"
),
"client_name"
:
args
.
get
(
"client_name"
),
"host"
:
host
,
"host"
:
host
,
"db"
:
SETTING
.
mysql_db
}
}
try
:
try
:
# auth_url = "http://0.0.0.0:9000/unify-api/auth"
# auth_url = "http://0.0.0.0:9000/unify-api/auth"
...
@@ -110,7 +113,8 @@ async def third_login(args, host):
...
@@ -110,7 +113,8 @@ async def third_login(args, host):
"password"
:
password
,
"password"
:
password
,
"client_name"
:
args
.
get
(
"client_name"
),
"client_name"
:
args
.
get
(
"client_name"
),
"host"
:
host
,
"host"
:
host
,
"product"
:
args
.
get
(
"product"
)
"product"
:
args
.
get
(
"product"
),
"db"
:
SETTING
.
mysql_db
}
}
try
:
try
:
log
.
info
(
log
.
info
(
...
@@ -148,6 +152,7 @@ async def web_third_login(args, host):
...
@@ -148,6 +152,7 @@ async def web_third_login(args, host):
"password"
:
password
,
"password"
:
password
,
"client_name"
:
args
.
get
(
"client_name"
),
"client_name"
:
args
.
get
(
"client_name"
),
"host"
:
host
,
"host"
:
host
,
"db"
:
SETTING
.
mysql_db
}
}
try
:
try
:
log
.
info
(
log
.
info
(
...
@@ -197,6 +202,7 @@ async def validation_login(args, host):
...
@@ -197,6 +202,7 @@ async def validation_login(args, host):
"user_id"
:
user
[
"user_id"
],
"user_id"
:
user
[
"user_id"
],
"client_name"
:
client_name
,
"client_name"
:
client_name
,
"host"
:
host
,
"host"
:
host
,
"db"
:
SETTING
.
mysql_db
}
}
try
:
try
:
log
.
info
(
SETTING
.
auth_url
,
f
"request auth_url={SETTING.auth_url} "
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):
...
@@ -28,7 +28,7 @@ class AuthView(HTTPMethodView):
resp_str
,
status_code
=
await
AioHttpUtils
()
.
post
(
resp_str
,
status_code
=
await
AioHttpUtils
()
.
post
(
SETTING
.
auth_url
,
SETTING
.
auth_url
,
{
"user_name"
:
"balabala"
,
"password"
:
"balabala"
,
{
"user_name"
:
"balabala"
,
"password"
:
"balabala"
,
"client_name"
:
client_name
},
"client_name"
:
client_name
,
"db"
:
SETTING
.
mysql_db
},
timeout
=
50
,
timeout
=
50
,
)
)
print
(
f
"resp_str = {resp_str} status={status_code}"
)
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):
...
@@ -152,7 +152,8 @@ async def post_save_userinfo(request, body: SaveUserReq):
"phone"
:
phone
,
"phone"
:
phone
,
"client_name"
:
"validation"
,
"client_name"
:
"validation"
,
"host"
:
request
.
host
,
"host"
:
request
.
host
,
"user_id"
:
user
[
"user_id"
]
"user_id"
:
user
[
"user_id"
],
"db"
:
SETTING
.
mysql_db
}
}
resp_str
,
status
=
await
AioHttpUtils
()
.
post
(
resp_str
,
status
=
await
AioHttpUtils
()
.
post
(
SETTING
.
auth_url
,
SETTING
.
auth_url
,
...
...
unify_api/modules/users/views/logout.py
View file @
d3b3699e
...
@@ -54,8 +54,13 @@ async def get_user_logout(request) -> Success:
...
@@ -54,8 +54,13 @@ async def get_user_logout(request) -> Success:
# await jwt_utils.store_token_blacklist(token)
# await jwt_utils.store_token_blacklist(token)
try
:
try
:
log
.
info
(
f
"request logout_url={SETTING.logout_url}"
)
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
,
SETTING
.
logout_url
,
request_body
,
timeout
=
50
,
headers
=
{
"Authorization"
:
f
"Bearer {token}"
},
headers
=
{
"Authorization"
:
f
"Bearer {token}"
},
)
)
log
.
info
(
f
"request auth_url resp_str={resp_str} status={status}"
)
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):
...
@@ -21,7 +21,11 @@ class RefreshView(HTTPMethodView):
status
=
200
)
status
=
200
)
resp
,
status_code
=
await
AioHttpUtils
()
.
post
(
resp
,
status_code
=
await
AioHttpUtils
()
.
post
(
SETTING
.
refresh_token_url
,
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
,
timeout
=
50
,
headers
=
{
"Authorization"
:
f
"Bearer {token}"
}
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