square-administration 2.0.0__tar.gz → 2.2.0__tar.gz

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.
Files changed (21) hide show
  1. {square_administration-2.0.0 → square_administration-2.2.0}/PKG-INFO +10 -1
  2. {square_administration-2.0.0 → square_administration-2.2.0}/README.md +9 -0
  3. {square_administration-2.0.0 → square_administration-2.2.0}/setup.py +1 -1
  4. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/messages.py +1 -0
  5. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/routes/authentication.py +136 -1
  6. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration.egg-info/PKG-INFO +10 -1
  7. {square_administration-2.0.0 → square_administration-2.2.0}/setup.cfg +0 -0
  8. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/__init__.py +0 -0
  9. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/configuration.py +0 -0
  10. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/data/config.ini +0 -0
  11. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/main.py +0 -0
  12. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/pydantic_models/__init__.py +0 -0
  13. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/pydantic_models/authentication.py +0 -0
  14. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/pydantic_models/core.py +0 -0
  15. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/routes/__init__.py +0 -0
  16. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/routes/core.py +0 -0
  17. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration/utils/__init__.py +0 -0
  18. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration.egg-info/SOURCES.txt +0 -0
  19. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration.egg-info/dependency_links.txt +0 -0
  20. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration.egg-info/requires.txt +0 -0
  21. {square_administration-2.0.0 → square_administration-2.2.0}/square_administration.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: square_administration
3
- Version: 2.0.0
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
@@ -32,6 +32,15 @@ pip install square_administration
32
32
 
33
33
  ## changelog
34
34
 
35
+ ### v2.2.0
36
+
37
+ - authentication
38
+ - logout_v0, generate_access_token_v0 remove refresh token from request header and accept in cookie.
39
+
40
+ ### v2.1.0
41
+
42
+ - add authentication -> logout_v0, generate_access_token_v0.
43
+
35
44
  ### v2.0.0
36
45
 
37
46
  - remove refresh token from response body and send in cookies.
@@ -16,6 +16,15 @@ pip install square_administration
16
16
 
17
17
  ## changelog
18
18
 
19
+ ### v2.2.0
20
+
21
+ - authentication
22
+ - logout_v0, generate_access_token_v0 remove refresh token from request header and accept in cookie.
23
+
24
+ ### v2.1.0
25
+
26
+ - add authentication -> logout_v0, generate_access_token_v0.
27
+
19
28
  ### v2.0.0
20
29
 
21
30
  - remove refresh token from response body and send in cookies.
@@ -4,7 +4,7 @@ package_name = "square_administration"
4
4
 
5
5
  setup(
6
6
  name=package_name,
7
- version="2.0.0",
7
+ version="2.2.0",
8
8
  packages=find_packages(),
9
9
  package_data={
10
10
  package_name: ["data/*"],
@@ -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.0.0
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
@@ -32,6 +32,15 @@ pip install square_administration
32
32
 
33
33
  ## changelog
34
34
 
35
+ ### v2.2.0
36
+
37
+ - authentication
38
+ - logout_v0, generate_access_token_v0 remove refresh token from request header and accept in cookie.
39
+
40
+ ### v2.1.0
41
+
42
+ - add authentication -> logout_v0, generate_access_token_v0.
43
+
35
44
  ### v2.0.0
36
45
 
37
46
  - remove refresh token from response body and send in cookies.