square-administration 3.2.1__py3-none-any.whl → 3.3.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.
@@ -10,8 +10,12 @@ try:
10
10
  config_file_path = os.path.join(
11
11
  os.path.dirname(os.path.abspath(__file__)), "data", "config.ini"
12
12
  )
13
- ldict_configuration = ConfigReader(config_file_path).read_configuration()
14
-
13
+ config_sample_file_path = os.path.join(
14
+ os.path.dirname(os.path.abspath(__file__)), "data", "config.sample.ini"
15
+ )
16
+ ldict_configuration = ConfigReader(
17
+ config_file_path, config_sample_file_path
18
+ ).read_configuration()
15
19
  # get all vars and typecast
16
20
  # ===========================================
17
21
  # general
@@ -14,3 +14,21 @@ class LoginUsernameV0(BaseModel):
14
14
 
15
15
  class RemoveAppForSelfV0(BaseModel):
16
16
  password: str
17
+
18
+
19
+ class RegisterLoginGoogleV0(BaseModel):
20
+ google_id: str
21
+
22
+
23
+ class ResetPasswordAndLoginUsingBackupCodeV0(BaseModel):
24
+ backup_code: str
25
+ username: str
26
+ new_password: str
27
+ logout_other_sessions: bool = False
28
+
29
+
30
+ class ResetPasswordAndLoginUsingResetEmailCodeV0(BaseModel):
31
+ reset_email_code: str
32
+ username: str
33
+ new_password: str
34
+ logout_other_sessions: bool = False
@@ -26,6 +26,9 @@ from square_administration.pydantic_models.authentication import (
26
26
  RegisterUsernameV0,
27
27
  LoginUsernameV0,
28
28
  RemoveAppForSelfV0,
29
+ RegisterLoginGoogleV0,
30
+ ResetPasswordAndLoginUsingBackupCodeV0,
31
+ ResetPasswordAndLoginUsingResetEmailCodeV0,
29
32
  )
30
33
  from square_administration.utils.common import is_https, global_int_app_id
31
34
 
@@ -481,3 +484,194 @@ async def generate_access_token_v0(
481
484
  return JSONResponse(
482
485
  status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
483
486
  )
487
+
488
+
489
+ @router.post("/register_login_google/v0")
490
+ @global_object_square_logger.auto_logger()
491
+ async def register_login_google_v0(body: RegisterLoginGoogleV0):
492
+ google_id = body.google_id
493
+ try:
494
+ """
495
+ validation
496
+ """
497
+ # pass
498
+ """
499
+ main process
500
+ """
501
+ response = global_object_square_authentication_helper.register_login_google_v0(
502
+ google_id=google_id,
503
+ assign_app_id_if_missing=False,
504
+ app_id=global_int_app_id,
505
+ )
506
+ """
507
+ return value
508
+ """
509
+
510
+ return JSONResponse(
511
+ status_code=status.HTTP_200_OK,
512
+ content=response,
513
+ )
514
+ except HTTPError as http_error:
515
+ global_object_square_logger.logger.error(http_error, exc_info=True)
516
+ """
517
+ rollback logic
518
+ """
519
+ # pass
520
+ return JSONResponse(
521
+ status_code=http_error.response.status_code,
522
+ content=json.loads(http_error.response.content),
523
+ )
524
+ except HTTPException as http_exception:
525
+ global_object_square_logger.logger.error(http_exception, exc_info=True)
526
+ """
527
+ rollback logic
528
+ """
529
+ # pass
530
+ return JSONResponse(
531
+ status_code=http_exception.status_code, content=http_exception.detail
532
+ )
533
+ except Exception as e:
534
+ global_object_square_logger.logger.error(e, exc_info=True)
535
+ """
536
+ rollback logic
537
+ """
538
+ # pass
539
+ output_content = get_api_output_in_standard_format(
540
+ message=messages["GENERIC_500"],
541
+ log=str(e),
542
+ )
543
+ return JSONResponse(
544
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
545
+ )
546
+
547
+
548
+ @router.post("/reset_password_and_login_using_backup_code/v0")
549
+ @global_object_square_logger.auto_logger()
550
+ async def reset_password_and_login_using_backup_code_v0(
551
+ body: ResetPasswordAndLoginUsingBackupCodeV0,
552
+ ):
553
+ backup_code = body.backup_code
554
+ username = body.username
555
+ new_password = body.new_password
556
+ logout_other_sessions = body.logout_other_sessions
557
+ try:
558
+ """
559
+ validation
560
+ """
561
+ # pass
562
+ """
563
+ main process
564
+ """
565
+ response = global_object_square_authentication_helper.reset_password_and_login_using_backup_code_v0(
566
+ backup_code=backup_code,
567
+ username=username,
568
+ new_password=new_password,
569
+ app_id=global_int_app_id,
570
+ logout_other_sessions=logout_other_sessions,
571
+ )
572
+ """
573
+ return value
574
+ """
575
+
576
+ return JSONResponse(
577
+ status_code=status.HTTP_200_OK,
578
+ content=response,
579
+ )
580
+ except HTTPError as http_error:
581
+ global_object_square_logger.logger.error(http_error, exc_info=True)
582
+ """
583
+ rollback logic
584
+ """
585
+ # pass
586
+ return JSONResponse(
587
+ status_code=http_error.response.status_code,
588
+ content=json.loads(http_error.response.content),
589
+ )
590
+ except HTTPException as http_exception:
591
+ global_object_square_logger.logger.error(http_exception, exc_info=True)
592
+ """
593
+ rollback logic
594
+ """
595
+ # pass
596
+ return JSONResponse(
597
+ status_code=http_exception.status_code, content=http_exception.detail
598
+ )
599
+ except Exception as e:
600
+ global_object_square_logger.logger.error(e, exc_info=True)
601
+ """
602
+ rollback logic
603
+ """
604
+ # pass
605
+ output_content = get_api_output_in_standard_format(
606
+ message=messages["GENERIC_500"],
607
+ log=str(e),
608
+ )
609
+ return JSONResponse(
610
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
611
+ )
612
+
613
+
614
+ @router.post("/reset_password_and_login_using_reset_email_code/v0")
615
+ @global_object_square_logger.auto_logger()
616
+ async def reset_password_and_login_using_reset_email_code_v0(
617
+ body: ResetPasswordAndLoginUsingResetEmailCodeV0,
618
+ ):
619
+ reset_email_code = body.reset_email_code
620
+ username = body.username
621
+ new_password = body.new_password
622
+ logout_other_sessions = body.logout_other_sessions
623
+ try:
624
+ """
625
+ validation
626
+ """
627
+ # pass
628
+ """
629
+ main process
630
+ """
631
+ response = global_object_square_authentication_helper.reset_password_and_login_using_reset_email_code_v0(
632
+ reset_email_code=reset_email_code,
633
+ username=username,
634
+ new_password=new_password,
635
+ app_id=global_int_app_id,
636
+ logout_other_sessions=logout_other_sessions,
637
+ )
638
+ """
639
+ return value
640
+ """
641
+
642
+ return JSONResponse(
643
+ status_code=status.HTTP_200_OK,
644
+ content=response,
645
+ )
646
+ except HTTPError as http_error:
647
+ global_object_square_logger.logger.error(http_error, exc_info=True)
648
+ """
649
+ rollback logic
650
+ """
651
+ # pass
652
+ return JSONResponse(
653
+ status_code=http_error.response.status_code,
654
+ content=json.loads(http_error.response.content),
655
+ )
656
+ except HTTPException as http_exception:
657
+ global_object_square_logger.logger.error(http_exception, exc_info=True)
658
+ """
659
+ rollback logic
660
+ """
661
+ # pass
662
+ return JSONResponse(
663
+ status_code=http_exception.status_code, content=http_exception.detail
664
+ )
665
+ except Exception as e:
666
+ global_object_square_logger.logger.error(e, exc_info=True)
667
+ """
668
+ rollback logic
669
+ """
670
+ # pass
671
+ output_content = get_api_output_in_standard_format(
672
+ message=messages["GENERIC_500"],
673
+ log=str(e),
674
+ )
675
+ return JSONResponse(
676
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
677
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: square-administration
3
- Version: 3.2.1
3
+ Version: 3.3.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
@@ -20,7 +20,7 @@ Requires-Dist: requests>=2.32.3
20
20
  Requires-Dist: bcrypt>=4.2.0
21
21
  Requires-Dist: pytest>=8.0.0
22
22
  Requires-Dist: httpx>=0.27.2
23
- Requires-Dist: square-commons>=1.0.0
23
+ Requires-Dist: square-commons>=2.1.0
24
24
  Requires-Dist: square-logger>=2.0.0
25
25
  Requires-Dist: square-database-helper>=2.0.0
26
26
  Requires-Dist: square-database-structure>=1.0.0
@@ -44,6 +44,17 @@ pip install square_administration
44
44
 
45
45
  ## changelog
46
46
 
47
+ ### v3.3.0
48
+
49
+ - authentication
50
+ - add new endpoint -> register_login_google_v0.
51
+ - add new endpoint -> reset_password_and_login_using_backup_code_v0.
52
+ - add new endpoint -> reset_password_and_login_using_reset_email_code_v0.
53
+
54
+ ### v3.2.2
55
+
56
+ - remove config.ini and config.testing.ini from version control.
57
+
47
58
  ### v3.2.1
48
59
 
49
60
  - testing
@@ -1,21 +1,21 @@
1
1
  square_administration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- square_administration/configuration.py,sha256=kP2zfEvt-knzrzFIeINI1kz7260eXz_DbNjIjakByEY,4433
2
+ square_administration/configuration.py,sha256=GoeYwDL3EQeInUdGPEKCT9UvA1wY45o-CGVO4OMGvrk,4601
3
3
  square_administration/main.py,sha256=vvKBMn4JkDp8B2L_zwBMIfYaSA41rXxhL3ZFsSv8ly8,1660
4
4
  square_administration/messages.py,sha256=VYjJGW0Kvtjrx1Mw7ekksLVMoxcexLol2OckvqhZ3n0,1063
5
- square_administration/data/config.ini,sha256=kkSbjJP7qR8ah44Oyv2IyCgYfmheYYh4zSU7wD7v3ec,1145
6
- square_administration/data/config.testing.ini,sha256=vdW01yJdCqdI6uK-jXHfWa9B9IJVuecYdx0n3y7dS2k,1193
5
+ square_administration/data/config.sample.ini,sha256=kkSbjJP7qR8ah44Oyv2IyCgYfmheYYh4zSU7wD7v3ec,1145
6
+ square_administration/data/config.testing.sample.ini,sha256=vdW01yJdCqdI6uK-jXHfWa9B9IJVuecYdx0n3y7dS2k,1193
7
7
  square_administration/pydantic_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- square_administration/pydantic_models/authentication.py,sha256=QEfM5ezG45hc_qATXpFIPNPl4bjf8ICW_bY5tY4cqO4,259
8
+ square_administration/pydantic_models/authentication.py,sha256=elgVJC-uELO78uSTmwRK_z42iWzEuSSpdqWIW_hiAnU,649
9
9
  square_administration/pydantic_models/core.py,sha256=HUMrBmfKrXeL-126gE5j2povdVmktn8XLg2tHEdeXTk,344
10
10
  square_administration/routes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- square_administration/routes/authentication.py,sha256=-1B82WgFr78_p2Udq0WbOwD3jcgjK8jXHI7KvhtfuJA,16029
11
+ square_administration/routes/authentication.py,sha256=gI1Y3yr3_NDbcjfq0ABARrn3rkeVuSB58NOcVWZ83rI,21960
12
12
  square_administration/routes/core.py,sha256=H5pfPuPDzSn8-HN40gyI7eDVxFW7821urYq0ceI_TDo,5271
13
13
  square_administration/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  square_administration/utils/common.py,sha256=bnyBF10EDMLIYXnfV3ZZOApNKScHRmw-Jcj2zIFE8kE,1157
15
15
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- tests/conftest.py,sha256=Lu7qQkrnSeV1WKlN0zVyNLLXRf3Sv8ghPlIWAByv1NQ,1921
16
+ tests/conftest.py,sha256=pqL3wk-mb_DPjtTHXWtIcYqVDXqhtM77xFPl3ljbLiw,2010
17
17
  tests/test_1.py,sha256=hikxL01-2dcax594y8ceanjRmLJXvuhLpcY-FMPIdY8,378
18
- square_administration-3.2.1.dist-info/METADATA,sha256=NzJek8yM3W4b1tqj7kRkXvXxc7-HhWnvmcZN6PQQLQM,3011
19
- square_administration-3.2.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
20
- square_administration-3.2.1.dist-info/top_level.txt,sha256=tyroqpdXXQAiA7Y_V1wCqPPt6nnS_orcY9txLeHjm1s,28
21
- square_administration-3.2.1.dist-info/RECORD,,
18
+ square_administration-3.3.0.dist-info/METADATA,sha256=5sFbRXJ2WJ0uQjJ-cJwIwY1sENyU-Xhvqpeg3JkGigQ,3322
19
+ square_administration-3.3.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
20
+ square_administration-3.3.0.dist-info/top_level.txt,sha256=tyroqpdXXQAiA7Y_V1wCqPPt6nnS_orcY9txLeHjm1s,28
21
+ square_administration-3.3.0.dist-info/RECORD,,
tests/conftest.py CHANGED
@@ -11,6 +11,8 @@ def get_patched_configuration():
11
11
  *rest, last = args
12
12
  if last == "config.ini":
13
13
  last = "config.testing.ini"
14
+ elif last == "config.sample.ini":
15
+ last = "config.testing.sample.ini"
14
16
 
15
17
  return original_join(*rest, last)
16
18