square-authentication 3.0.0__py3-none-any.whl → 4.0.1__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_authentication/pydantic_models/core.py +1 -0
- square_authentication/routes/core.py +67 -35
- {square_authentication-3.0.0.dist-info → square_authentication-4.0.1.dist-info}/METADATA +11 -1
- {square_authentication-3.0.0.dist-info → square_authentication-4.0.1.dist-info}/RECORD +6 -6
- {square_authentication-3.0.0.dist-info → square_authentication-4.0.1.dist-info}/WHEEL +1 -1
- {square_authentication-3.0.0.dist-info → square_authentication-4.0.1.dist-info}/top_level.txt +0 -0
@@ -5,12 +5,13 @@ import bcrypt
|
|
5
5
|
import jwt
|
6
6
|
from fastapi import APIRouter, status, Header, HTTPException
|
7
7
|
from fastapi.responses import JSONResponse
|
8
|
+
from requests import HTTPError
|
8
9
|
from square_commons import get_api_output_in_standard_format
|
9
|
-
from
|
10
|
+
from square_database_helper.main import SquareDatabaseHelper
|
11
|
+
from square_database_helper.pydantic_models import (
|
10
12
|
FiltersV0,
|
11
13
|
FilterConditionsV0,
|
12
14
|
)
|
13
|
-
from square_database_helper.main import SquareDatabaseHelper
|
14
15
|
from square_database_structure.square import global_string_database_name
|
15
16
|
from square_database_structure.square.authentication import global_string_schema_name
|
16
17
|
from square_database_structure.square.authentication.tables import (
|
@@ -79,7 +80,7 @@ async def register_username_v0(
|
|
79
80
|
schema_name=global_string_schema_name,
|
80
81
|
table_name=UserCredential.__tablename__,
|
81
82
|
filters=FiltersV0(
|
82
|
-
{
|
83
|
+
root={
|
83
84
|
UserCredential.user_credential_username.name: FilterConditionsV0(
|
84
85
|
eq=username
|
85
86
|
)
|
@@ -222,7 +223,7 @@ async def register_username_v0(
|
|
222
223
|
schema_name=global_string_schema_name,
|
223
224
|
table_name=User.__tablename__,
|
224
225
|
filters=FiltersV0(
|
225
|
-
{User.user_id.name: FilterConditionsV0(eq=local_str_user_id)}
|
226
|
+
root={User.user_id.name: FilterConditionsV0(eq=local_str_user_id)}
|
226
227
|
),
|
227
228
|
)
|
228
229
|
output_content = get_api_output_in_standard_format(
|
@@ -264,7 +265,9 @@ async def get_user_details_v0(
|
|
264
265
|
database_name=global_string_database_name,
|
265
266
|
schema_name=global_string_schema_name,
|
266
267
|
table_name=UserApp.__tablename__,
|
267
|
-
filters=FiltersV0(
|
268
|
+
filters=FiltersV0(
|
269
|
+
root={UserApp.user_id.name: FilterConditionsV0(eq=user_id)}
|
270
|
+
),
|
268
271
|
)["data"]["main"]
|
269
272
|
local_list_response_user_credentials = (
|
270
273
|
global_object_square_database_helper.get_rows_v0(
|
@@ -272,19 +275,21 @@ async def get_user_details_v0(
|
|
272
275
|
schema_name=global_string_schema_name,
|
273
276
|
table_name=UserCredential.__tablename__,
|
274
277
|
filters=FiltersV0(
|
275
|
-
{UserCredential.user_id.name: FilterConditionsV0(eq=user_id)}
|
278
|
+
root={UserCredential.user_id.name: FilterConditionsV0(eq=user_id)}
|
276
279
|
),
|
277
280
|
)["data"]["main"]
|
278
281
|
)
|
279
|
-
# not putting filter for expiry refresh tokens
|
280
282
|
local_list_response_user_sessions = (
|
281
283
|
global_object_square_database_helper.get_rows_v0(
|
282
284
|
database_name=global_string_database_name,
|
283
285
|
schema_name=global_string_schema_name,
|
284
286
|
table_name=UserSession.__tablename__,
|
285
287
|
filters=FiltersV0(
|
286
|
-
{
|
288
|
+
root={
|
287
289
|
UserSession.user_id.name: FilterConditionsV0(eq=user_id),
|
290
|
+
UserSession.user_session_expiry_time.name: FilterConditionsV0(
|
291
|
+
gte=datetime.now(timezone.utc).isoformat()
|
292
|
+
),
|
288
293
|
}
|
289
294
|
),
|
290
295
|
)["data"]["main"]
|
@@ -303,7 +308,7 @@ async def get_user_details_v0(
|
|
303
308
|
"sessions": [
|
304
309
|
{
|
305
310
|
"app_id": x[UserApp.app_id.name],
|
306
|
-
"
|
311
|
+
"active_sessions": len(
|
307
312
|
[
|
308
313
|
y
|
309
314
|
for y in local_list_response_user_sessions
|
@@ -390,7 +395,7 @@ async def update_user_app_ids_v0(
|
|
390
395
|
schema_name=global_string_public_schema_name,
|
391
396
|
table_name=App.__tablename__,
|
392
397
|
apply_filters=False,
|
393
|
-
filters=FiltersV0({}),
|
398
|
+
filters=FiltersV0(root={}),
|
394
399
|
)["data"]["main"]
|
395
400
|
local_list_invalid_ids = [
|
396
401
|
x
|
@@ -414,7 +419,9 @@ async def update_user_app_ids_v0(
|
|
414
419
|
database_name=global_string_database_name,
|
415
420
|
schema_name=global_string_schema_name,
|
416
421
|
table_name=UserApp.__tablename__,
|
417
|
-
filters=FiltersV0(
|
422
|
+
filters=FiltersV0(
|
423
|
+
root={UserApp.user_id.name: FilterConditionsV0(eq=user_id)}
|
424
|
+
),
|
418
425
|
)["data"]["main"]
|
419
426
|
local_list_new_app_ids = [
|
420
427
|
{
|
@@ -439,7 +446,7 @@ async def update_user_app_ids_v0(
|
|
439
446
|
schema_name=global_string_schema_name,
|
440
447
|
table_name=UserApp.__tablename__,
|
441
448
|
filters=FiltersV0(
|
442
|
-
{
|
449
|
+
root={
|
443
450
|
UserApp.user_id.name: FilterConditionsV0(eq=user_id),
|
444
451
|
UserApp.app_id.name: FilterConditionsV0(eq=app_id),
|
445
452
|
}
|
@@ -451,7 +458,7 @@ async def update_user_app_ids_v0(
|
|
451
458
|
schema_name=global_string_schema_name,
|
452
459
|
table_name=UserSession.__tablename__,
|
453
460
|
filters=FiltersV0(
|
454
|
-
{
|
461
|
+
root={
|
455
462
|
UserSession.user_id.name: FilterConditionsV0(eq=user_id),
|
456
463
|
UserSession.app_id.name: FilterConditionsV0(eq=app_id),
|
457
464
|
}
|
@@ -466,7 +473,9 @@ async def update_user_app_ids_v0(
|
|
466
473
|
database_name=global_string_database_name,
|
467
474
|
schema_name=global_string_schema_name,
|
468
475
|
table_name=UserApp.__tablename__,
|
469
|
-
filters=FiltersV0(
|
476
|
+
filters=FiltersV0(
|
477
|
+
root={UserApp.user_id.name: FilterConditionsV0(eq=user_id)}
|
478
|
+
),
|
470
479
|
)["data"]["main"]
|
471
480
|
output_content = get_api_output_in_standard_format(
|
472
481
|
message=messages["GENERIC_UPDATE_SUCCESSFUL"],
|
@@ -497,12 +506,13 @@ async def update_user_app_ids_v0(
|
|
497
506
|
)
|
498
507
|
|
499
508
|
|
500
|
-
@router.
|
509
|
+
@router.post("/login_username/v0")
|
501
510
|
@global_object_square_logger.async_auto_logger
|
502
511
|
async def login_username_v0(body: LoginUsernameV0):
|
503
512
|
username = body.username
|
504
513
|
password = body.password
|
505
514
|
app_id = body.app_id
|
515
|
+
assign_app_id_if_missing = body.assign_app_id_if_missing
|
506
516
|
username = username.lower()
|
507
517
|
try:
|
508
518
|
"""
|
@@ -514,7 +524,7 @@ async def login_username_v0(body: LoginUsernameV0):
|
|
514
524
|
schema_name=global_string_schema_name,
|
515
525
|
table_name=UserCredential.__tablename__,
|
516
526
|
filters=FiltersV0(
|
517
|
-
{
|
527
|
+
root={
|
518
528
|
UserCredential.user_credential_username.name: FilterConditionsV0(
|
519
529
|
eq=username
|
520
530
|
)
|
@@ -542,20 +552,42 @@ async def login_username_v0(body: LoginUsernameV0):
|
|
542
552
|
schema_name=global_string_schema_name,
|
543
553
|
table_name=UserApp.__tablename__,
|
544
554
|
filters=FiltersV0(
|
545
|
-
{
|
555
|
+
root={
|
546
556
|
UserApp.user_id.name: FilterConditionsV0(eq=local_str_user_id),
|
547
557
|
UserApp.app_id.name: FilterConditionsV0(eq=app_id),
|
548
558
|
}
|
549
559
|
),
|
550
560
|
)["data"]["main"]
|
551
|
-
if len(local_list_user_app_response)
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
561
|
+
if len(local_list_user_app_response) == 0:
|
562
|
+
if assign_app_id_if_missing:
|
563
|
+
try:
|
564
|
+
global_object_square_database_helper.insert_rows_v0(
|
565
|
+
database_name=global_string_database_name,
|
566
|
+
schema_name=global_string_schema_name,
|
567
|
+
table_name=UserApp.__tablename__,
|
568
|
+
data=[
|
569
|
+
{
|
570
|
+
UserApp.user_id.name: local_str_user_id,
|
571
|
+
UserApp.app_id.name: app_id,
|
572
|
+
}
|
573
|
+
],
|
574
|
+
)
|
575
|
+
except HTTPError as he:
|
576
|
+
output_content = get_api_output_in_standard_format(
|
577
|
+
message=messages["GENERIC_400"],
|
578
|
+
log=str(he),
|
579
|
+
)
|
580
|
+
return JSONResponse(
|
581
|
+
status_code=he.response.status_code, content=output_content
|
582
|
+
)
|
583
|
+
else:
|
584
|
+
output_content = get_api_output_in_standard_format(
|
585
|
+
message=messages["GENERIC_400"],
|
586
|
+
log=f"user_id {local_str_user_id}({username}) not assigned to app {app_id}.",
|
587
|
+
)
|
588
|
+
return JSONResponse(
|
589
|
+
status_code=status.HTTP_400_BAD_REQUEST, content=output_content
|
590
|
+
)
|
559
591
|
|
560
592
|
# validate password
|
561
593
|
if not (
|
@@ -673,7 +705,7 @@ async def generate_access_token_v0(
|
|
673
705
|
schema_name=global_string_schema_name,
|
674
706
|
table_name=UserSession.__tablename__,
|
675
707
|
filters=FiltersV0(
|
676
|
-
{
|
708
|
+
root={
|
677
709
|
UserSession.user_session_refresh_token.name: FilterConditionsV0(
|
678
710
|
eq=refresh_token
|
679
711
|
),
|
@@ -763,7 +795,7 @@ async def logout_v0(
|
|
763
795
|
schema_name=global_string_schema_name,
|
764
796
|
table_name=UserSession.__tablename__,
|
765
797
|
filters=FiltersV0(
|
766
|
-
{
|
798
|
+
root={
|
767
799
|
UserSession.user_session_refresh_token.name: FilterConditionsV0(
|
768
800
|
eq=refresh_token
|
769
801
|
),
|
@@ -807,7 +839,7 @@ async def logout_v0(
|
|
807
839
|
schema_name=global_string_schema_name,
|
808
840
|
table_name=UserSession.__tablename__,
|
809
841
|
filters=FiltersV0(
|
810
|
-
{
|
842
|
+
root={
|
811
843
|
UserSession.user_session_refresh_token.name: FilterConditionsV0(
|
812
844
|
eq=refresh_token
|
813
845
|
),
|
@@ -870,7 +902,7 @@ async def update_username_v0(
|
|
870
902
|
schema_name=global_string_schema_name,
|
871
903
|
table_name=User.__tablename__,
|
872
904
|
filters=FiltersV0(
|
873
|
-
{
|
905
|
+
root={
|
874
906
|
User.user_id.name: FilterConditionsV0(eq=user_id),
|
875
907
|
}
|
876
908
|
),
|
@@ -892,7 +924,7 @@ async def update_username_v0(
|
|
892
924
|
schema_name=global_string_schema_name,
|
893
925
|
table_name=UserCredential.__tablename__,
|
894
926
|
filters=FiltersV0(
|
895
|
-
{
|
927
|
+
root={
|
896
928
|
UserCredential.user_credential_username.name: FilterConditionsV0(
|
897
929
|
eq=new_username
|
898
930
|
),
|
@@ -921,7 +953,7 @@ async def update_username_v0(
|
|
921
953
|
schema_name=global_string_schema_name,
|
922
954
|
table_name=UserCredential.__tablename__,
|
923
955
|
filters=FiltersV0(
|
924
|
-
{
|
956
|
+
root={
|
925
957
|
UserCredential.user_id.name: FilterConditionsV0(eq=user_id),
|
926
958
|
}
|
927
959
|
),
|
@@ -988,7 +1020,7 @@ async def delete_user_v0(
|
|
988
1020
|
schema_name=global_string_schema_name,
|
989
1021
|
table_name=UserCredential.__tablename__,
|
990
1022
|
filters=FiltersV0(
|
991
|
-
{UserCredential.user_id.name: FilterConditionsV0(eq=user_id)}
|
1023
|
+
root={UserCredential.user_id.name: FilterConditionsV0(eq=user_id)}
|
992
1024
|
),
|
993
1025
|
)["data"]["main"]
|
994
1026
|
)
|
@@ -1028,7 +1060,7 @@ async def delete_user_v0(
|
|
1028
1060
|
schema_name=global_string_schema_name,
|
1029
1061
|
table_name=User.__tablename__,
|
1030
1062
|
filters=FiltersV0(
|
1031
|
-
{
|
1063
|
+
root={
|
1032
1064
|
User.user_id.name: FilterConditionsV0(eq=user_id),
|
1033
1065
|
}
|
1034
1066
|
),
|
@@ -1093,7 +1125,7 @@ async def update_password_v0(
|
|
1093
1125
|
schema_name=global_string_schema_name,
|
1094
1126
|
table_name=UserCredential.__tablename__,
|
1095
1127
|
filters=FiltersV0(
|
1096
|
-
{UserCredential.user_id.name: FilterConditionsV0(eq=user_id)}
|
1128
|
+
root={UserCredential.user_id.name: FilterConditionsV0(eq=user_id)}
|
1097
1129
|
),
|
1098
1130
|
)["data"]["main"]
|
1099
1131
|
)
|
@@ -1136,7 +1168,7 @@ async def update_password_v0(
|
|
1136
1168
|
schema_name=global_string_schema_name,
|
1137
1169
|
table_name=UserCredential.__tablename__,
|
1138
1170
|
filters=FiltersV0(
|
1139
|
-
{
|
1171
|
+
root={
|
1140
1172
|
UserCredential.user_id.name: FilterConditionsV0(eq=user_id),
|
1141
1173
|
}
|
1142
1174
|
),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: square-authentication
|
3
|
-
Version:
|
3
|
+
Version: 4.0.1
|
4
4
|
Summary: authentication layer for my personal server.
|
5
5
|
Home-page: https://github.com/thepmsquare/square_authentication
|
6
6
|
Author: thePmSquare
|
@@ -43,6 +43,16 @@ pip install square_authentication
|
|
43
43
|
|
44
44
|
## changelog
|
45
45
|
|
46
|
+
### v4.0.1
|
47
|
+
|
48
|
+
- bugfix in pydantic model import.
|
49
|
+
|
50
|
+
### v4.0.0
|
51
|
+
|
52
|
+
- /login_username/v0 is now POST method.
|
53
|
+
- new flag in /login_username/v0 assign_app_id_if_missing.
|
54
|
+
- bugfix: /get_user_details/v0 now only returns number of active sessions.
|
55
|
+
|
46
56
|
### v3.0.0
|
47
57
|
|
48
58
|
- added new endpoints
|
@@ -4,14 +4,14 @@ square_authentication/main.py,sha256=JK9KBmN73KL8EpKrXrjrwwf37bmC4AXrFHtfl2roYwQ
|
|
4
4
|
square_authentication/messages.py,sha256=BA9KC0vW9UD1ZXT4VneVqVNLlgdbMdsAwAgxhJISLf4,1175
|
5
5
|
square_authentication/data/config.ini,sha256=_740RvKpL5W2bUDGwZ7ePwuP-mAasr5cXXB81yq_Jv8,906
|
6
6
|
square_authentication/pydantic_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
square_authentication/pydantic_models/core.py,sha256=
|
7
|
+
square_authentication/pydantic_models/core.py,sha256=Hwzr-YJH6GVGLp4Z29iHItOEhiEvk65MjsttmCaDTe4,431
|
8
8
|
square_authentication/routes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
square_authentication/routes/core.py,sha256=
|
9
|
+
square_authentication/routes/core.py,sha256=Yki554LnBEv1RkwwPkSTksCbXMtgheka4_No41XVbe0,44742
|
10
10
|
square_authentication/routes/utility.py,sha256=Kx4S4tZ1GKsPoC8CoZ4fkLEebvr02KeFEPePtTHtpnQ,75
|
11
11
|
square_authentication/utils/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
12
12
|
square_authentication/utils/encryption.py,sha256=T6BShoUr_xeGpbfPgTK-GxTlXPwcjwU4c4KW7KPzrF8,1865
|
13
13
|
square_authentication/utils/token.py,sha256=Y_arg5LegX-aprMj9YweUK8jjNZLGDjLUGgxbUA12w4,560
|
14
|
-
square_authentication-
|
15
|
-
square_authentication-
|
16
|
-
square_authentication-
|
17
|
-
square_authentication-
|
14
|
+
square_authentication-4.0.1.dist-info/METADATA,sha256=jJswgaCL5ieluh7o0KkQ4THyr0FlaKdc57-1hQNfttA,2858
|
15
|
+
square_authentication-4.0.1.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
|
16
|
+
square_authentication-4.0.1.dist-info/top_level.txt,sha256=wDssVJIl9KIEJPj5rR3rv4uRI7yCndMBrvHd_6BGXQA,22
|
17
|
+
square_authentication-4.0.1.dist-info/RECORD,,
|
{square_authentication-3.0.0.dist-info → square_authentication-4.0.1.dist-info}/top_level.txt
RENAMED
File without changes
|