square-administration 2.1.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.1.0 → square_administration-2.2.0}/PKG-INFO +6 -1
  2. {square_administration-2.1.0 → square_administration-2.2.0}/README.md +5 -0
  3. {square_administration-2.1.0 → square_administration-2.2.0}/setup.py +1 -1
  4. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/messages.py +1 -0
  5. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/routes/authentication.py +24 -7
  6. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration.egg-info/PKG-INFO +6 -1
  7. {square_administration-2.1.0 → square_administration-2.2.0}/setup.cfg +0 -0
  8. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/__init__.py +0 -0
  9. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/configuration.py +0 -0
  10. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/data/config.ini +0 -0
  11. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/main.py +0 -0
  12. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/pydantic_models/__init__.py +0 -0
  13. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/pydantic_models/authentication.py +0 -0
  14. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/pydantic_models/core.py +0 -0
  15. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/routes/__init__.py +0 -0
  16. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/routes/core.py +0 -0
  17. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration/utils/__init__.py +0 -0
  18. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration.egg-info/SOURCES.txt +0 -0
  19. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration.egg-info/dependency_links.txt +0 -0
  20. {square_administration-2.1.0 → square_administration-2.2.0}/square_administration.egg-info/requires.txt +0 -0
  21. {square_administration-2.1.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.1.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,11 @@ 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
+
35
40
  ### v2.1.0
36
41
 
37
42
  - add authentication -> logout_v0, generate_access_token_v0.
@@ -16,6 +16,11 @@ 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
+
19
24
  ### v2.1.0
20
25
 
21
26
  - add authentication -> logout_v0, generate_access_token_v0.
@@ -4,7 +4,7 @@ package_name = "square_administration"
4
4
 
5
5
  setup(
6
6
  name=package_name,
7
- version="2.1.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
@@ -260,15 +260,23 @@ async def remove_app_for_self_v0(
260
260
 
261
261
  @router.delete("/logout/v0")
262
262
  @global_object_square_logger.async_auto_logger
263
- async def logout_v0(
264
- refresh_token: Annotated[str, Header()],
265
- ):
263
+ async def logout_v0(request: Request):
266
264
 
267
265
  try:
268
266
  """
269
267
  validation
270
268
  """
271
- # pass
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
+ )
272
280
  """
273
281
  main process
274
282
  """
@@ -320,14 +328,23 @@ async def logout_v0(
320
328
  @router.get("/generate_access_token/v0")
321
329
  @global_object_square_logger.async_auto_logger
322
330
  async def generate_access_token_v0(
323
- refresh_token: Annotated[str, Header()],
331
+ request: Request,
324
332
  ):
325
333
 
326
334
  try:
327
335
  """
328
336
  validation
329
337
  """
330
- # pass
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
+ )
331
348
  """
332
349
  main process
333
350
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: square-administration
3
- Version: 2.1.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,11 @@ 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
+
35
40
  ### v2.1.0
36
41
 
37
42
  - add authentication -> logout_v0, generate_access_token_v0.