square-administration 2.0.0__py3-none-any.whl → 2.2.0__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.
- square_administration/messages.py +1 -0
- square_administration/routes/authentication.py +136 -1
- {square_administration-2.0.0.dist-info → square_administration-2.2.0.dist-info}/METADATA +10 -1
- {square_administration-2.0.0.dist-info → square_administration-2.2.0.dist-info}/RECORD +6 -6
- {square_administration-2.0.0.dist-info → square_administration-2.2.0.dist-info}/WHEEL +0 -0
- {square_administration-2.0.0.dist-info → square_administration-2.2.0.dist-info}/top_level.txt +0 -0
@@ -12,4 +12,5 @@ messages = {
|
|
12
12
|
"GENERIC_500": "an internal server error occurred. please try again later.",
|
13
13
|
"INCORRECT_ACCESS_TOKEN": "the access token provided is invalid or expired.",
|
14
14
|
"INCORRECT_REFRESH_TOKEN": "the refresh token provided is invalid or expired.",
|
15
|
+
"REFRESH_TOKEN_NOT_FOUND": "refresh token not found. please login again.",
|
15
16
|
}
|
@@ -2,7 +2,7 @@ import json
|
|
2
2
|
from typing import Annotated
|
3
3
|
|
4
4
|
import bcrypt
|
5
|
-
from fastapi import APIRouter, status, HTTPException, Header
|
5
|
+
from fastapi import APIRouter, status, HTTPException, Header, Request
|
6
6
|
from fastapi.responses import JSONResponse
|
7
7
|
from requests import HTTPError
|
8
8
|
from square_commons import get_api_output_in_standard_format
|
@@ -256,3 +256,138 @@ async def remove_app_for_self_v0(
|
|
256
256
|
return JSONResponse(
|
257
257
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
258
258
|
)
|
259
|
+
|
260
|
+
|
261
|
+
@router.delete("/logout/v0")
|
262
|
+
@global_object_square_logger.async_auto_logger
|
263
|
+
async def logout_v0(request: Request):
|
264
|
+
|
265
|
+
try:
|
266
|
+
"""
|
267
|
+
validation
|
268
|
+
"""
|
269
|
+
|
270
|
+
refresh_token = request.cookies.get("refresh_token|" + str(global_int_app_id))
|
271
|
+
if refresh_token is None:
|
272
|
+
output_content = get_api_output_in_standard_format(
|
273
|
+
message=messages["REFRESH_TOKEN_NOT_FOUND"],
|
274
|
+
log=f"refresh token not found.",
|
275
|
+
)
|
276
|
+
return JSONResponse(
|
277
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
278
|
+
content=output_content,
|
279
|
+
)
|
280
|
+
"""
|
281
|
+
main process
|
282
|
+
"""
|
283
|
+
response = global_object_square_authentication_helper.logout_v0(
|
284
|
+
refresh_token=refresh_token
|
285
|
+
)
|
286
|
+
"""
|
287
|
+
return value
|
288
|
+
"""
|
289
|
+
|
290
|
+
return JSONResponse(
|
291
|
+
status_code=status.HTTP_200_OK,
|
292
|
+
content=response,
|
293
|
+
)
|
294
|
+
except HTTPError as http_error:
|
295
|
+
global_object_square_logger.logger.error(http_error, exc_info=True)
|
296
|
+
"""
|
297
|
+
rollback logic
|
298
|
+
"""
|
299
|
+
# pass
|
300
|
+
return JSONResponse(
|
301
|
+
status_code=http_error.response.status_code,
|
302
|
+
content=json.loads(http_error.response.content),
|
303
|
+
)
|
304
|
+
except HTTPException as http_exception:
|
305
|
+
global_object_square_logger.logger.error(http_exception, exc_info=True)
|
306
|
+
"""
|
307
|
+
rollback logic
|
308
|
+
"""
|
309
|
+
# pass
|
310
|
+
return JSONResponse(
|
311
|
+
status_code=http_exception.status_code, content=http_exception.detail
|
312
|
+
)
|
313
|
+
except Exception as e:
|
314
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
315
|
+
"""
|
316
|
+
rollback logic
|
317
|
+
"""
|
318
|
+
# pass
|
319
|
+
output_content = get_api_output_in_standard_format(
|
320
|
+
message=messages["GENERIC_500"],
|
321
|
+
log=str(e),
|
322
|
+
)
|
323
|
+
return JSONResponse(
|
324
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
325
|
+
)
|
326
|
+
|
327
|
+
|
328
|
+
@router.get("/generate_access_token/v0")
|
329
|
+
@global_object_square_logger.async_auto_logger
|
330
|
+
async def generate_access_token_v0(
|
331
|
+
request: Request,
|
332
|
+
):
|
333
|
+
|
334
|
+
try:
|
335
|
+
"""
|
336
|
+
validation
|
337
|
+
"""
|
338
|
+
refresh_token = request.cookies.get("refresh_token|" + str(global_int_app_id))
|
339
|
+
if refresh_token is None:
|
340
|
+
output_content = get_api_output_in_standard_format(
|
341
|
+
message=messages["REFRESH_TOKEN_NOT_FOUND"],
|
342
|
+
log=f"refresh token not found.",
|
343
|
+
)
|
344
|
+
return JSONResponse(
|
345
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
346
|
+
content=output_content,
|
347
|
+
)
|
348
|
+
"""
|
349
|
+
main process
|
350
|
+
"""
|
351
|
+
response = global_object_square_authentication_helper.generate_access_token_v0(
|
352
|
+
refresh_token=refresh_token
|
353
|
+
)
|
354
|
+
"""
|
355
|
+
return value
|
356
|
+
"""
|
357
|
+
|
358
|
+
return JSONResponse(
|
359
|
+
status_code=status.HTTP_200_OK,
|
360
|
+
content=response,
|
361
|
+
)
|
362
|
+
except HTTPError as http_error:
|
363
|
+
global_object_square_logger.logger.error(http_error, exc_info=True)
|
364
|
+
"""
|
365
|
+
rollback logic
|
366
|
+
"""
|
367
|
+
# pass
|
368
|
+
return JSONResponse(
|
369
|
+
status_code=http_error.response.status_code,
|
370
|
+
content=json.loads(http_error.response.content),
|
371
|
+
)
|
372
|
+
except HTTPException as http_exception:
|
373
|
+
global_object_square_logger.logger.error(http_exception, exc_info=True)
|
374
|
+
"""
|
375
|
+
rollback logic
|
376
|
+
"""
|
377
|
+
# pass
|
378
|
+
return JSONResponse(
|
379
|
+
status_code=http_exception.status_code, content=http_exception.detail
|
380
|
+
)
|
381
|
+
except Exception as e:
|
382
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
383
|
+
"""
|
384
|
+
rollback logic
|
385
|
+
"""
|
386
|
+
# pass
|
387
|
+
output_content = get_api_output_in_standard_format(
|
388
|
+
message=messages["GENERIC_500"],
|
389
|
+
log=str(e),
|
390
|
+
)
|
391
|
+
return JSONResponse(
|
392
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
393
|
+
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: square-administration
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.2.0
|
4
4
|
Summary: common business layer for my personal server.
|
5
5
|
Home-page: https://github.com/thepmsquare/square_administration
|
6
6
|
Author: thePmSquare
|
@@ -42,6 +42,15 @@ pip install square_administration
|
|
42
42
|
|
43
43
|
## changelog
|
44
44
|
|
45
|
+
### v2.2.0
|
46
|
+
|
47
|
+
- authentication
|
48
|
+
- logout_v0, generate_access_token_v0 remove refresh token from request header and accept in cookie.
|
49
|
+
|
50
|
+
### v2.1.0
|
51
|
+
|
52
|
+
- add authentication -> logout_v0, generate_access_token_v0.
|
53
|
+
|
45
54
|
### v2.0.0
|
46
55
|
|
47
56
|
- remove refresh token from response body and send in cookies.
|
@@ -1,16 +1,16 @@
|
|
1
1
|
square_administration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
square_administration/configuration.py,sha256=ldSmVp3FWOndN4u-dH-pf4i0olRZx1-uORJAj1qW-g8,4733
|
3
3
|
square_administration/main.py,sha256=L4MM_7yimRLB8J1ltgXPnrN3j_UXKVtp8o8S46MSqrY,1678
|
4
|
-
square_administration/messages.py,sha256=
|
4
|
+
square_administration/messages.py,sha256=VYjJGW0Kvtjrx1Mw7ekksLVMoxcexLol2OckvqhZ3n0,1063
|
5
5
|
square_administration/data/config.ini,sha256=NMpUnBSPEdwCW1Y-z5DOjpTQgXGjt4ZcqP4QQiAXr_U,997
|
6
6
|
square_administration/pydantic_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
square_administration/pydantic_models/authentication.py,sha256=DWXctw5UWzkSVY7nMIQZsRhmgW3OK455OVcoUpJrPY0,202
|
8
8
|
square_administration/pydantic_models/core.py,sha256=HUMrBmfKrXeL-126gE5j2povdVmktn8XLg2tHEdeXTk,344
|
9
9
|
square_administration/routes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
-
square_administration/routes/authentication.py,sha256=
|
10
|
+
square_administration/routes/authentication.py,sha256=jGyQJkX6LMnNbOFqbWdEyOnMGUHNdK-PoeGriTNt-XM,11862
|
11
11
|
square_administration/routes/core.py,sha256=65_FIZilintZvbHx7r25UQbgN-oKdQ92-Nv3kpwKX6s,5374
|
12
12
|
square_administration/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
-
square_administration-2.
|
14
|
-
square_administration-2.
|
15
|
-
square_administration-2.
|
16
|
-
square_administration-2.
|
13
|
+
square_administration-2.2.0.dist-info/METADATA,sha256=jKs3X8MSBrYx4YGeC-P7_arkADCzp29S8p7JMz4tN-k,1686
|
14
|
+
square_administration-2.2.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
15
|
+
square_administration-2.2.0.dist-info/top_level.txt,sha256=8WFipDrMQUPRDo5AvipxU1YK3wZtWZyCUMWaR416zAw,22
|
16
|
+
square_administration-2.2.0.dist-info/RECORD,,
|
File without changes
|
{square_administration-2.0.0.dist-info → square_administration-2.2.0.dist-info}/top_level.txt
RENAMED
File without changes
|