square-administration 1.2.1__tar.gz → 2.1.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-1.2.1 → square_administration-2.1.0}/PKG-INFO +9 -1
  2. {square_administration-1.2.1 → square_administration-2.1.0}/README.md +8 -0
  3. {square_administration-1.2.1 → square_administration-2.1.0}/setup.py +1 -1
  4. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/routes/authentication.py +139 -2
  5. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration.egg-info/PKG-INFO +9 -1
  6. {square_administration-1.2.1 → square_administration-2.1.0}/setup.cfg +0 -0
  7. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/__init__.py +0 -0
  8. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/configuration.py +0 -0
  9. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/data/config.ini +0 -0
  10. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/main.py +0 -0
  11. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/messages.py +0 -0
  12. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/pydantic_models/__init__.py +0 -0
  13. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/pydantic_models/authentication.py +0 -0
  14. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/pydantic_models/core.py +0 -0
  15. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/routes/__init__.py +0 -0
  16. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/routes/core.py +0 -0
  17. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration/utils/__init__.py +0 -0
  18. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration.egg-info/SOURCES.txt +0 -0
  19. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration.egg-info/dependency_links.txt +0 -0
  20. {square_administration-1.2.1 → square_administration-2.1.0}/square_administration.egg-info/requires.txt +0 -0
  21. {square_administration-1.2.1 → square_administration-2.1.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: 1.2.1
3
+ Version: 2.1.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,14 @@ pip install square_administration
32
32
 
33
33
  ## changelog
34
34
 
35
+ ### v2.1.0
36
+
37
+ - add authentication -> logout_v0, generate_access_token_v0.
38
+
39
+ ### v2.0.0
40
+
41
+ - remove refresh token from response body and send in cookies.
42
+
35
43
  ### v1.2.1
36
44
 
37
45
  - fix bug in core -> get_all_greetings_v0, now sending full response instead of only main.
@@ -16,6 +16,14 @@ pip install square_administration
16
16
 
17
17
  ## changelog
18
18
 
19
+ ### v2.1.0
20
+
21
+ - add authentication -> logout_v0, generate_access_token_v0.
22
+
23
+ ### v2.0.0
24
+
25
+ - remove refresh token from response body and send in cookies.
26
+
19
27
  ### v1.2.1
20
28
 
21
29
  - fix bug in core -> get_all_greetings_v0, now sending full response instead of only main.
@@ -4,7 +4,7 @@ package_name = "square_administration"
4
4
 
5
5
  setup(
6
6
  name=package_name,
7
- version="1.2.1",
7
+ version="2.1.0",
8
8
  packages=find_packages(),
9
9
  package_data={
10
10
  package_name: ["data/*"],
@@ -6,6 +6,7 @@ from fastapi import APIRouter, status, HTTPException, Header
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
9
+ from square_commons.api_utils import create_cookie
9
10
 
10
11
  from square_administration.configuration import (
11
12
  global_object_square_logger,
@@ -66,14 +67,23 @@ async def register_username_v0(
66
67
  """
67
68
  return value
68
69
  """
70
+ refresh_token = response["data"]["main"]["refresh_token"]
71
+ del response["data"]["main"]["refresh_token"]
69
72
  output_content = get_api_output_in_standard_format(
70
73
  message=messages["REGISTRATION_SUCCESSFUL"],
71
74
  data={"main": response["data"]["main"]},
72
75
  )
73
- return JSONResponse(
76
+ json_response = JSONResponse(
74
77
  status_code=status.HTTP_201_CREATED,
75
78
  content=output_content,
76
79
  )
80
+ json_response.set_cookie(
81
+ **create_cookie(
82
+ key="refresh_token|" + str(global_int_app_id),
83
+ value=refresh_token,
84
+ )
85
+ )
86
+ return json_response
77
87
  except HTTPError as http_error:
78
88
  global_object_square_logger.logger.error(http_error, exc_info=True)
79
89
  """
@@ -133,14 +143,23 @@ async def login_username_v0(
133
143
  """
134
144
  return value
135
145
  """
146
+ refresh_token = response["data"]["main"]["refresh_token"]
147
+ del response["data"]["main"]["refresh_token"]
136
148
  output_content = get_api_output_in_standard_format(
137
149
  message=messages["LOGIN_SUCCESSFUL"],
138
150
  data={"main": response["data"]["main"]},
139
151
  )
140
- return JSONResponse(
152
+ json_response = JSONResponse(
141
153
  status_code=status.HTTP_200_OK,
142
154
  content=output_content,
143
155
  )
156
+ json_response.set_cookie(
157
+ **create_cookie(
158
+ key="refresh_token|" + str(global_int_app_id),
159
+ value=refresh_token,
160
+ )
161
+ )
162
+ return json_response
144
163
  except HTTPError as http_error:
145
164
  global_object_square_logger.logger.error(http_error, exc_info=True)
146
165
  """
@@ -237,3 +256,121 @@ async def remove_app_for_self_v0(
237
256
  return JSONResponse(
238
257
  status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
239
258
  )
259
+
260
+
261
+ @router.delete("/logout/v0")
262
+ @global_object_square_logger.async_auto_logger
263
+ async def logout_v0(
264
+ refresh_token: Annotated[str, Header()],
265
+ ):
266
+
267
+ try:
268
+ """
269
+ validation
270
+ """
271
+ # pass
272
+ """
273
+ main process
274
+ """
275
+ response = global_object_square_authentication_helper.logout_v0(
276
+ refresh_token=refresh_token
277
+ )
278
+ """
279
+ return value
280
+ """
281
+
282
+ return JSONResponse(
283
+ status_code=status.HTTP_200_OK,
284
+ content=response,
285
+ )
286
+ except HTTPError as http_error:
287
+ global_object_square_logger.logger.error(http_error, exc_info=True)
288
+ """
289
+ rollback logic
290
+ """
291
+ # pass
292
+ return JSONResponse(
293
+ status_code=http_error.response.status_code,
294
+ content=json.loads(http_error.response.content),
295
+ )
296
+ except HTTPException as http_exception:
297
+ global_object_square_logger.logger.error(http_exception, exc_info=True)
298
+ """
299
+ rollback logic
300
+ """
301
+ # pass
302
+ return JSONResponse(
303
+ status_code=http_exception.status_code, content=http_exception.detail
304
+ )
305
+ except Exception as e:
306
+ global_object_square_logger.logger.error(e, exc_info=True)
307
+ """
308
+ rollback logic
309
+ """
310
+ # pass
311
+ output_content = get_api_output_in_standard_format(
312
+ message=messages["GENERIC_500"],
313
+ log=str(e),
314
+ )
315
+ return JSONResponse(
316
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
317
+ )
318
+
319
+
320
+ @router.get("/generate_access_token/v0")
321
+ @global_object_square_logger.async_auto_logger
322
+ async def generate_access_token_v0(
323
+ refresh_token: Annotated[str, Header()],
324
+ ):
325
+
326
+ try:
327
+ """
328
+ validation
329
+ """
330
+ # pass
331
+ """
332
+ main process
333
+ """
334
+ response = global_object_square_authentication_helper.generate_access_token_v0(
335
+ refresh_token=refresh_token
336
+ )
337
+ """
338
+ return value
339
+ """
340
+
341
+ return JSONResponse(
342
+ status_code=status.HTTP_200_OK,
343
+ content=response,
344
+ )
345
+ except HTTPError as http_error:
346
+ global_object_square_logger.logger.error(http_error, exc_info=True)
347
+ """
348
+ rollback logic
349
+ """
350
+ # pass
351
+ return JSONResponse(
352
+ status_code=http_error.response.status_code,
353
+ content=json.loads(http_error.response.content),
354
+ )
355
+ except HTTPException as http_exception:
356
+ global_object_square_logger.logger.error(http_exception, exc_info=True)
357
+ """
358
+ rollback logic
359
+ """
360
+ # pass
361
+ return JSONResponse(
362
+ status_code=http_exception.status_code, content=http_exception.detail
363
+ )
364
+ except Exception as e:
365
+ global_object_square_logger.logger.error(e, exc_info=True)
366
+ """
367
+ rollback logic
368
+ """
369
+ # pass
370
+ output_content = get_api_output_in_standard_format(
371
+ message=messages["GENERIC_500"],
372
+ log=str(e),
373
+ )
374
+ return JSONResponse(
375
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
376
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: square-administration
3
- Version: 1.2.1
3
+ Version: 2.1.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,14 @@ pip install square_administration
32
32
 
33
33
  ## changelog
34
34
 
35
+ ### v2.1.0
36
+
37
+ - add authentication -> logout_v0, generate_access_token_v0.
38
+
39
+ ### v2.0.0
40
+
41
+ - remove refresh token from response body and send in cookies.
42
+
35
43
  ### v1.2.1
36
44
 
37
45
  - fix bug in core -> get_all_greetings_v0, now sending full response instead of only main.