reyserver 1.1.51__py3-none-any.whl → 1.1.52__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reyserver/rauth.py +35 -36
- reyserver/rserver.py +4 -1
- {reyserver-1.1.51.dist-info → reyserver-1.1.52.dist-info}/METADATA +1 -1
- {reyserver-1.1.51.dist-info → reyserver-1.1.52.dist-info}/RECORD +6 -6
- {reyserver-1.1.51.dist-info → reyserver-1.1.52.dist-info}/WHEEL +0 -0
- {reyserver-1.1.51.dist-info → reyserver-1.1.52.dist-info}/licenses/LICENSE +0 -0
reyserver/rauth.py
CHANGED
@@ -9,11 +9,12 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Literal
|
12
|
+
from typing import Any, Literal
|
13
|
+
from datetime import datetime as Datetime
|
13
14
|
from fastapi import APIRouter
|
14
15
|
from reydb import rorm, DatabaseEngine, DatabaseEngineAsync
|
15
|
-
|
16
|
-
|
16
|
+
from reykit.rdata import encode_jwt, is_hash_bcrypt
|
17
|
+
from reykit.rtime import now, time_to
|
17
18
|
|
18
19
|
from .rbase import ServerConfig, Bind, exit_api
|
19
20
|
|
@@ -263,41 +264,39 @@ async def create_sessions(
|
|
263
264
|
" SELECT `perm_id`, `name`, CONCAT(`method`, ':', `path`) as `api`\n"
|
264
265
|
' FROM `test`.`perm`\n'
|
265
266
|
') AS `perm`\n'
|
266
|
-
'ON `role_perm`.`perm_id` = `perm`.`perm_id
|
267
|
+
'ON `role_perm`.`perm_id` = `perm`.`perm_id`\n'
|
268
|
+
'GROUP BY `user_id`'
|
267
269
|
)
|
268
|
-
print(1111111111111)
|
269
270
|
result = await conn.execute(
|
270
271
|
sql,
|
271
272
|
account=account
|
272
273
|
)
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
#
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
# print(111111, data)
|
303
|
-
# return data
|
274
|
+
|
275
|
+
# Check.
|
276
|
+
if result.empty:
|
277
|
+
exit_api(401)
|
278
|
+
json: dict[str, Datetime | Any] = result.to_row()
|
279
|
+
if not is_hash_bcrypt(password, json['password']):
|
280
|
+
exit_api(401)
|
281
|
+
|
282
|
+
# JWT.
|
283
|
+
now_timestamp_s = now('timestamp_s')
|
284
|
+
json['sub'] = json.pop('user_id')
|
285
|
+
json['iat'] = now_timestamp_s
|
286
|
+
json['nbf'] = now_timestamp_s
|
287
|
+
json['exp'] = now_timestamp_s + sess_seconds
|
288
|
+
json['role_names'] = json['role_names'].split(';')
|
289
|
+
json['perm_names'] = json['perm_names'].split(';')
|
290
|
+
perm_apis: list[str] = json['perm_apis'].split(';')
|
291
|
+
perm_api_dict = {}
|
292
|
+
for perm_api in perm_apis:
|
293
|
+
method, path = perm_api.split(':', 1)
|
294
|
+
paths: list = perm_api_dict.setdefault(method, [])
|
295
|
+
paths.append(path)
|
296
|
+
json['perm_apis'] = perm_api_dict
|
297
|
+
json['create_time'] = json['create_time'].timestamp()
|
298
|
+
json['update_time'] = json['update_time'].timestamp()
|
299
|
+
token = encode_jwt(json, key)
|
300
|
+
data = {'token': token}
|
301
|
+
|
302
|
+
return data
|
reyserver/rserver.py
CHANGED
@@ -138,7 +138,10 @@ class Server(ServerBase, Singleton):
|
|
138
138
|
response = await call_next(request)
|
139
139
|
|
140
140
|
# After.
|
141
|
-
if
|
141
|
+
if (
|
142
|
+
response.status_code == 200
|
143
|
+
and request.method == 'POST'
|
144
|
+
):
|
142
145
|
response.status_code = 201
|
143
146
|
|
144
147
|
return response
|
@@ -1,11 +1,11 @@
|
|
1
1
|
reyserver/__init__.py,sha256=7GX64p7uI2eetJH9NJ-DTg-8iyQwOsGcviADFJCPxVA,373
|
2
2
|
reyserver/rall.py,sha256=riyDRTUsigco_Bee1H4aZFb8IgvjnxdX9qcnVb9i9mE,270
|
3
|
-
reyserver/rauth.py,sha256=
|
3
|
+
reyserver/rauth.py,sha256=oa6Iwuutcj9eO6RH7DaT-rPn_YqYwKuyHYaBd3lZoZE,11728
|
4
4
|
reyserver/rbase.py,sha256=xgdLP_O77e-pSrRWm9GVSziPSqEOh2w20cWkF4HBeWo,7042
|
5
5
|
reyserver/rclient.py,sha256=IWZ3smyIP0_YJrfSrM8JFCr0FCtN02AyT3hp8YuSsDQ,5103
|
6
6
|
reyserver/rfile.py,sha256=bvuXOYO3UDM1jMiyNzQDz56_0ekZUEIRcfNFAhGgdUY,9010
|
7
|
-
reyserver/rserver.py,sha256=
|
8
|
-
reyserver-1.1.
|
9
|
-
reyserver-1.1.
|
10
|
-
reyserver-1.1.
|
11
|
-
reyserver-1.1.
|
7
|
+
reyserver/rserver.py,sha256=bfakJGhcHF0CIiAmRyMVOURLbPNCIALGyrnKpf_Yi80,6800
|
8
|
+
reyserver-1.1.52.dist-info/METADATA,sha256=ujWE6YB95IdJf4nCYtq7FZW2sw0s_TGSeyuEwAjfHW8,1689
|
9
|
+
reyserver-1.1.52.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
reyserver-1.1.52.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
11
|
+
reyserver-1.1.52.dist-info/RECORD,,
|
File without changes
|
File without changes
|