square-authentication 5.1.4__tar.gz → 5.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.
- {square_authentication-5.1.4 → square_authentication-5.2.0}/PKG-INFO +41 -6
- {square_authentication-5.1.4 → square_authentication-5.2.0}/README.md +16 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/setup.py +4 -2
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/configuration.py +26 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/data/config.ini +7 -1
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/main.py +3 -2
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/messages.py +2 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/routes/core.py +16 -23
- square_authentication-5.2.0/square_authentication/routes/profile.py +134 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/routes/utility.py +1 -1
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/utils/encryption.py +2 -2
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/utils/token.py +1 -1
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication.egg-info/PKG-INFO +42 -7
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication.egg-info/SOURCES.txt +3 -1
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication.egg-info/requires.txt +3 -1
- square_authentication-5.2.0/tests/test_1.py +17 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/setup.cfg +0 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/__init__.py +0 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/pydantic_models/__init__.py +0 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/pydantic_models/core.py +0 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/routes/__init__.py +0 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/utils/__init__.py +0 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication.egg-info/dependency_links.txt +0 -0
- {square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication.egg-info/top_level.txt +0 -0
@@ -1,18 +1,39 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: square_authentication
|
3
|
-
Version: 5.
|
3
|
+
Version: 5.2.0
|
4
4
|
Summary: authentication layer for my personal server.
|
5
5
|
Home-page: https://github.com/thepmsquare/square_authentication
|
6
6
|
Author: thePmSquare
|
7
7
|
Author-email: thepmsquare@gmail.com
|
8
|
-
License: UNKNOWN
|
9
|
-
Platform: UNKNOWN
|
10
8
|
Classifier: Development Status :: 3 - Alpha
|
11
9
|
Classifier: Intended Audience :: Developers
|
12
10
|
Classifier: License :: OSI Approved :: MIT License
|
13
11
|
Classifier: Programming Language :: Python :: 3
|
14
12
|
Classifier: Programming Language :: Python :: 3.9
|
15
13
|
Description-Content-Type: text/markdown
|
14
|
+
Requires-Dist: uvicorn>=0.24.0.post1
|
15
|
+
Requires-Dist: fastapi>=0.104.1
|
16
|
+
Requires-Dist: python-multipart>=0.0.6
|
17
|
+
Requires-Dist: pydantic>=2.5.3
|
18
|
+
Requires-Dist: bcrypt>=4.1.2
|
19
|
+
Requires-Dist: pyjwt>=2.8.0
|
20
|
+
Requires-Dist: requests>=2.32.3
|
21
|
+
Requires-Dist: cryptography>=42.0.7
|
22
|
+
Requires-Dist: square_commons>=1.0.0
|
23
|
+
Requires-Dist: square_logger>=2.0.0
|
24
|
+
Requires-Dist: square_database_helper>=2.0.0
|
25
|
+
Requires-Dist: square_database_structure>=2.3.1
|
26
|
+
Requires-Dist: square_file_store_helper>=2.1.0
|
27
|
+
Requires-Dist: pytest>=8.0.0
|
28
|
+
Requires-Dist: httpx>=0.27.2
|
29
|
+
Dynamic: author
|
30
|
+
Dynamic: author-email
|
31
|
+
Dynamic: classifier
|
32
|
+
Dynamic: description
|
33
|
+
Dynamic: description-content-type
|
34
|
+
Dynamic: home-page
|
35
|
+
Dynamic: requires-dist
|
36
|
+
Dynamic: summary
|
16
37
|
|
17
38
|
# square_authentication
|
18
39
|
|
@@ -32,6 +53,22 @@ pip install square_authentication
|
|
32
53
|
|
33
54
|
## changelog
|
34
55
|
|
56
|
+
### v5.2.0
|
57
|
+
|
58
|
+
- add temp folder to .gitignore.
|
59
|
+
- add square_file_store_helper as a dependency.
|
60
|
+
- config
|
61
|
+
- add config section for file store helper.
|
62
|
+
- initialise file store helper and database helper in config.py
|
63
|
+
- add profile router
|
64
|
+
- profile
|
65
|
+
- add update_profile_photo/v0
|
66
|
+
- update messages.
|
67
|
+
|
68
|
+
### v5.1.5
|
69
|
+
|
70
|
+
- bump square_logger to >=2.0.0.
|
71
|
+
|
35
72
|
### v5.1.4
|
36
73
|
|
37
74
|
- re bug fix v5.1.3
|
@@ -139,5 +176,3 @@ pip install square_authentication
|
|
139
176
|
- initial implementation.
|
140
177
|
|
141
178
|
## Feedback is appreciated. Thank you!
|
142
|
-
|
143
|
-
|
@@ -16,6 +16,22 @@ pip install square_authentication
|
|
16
16
|
|
17
17
|
## changelog
|
18
18
|
|
19
|
+
### v5.2.0
|
20
|
+
|
21
|
+
- add temp folder to .gitignore.
|
22
|
+
- add square_file_store_helper as a dependency.
|
23
|
+
- config
|
24
|
+
- add config section for file store helper.
|
25
|
+
- initialise file store helper and database helper in config.py
|
26
|
+
- add profile router
|
27
|
+
- profile
|
28
|
+
- add update_profile_photo/v0
|
29
|
+
- update messages.
|
30
|
+
|
31
|
+
### v5.1.5
|
32
|
+
|
33
|
+
- bump square_logger to >=2.0.0.
|
34
|
+
|
19
35
|
### v5.1.4
|
20
36
|
|
21
37
|
- re bug fix v5.1.3
|
@@ -4,7 +4,7 @@ package_name = "square_authentication"
|
|
4
4
|
|
5
5
|
setup(
|
6
6
|
name=package_name,
|
7
|
-
version="5.
|
7
|
+
version="5.2.0",
|
8
8
|
packages=find_packages(),
|
9
9
|
package_data={
|
10
10
|
package_name: ["data/*"],
|
@@ -12,15 +12,17 @@ setup(
|
|
12
12
|
install_requires=[
|
13
13
|
"uvicorn>=0.24.0.post1",
|
14
14
|
"fastapi>=0.104.1",
|
15
|
+
"python-multipart>=0.0.6",
|
15
16
|
"pydantic>=2.5.3",
|
16
17
|
"bcrypt>=4.1.2",
|
17
18
|
"pyjwt>=2.8.0",
|
18
19
|
"requests>=2.32.3",
|
19
20
|
"cryptography>=42.0.7",
|
20
21
|
"square_commons>=1.0.0",
|
21
|
-
"square_logger>=
|
22
|
+
"square_logger>=2.0.0",
|
22
23
|
"square_database_helper>=2.0.0",
|
23
24
|
"square_database_structure>=2.3.1",
|
25
|
+
"square_file_store_helper>=2.1.0",
|
24
26
|
"pytest>=8.0.0",
|
25
27
|
"httpx>=0.27.2",
|
26
28
|
],
|
{square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/configuration.py
RENAMED
@@ -2,6 +2,8 @@ import os
|
|
2
2
|
import sys
|
3
3
|
|
4
4
|
from square_commons import ConfigReader
|
5
|
+
from square_database_helper import SquareDatabaseHelper
|
6
|
+
from square_file_store_helper import SquareFileStoreHelper
|
5
7
|
from square_logger.main import SquareLogger
|
6
8
|
|
7
9
|
try:
|
@@ -67,6 +69,20 @@ try:
|
|
67
69
|
ldict_configuration["SQUARE_DATABASE_HELPER"]["SQUARE_DATABASE_PORT"]
|
68
70
|
)
|
69
71
|
# ===========================================
|
72
|
+
|
73
|
+
# ===========================================
|
74
|
+
# square_file_store_helper
|
75
|
+
|
76
|
+
config_str_square_file_store_protocol = ldict_configuration[
|
77
|
+
"SQUARE_FILE_STORE_HELPER"
|
78
|
+
]["SQUARE_FILE_STORE_PROTOCOL"]
|
79
|
+
config_str_square_file_store_ip = ldict_configuration["SQUARE_FILE_STORE_HELPER"][
|
80
|
+
"SQUARE_FILE_STORE_IP"
|
81
|
+
]
|
82
|
+
config_int_square_file_store_port = int(
|
83
|
+
ldict_configuration["SQUARE_FILE_STORE_HELPER"]["SQUARE_FILE_STORE_PORT"]
|
84
|
+
)
|
85
|
+
# ===========================================
|
70
86
|
# Initialize logger
|
71
87
|
global_object_square_logger = SquareLogger(
|
72
88
|
pstr_log_file_name=config_str_log_file_name,
|
@@ -74,6 +90,16 @@ try:
|
|
74
90
|
pstr_log_path=config_str_log_path,
|
75
91
|
pint_log_backup_count=config_int_log_backup_count,
|
76
92
|
)
|
93
|
+
global_object_square_database_helper = SquareDatabaseHelper(
|
94
|
+
param_str_square_database_ip=config_str_square_database_ip,
|
95
|
+
param_int_square_database_port=config_int_square_database_port,
|
96
|
+
param_str_square_database_protocol=config_str_square_database_protocol,
|
97
|
+
)
|
98
|
+
global_object_square_file_store_helper = SquareFileStoreHelper(
|
99
|
+
param_str_square_file_store_protocol=config_str_square_file_store_protocol,
|
100
|
+
param_str_square_file_store_ip=config_str_square_file_store_ip,
|
101
|
+
param_int_square_file_store_port=config_int_square_file_store_port,
|
102
|
+
)
|
77
103
|
except Exception as e:
|
78
104
|
print(
|
79
105
|
"\033[91mMissing or incorrect config.ini file.\n"
|
{square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/data/config.ini
RENAMED
@@ -39,4 +39,10 @@ LOG_BACKUP_COUNT = 3
|
|
39
39
|
|
40
40
|
SQUARE_DATABASE_PROTOCOL = http
|
41
41
|
SQUARE_DATABASE_IP = localhost
|
42
|
-
SQUARE_DATABASE_PORT = 10010
|
42
|
+
SQUARE_DATABASE_PORT = 10010
|
43
|
+
|
44
|
+
[SQUARE_FILE_STORE_HELPER]
|
45
|
+
|
46
|
+
SQUARE_FILE_STORE_PROTOCOL = http
|
47
|
+
SQUARE_FILE_STORE_IP = localhost
|
48
|
+
SQUARE_FILE_STORE_PORT = 10100
|
@@ -14,7 +14,7 @@ from square_authentication.configuration import (
|
|
14
14
|
config_str_ssl_key_file_path,
|
15
15
|
config_str_ssl_crt_file_path,
|
16
16
|
)
|
17
|
-
from square_authentication.routes import core, utility
|
17
|
+
from square_authentication.routes import core, utility, profile
|
18
18
|
|
19
19
|
app = FastAPI()
|
20
20
|
|
@@ -28,10 +28,11 @@ app.add_middleware(
|
|
28
28
|
|
29
29
|
app.include_router(core.router)
|
30
30
|
app.include_router(utility.router)
|
31
|
+
app.include_router(profile.router)
|
31
32
|
|
32
33
|
|
33
34
|
@app.get("/")
|
34
|
-
@global_object_square_logger.
|
35
|
+
@global_object_square_logger.auto_logger()
|
35
36
|
async def root():
|
36
37
|
output_content = get_api_output_in_standard_format(log=config_str_module_name)
|
37
38
|
return JSONResponse(status_code=status.HTTP_200_OK, content=output_content)
|
{square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/messages.py
RENAMED
@@ -14,4 +14,6 @@ messages = {
|
|
14
14
|
"GENERIC_DELETE_SUCCESSFUL": "your records have been deleted successfully.",
|
15
15
|
"GENERIC_400": "the request is invalid or cannot be processed.",
|
16
16
|
"GENERIC_500": "an internal server error occurred. please try again later.",
|
17
|
+
"INVALID_FILE_FORMAT": "the file format is not supported. please upload a valid file.",
|
18
|
+
"FILE_SIZE_EXCEEDS_LIMIT": "the file size exceeds the limit. please upload a smaller file.",
|
17
19
|
}
|
{square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/routes/core.py
RENAMED
@@ -8,7 +8,6 @@ from fastapi.params import Query
|
|
8
8
|
from fastapi.responses import JSONResponse
|
9
9
|
from requests import HTTPError
|
10
10
|
from square_commons import get_api_output_in_standard_format
|
11
|
-
from square_database_helper.main import SquareDatabaseHelper
|
12
11
|
from square_database_helper.pydantic_models import FilterConditionsV0, FiltersV0
|
13
12
|
from square_database_structure.square import global_string_database_name
|
14
13
|
from square_database_structure.square.authentication import global_string_schema_name
|
@@ -27,12 +26,10 @@ from square_database_structure.square.public.tables import App
|
|
27
26
|
from square_authentication.configuration import (
|
28
27
|
config_int_access_token_valid_minutes,
|
29
28
|
config_int_refresh_token_valid_minutes,
|
30
|
-
config_int_square_database_port,
|
31
29
|
config_str_secret_key_for_access_token,
|
32
30
|
config_str_secret_key_for_refresh_token,
|
33
|
-
config_str_square_database_ip,
|
34
|
-
config_str_square_database_protocol,
|
35
31
|
global_object_square_logger,
|
32
|
+
global_object_square_database_helper,
|
36
33
|
)
|
37
34
|
from square_authentication.messages import messages
|
38
35
|
from square_authentication.pydantic_models.core import (
|
@@ -49,15 +46,9 @@ router = APIRouter(
|
|
49
46
|
tags=["core"],
|
50
47
|
)
|
51
48
|
|
52
|
-
global_object_square_database_helper = SquareDatabaseHelper(
|
53
|
-
param_str_square_database_ip=config_str_square_database_ip,
|
54
|
-
param_int_square_database_port=config_int_square_database_port,
|
55
|
-
param_str_square_database_protocol=config_str_square_database_protocol,
|
56
|
-
)
|
57
|
-
|
58
49
|
|
59
50
|
@router.post("/register_username/v0")
|
60
|
-
@global_object_square_logger.
|
51
|
+
@global_object_square_logger.auto_logger()
|
61
52
|
async def register_username_v0(
|
62
53
|
body: RegisterUsernameV0,
|
63
54
|
):
|
@@ -246,7 +237,7 @@ async def register_username_v0(
|
|
246
237
|
|
247
238
|
|
248
239
|
@router.get("/get_user_details/v0")
|
249
|
-
@global_object_square_logger.
|
240
|
+
@global_object_square_logger.auto_logger()
|
250
241
|
async def get_user_details_v0(
|
251
242
|
access_token: Annotated[str, Header()],
|
252
243
|
):
|
@@ -374,7 +365,7 @@ async def get_user_details_v0(
|
|
374
365
|
|
375
366
|
|
376
367
|
@router.patch("/update_user_app_ids/v0")
|
377
|
-
@global_object_square_logger.
|
368
|
+
@global_object_square_logger.auto_logger()
|
378
369
|
async def update_user_app_ids_v0(
|
379
370
|
access_token: Annotated[str, Header()],
|
380
371
|
app_ids_to_add: List[int],
|
@@ -535,7 +526,7 @@ async def update_user_app_ids_v0(
|
|
535
526
|
|
536
527
|
|
537
528
|
@router.post("/login_username/v0")
|
538
|
-
@global_object_square_logger.
|
529
|
+
@global_object_square_logger.auto_logger()
|
539
530
|
async def login_username_v0(body: LoginUsernameV0):
|
540
531
|
username = body.username
|
541
532
|
password = body.password
|
@@ -578,7 +569,9 @@ async def login_username_v0(body: LoginUsernameV0):
|
|
578
569
|
filters=FiltersV0(
|
579
570
|
root={
|
580
571
|
UserCredential.user_id.name: FilterConditionsV0(
|
581
|
-
eq=local_list_response_user_profile[0][
|
572
|
+
eq=local_list_response_user_profile[0][
|
573
|
+
UserProfile.user_id.name
|
574
|
+
]
|
582
575
|
)
|
583
576
|
}
|
584
577
|
),
|
@@ -742,7 +735,7 @@ async def login_username_v0(body: LoginUsernameV0):
|
|
742
735
|
|
743
736
|
|
744
737
|
@router.get("/generate_access_token/v0")
|
745
|
-
@global_object_square_logger.
|
738
|
+
@global_object_square_logger.auto_logger()
|
746
739
|
async def generate_access_token_v0(
|
747
740
|
refresh_token: Annotated[str, Header()],
|
748
741
|
):
|
@@ -833,7 +826,7 @@ async def generate_access_token_v0(
|
|
833
826
|
|
834
827
|
|
835
828
|
@router.delete("/logout/v0")
|
836
|
-
@global_object_square_logger.
|
829
|
+
@global_object_square_logger.auto_logger()
|
837
830
|
async def logout_v0(
|
838
831
|
refresh_token: Annotated[str, Header()],
|
839
832
|
):
|
@@ -925,7 +918,7 @@ async def logout_v0(
|
|
925
918
|
|
926
919
|
|
927
920
|
@router.delete("/logout/apps/v0")
|
928
|
-
@global_object_square_logger.
|
921
|
+
@global_object_square_logger.auto_logger()
|
929
922
|
async def logout_apps_v0(
|
930
923
|
access_token: Annotated[str, Header()],
|
931
924
|
body: LogoutAppsV0,
|
@@ -1018,7 +1011,7 @@ async def logout_apps_v0(
|
|
1018
1011
|
|
1019
1012
|
|
1020
1013
|
@router.delete("/logout/all/v0")
|
1021
|
-
@global_object_square_logger.
|
1014
|
+
@global_object_square_logger.auto_logger()
|
1022
1015
|
async def logout_all_v0(
|
1023
1016
|
access_token: Annotated[str, Header()],
|
1024
1017
|
):
|
@@ -1082,7 +1075,7 @@ async def logout_all_v0(
|
|
1082
1075
|
|
1083
1076
|
|
1084
1077
|
@router.patch("/update_username/v0")
|
1085
|
-
@global_object_square_logger.
|
1078
|
+
@global_object_square_logger.auto_logger()
|
1086
1079
|
async def update_username_v0(
|
1087
1080
|
new_username: str,
|
1088
1081
|
access_token: Annotated[str, Header()],
|
@@ -1197,7 +1190,7 @@ async def update_username_v0(
|
|
1197
1190
|
|
1198
1191
|
|
1199
1192
|
@router.delete("/delete_user/v0")
|
1200
|
-
@global_object_square_logger.
|
1193
|
+
@global_object_square_logger.auto_logger()
|
1201
1194
|
async def delete_user_v0(
|
1202
1195
|
body: DeleteUserV0,
|
1203
1196
|
access_token: Annotated[str, Header()],
|
@@ -1303,7 +1296,7 @@ async def delete_user_v0(
|
|
1303
1296
|
|
1304
1297
|
|
1305
1298
|
@router.patch("/update_password/v0")
|
1306
|
-
@global_object_square_logger.
|
1299
|
+
@global_object_square_logger.auto_logger()
|
1307
1300
|
async def update_password_v0(
|
1308
1301
|
body: UpdatePasswordV0,
|
1309
1302
|
access_token: Annotated[str, Header()],
|
@@ -1416,7 +1409,7 @@ async def update_password_v0(
|
|
1416
1409
|
|
1417
1410
|
|
1418
1411
|
@router.get("/validate_and_get_payload_from_token/v0")
|
1419
|
-
@global_object_square_logger.
|
1412
|
+
@global_object_square_logger.auto_logger()
|
1420
1413
|
async def validate_and_get_payload_from_token_v0(
|
1421
1414
|
token: Annotated[str, Header()],
|
1422
1415
|
token_type: TokenType = Query(...),
|
@@ -0,0 +1,134 @@
|
|
1
|
+
import os
|
2
|
+
from typing import Annotated
|
3
|
+
|
4
|
+
from fastapi import APIRouter, HTTPException, status, Header, UploadFile
|
5
|
+
from fastapi.responses import JSONResponse
|
6
|
+
from square_commons import get_api_output_in_standard_format
|
7
|
+
from square_database_helper import FiltersV0
|
8
|
+
from square_database_helper.pydantic_models import FilterConditionsV0
|
9
|
+
from square_database_structure.square import global_string_database_name
|
10
|
+
from square_database_structure.square.authentication import global_string_schema_name
|
11
|
+
from square_database_structure.square.authentication.tables import UserProfile
|
12
|
+
|
13
|
+
from square_authentication.configuration import (
|
14
|
+
global_object_square_logger,
|
15
|
+
config_str_secret_key_for_access_token,
|
16
|
+
global_object_square_file_store_helper,
|
17
|
+
global_object_square_database_helper,
|
18
|
+
)
|
19
|
+
from square_authentication.messages import messages
|
20
|
+
from square_authentication.utils.token import get_jwt_payload
|
21
|
+
|
22
|
+
router = APIRouter(
|
23
|
+
tags=["profile"],
|
24
|
+
)
|
25
|
+
|
26
|
+
|
27
|
+
@router.patch("/update_profile_photo/v0")
|
28
|
+
@global_object_square_logger.auto_logger()
|
29
|
+
async def update_profile_photo_v0(
|
30
|
+
access_token: Annotated[str, Header()],
|
31
|
+
profile_photo: UploadFile,
|
32
|
+
):
|
33
|
+
|
34
|
+
try:
|
35
|
+
"""
|
36
|
+
validation
|
37
|
+
"""
|
38
|
+
# validate access token
|
39
|
+
try:
|
40
|
+
local_dict_access_token_payload = get_jwt_payload(
|
41
|
+
access_token, config_str_secret_key_for_access_token
|
42
|
+
)
|
43
|
+
except Exception as error:
|
44
|
+
output_content = get_api_output_in_standard_format(
|
45
|
+
message=messages["INCORRECT_ACCESS_TOKEN"], log=str(error)
|
46
|
+
)
|
47
|
+
raise HTTPException(
|
48
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
49
|
+
detail=output_content,
|
50
|
+
)
|
51
|
+
user_id = local_dict_access_token_payload["user_id"]
|
52
|
+
|
53
|
+
# validate file format
|
54
|
+
if not profile_photo.filename.endswith((".jpg", ".jpeg", ".png")):
|
55
|
+
output_content = get_api_output_in_standard_format(
|
56
|
+
message=messages["INVALID_FILE_FORMAT"]
|
57
|
+
)
|
58
|
+
raise HTTPException(
|
59
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
60
|
+
detail=output_content,
|
61
|
+
)
|
62
|
+
|
63
|
+
# validate file size
|
64
|
+
file_size_limit_in_mib = 5
|
65
|
+
if profile_photo.size > (file_size_limit_in_mib * 1024 * 1024):
|
66
|
+
output_content = get_api_output_in_standard_format(
|
67
|
+
message=messages["FILE_SIZE_EXCEEDS_LIMIT"]
|
68
|
+
)
|
69
|
+
raise HTTPException(
|
70
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
71
|
+
detail=output_content,
|
72
|
+
)
|
73
|
+
"""
|
74
|
+
main process
|
75
|
+
"""
|
76
|
+
# uploading to square file store
|
77
|
+
destination_path = f"temp/{user_id}/profile_photo/{profile_photo.filename}"
|
78
|
+
os.makedirs(os.path.dirname(destination_path), exist_ok=True)
|
79
|
+
with open(destination_path, "wb") as out_file:
|
80
|
+
content = await profile_photo.read()
|
81
|
+
out_file.write(content)
|
82
|
+
|
83
|
+
file_upload_response = (
|
84
|
+
global_object_square_file_store_helper.upload_file_using_file_path_v0(
|
85
|
+
file_path=destination_path,
|
86
|
+
system_relative_path="global/users/profile_photos",
|
87
|
+
)
|
88
|
+
)
|
89
|
+
os.remove(destination_path)
|
90
|
+
|
91
|
+
# adding file storage token to user profile
|
92
|
+
profile_update_response = global_object_square_database_helper.edit_rows_v0(
|
93
|
+
data={
|
94
|
+
UserProfile.user_profile_photo_storage_token.name: file_upload_response[
|
95
|
+
"data"
|
96
|
+
]["main"]
|
97
|
+
},
|
98
|
+
filters=FiltersV0(
|
99
|
+
{UserProfile.user_id.name: FilterConditionsV0(eq=user_id)}
|
100
|
+
),
|
101
|
+
database_name=global_string_database_name,
|
102
|
+
schema_name=global_string_schema_name,
|
103
|
+
table_name=UserProfile.__tablename__,
|
104
|
+
apply_filters=True,
|
105
|
+
)
|
106
|
+
|
107
|
+
"""
|
108
|
+
return value
|
109
|
+
"""
|
110
|
+
output_content = get_api_output_in_standard_format(
|
111
|
+
data=profile_update_response["data"],
|
112
|
+
message=messages["GENERIC_UPDATE_SUCCESSFUL"],
|
113
|
+
)
|
114
|
+
return JSONResponse(
|
115
|
+
status_code=status.HTTP_200_OK,
|
116
|
+
content=output_content,
|
117
|
+
)
|
118
|
+
except HTTPException as http_exception:
|
119
|
+
global_object_square_logger.logger.error(http_exception, exc_info=True)
|
120
|
+
return JSONResponse(
|
121
|
+
status_code=http_exception.status_code, content=http_exception.detail
|
122
|
+
)
|
123
|
+
except Exception as e:
|
124
|
+
"""
|
125
|
+
rollback logic
|
126
|
+
"""
|
127
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
128
|
+
output_content = get_api_output_in_standard_format(
|
129
|
+
message=messages["GENERIC_500"],
|
130
|
+
log=str(e),
|
131
|
+
)
|
132
|
+
return JSONResponse(
|
133
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
134
|
+
)
|
@@ -7,7 +7,7 @@ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|
7
7
|
from square_authentication.configuration import global_object_square_logger
|
8
8
|
|
9
9
|
|
10
|
-
@global_object_square_logger.auto_logger
|
10
|
+
@global_object_square_logger.auto_logger()
|
11
11
|
def encrypt(key, plaintext):
|
12
12
|
# Ensure the key length is 16, 24, or 32 bytes for AES
|
13
13
|
key = key.ljust(32)[:32].encode('utf-8')
|
@@ -31,7 +31,7 @@ def encrypt(key, plaintext):
|
|
31
31
|
|
32
32
|
return encoded_ciphertext
|
33
33
|
|
34
|
-
@global_object_square_logger.auto_logger
|
34
|
+
@global_object_square_logger.auto_logger()
|
35
35
|
def decrypt(key, encoded_ciphertext):
|
36
36
|
# Ensure the key length is 16, 24, or 32 bytes for AES
|
37
37
|
key = key.ljust(32)[:32].encode('utf-8')
|
{square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/utils/token.py
RENAMED
@@ -4,7 +4,7 @@ from jwt.exceptions import ExpiredSignatureError, DecodeError, InvalidTokenError
|
|
4
4
|
from square_authentication.configuration import global_object_square_logger
|
5
5
|
|
6
6
|
|
7
|
-
@global_object_square_logger.auto_logger
|
7
|
+
@global_object_square_logger.auto_logger()
|
8
8
|
def get_jwt_payload(token, secret_key):
|
9
9
|
try:
|
10
10
|
# Decode the token and verify the signature
|
{square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication.egg-info/PKG-INFO
RENAMED
@@ -1,18 +1,39 @@
|
|
1
|
-
Metadata-Version: 2.
|
2
|
-
Name:
|
3
|
-
Version: 5.
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: square_authentication
|
3
|
+
Version: 5.2.0
|
4
4
|
Summary: authentication layer for my personal server.
|
5
5
|
Home-page: https://github.com/thepmsquare/square_authentication
|
6
6
|
Author: thePmSquare
|
7
7
|
Author-email: thepmsquare@gmail.com
|
8
|
-
License: UNKNOWN
|
9
|
-
Platform: UNKNOWN
|
10
8
|
Classifier: Development Status :: 3 - Alpha
|
11
9
|
Classifier: Intended Audience :: Developers
|
12
10
|
Classifier: License :: OSI Approved :: MIT License
|
13
11
|
Classifier: Programming Language :: Python :: 3
|
14
12
|
Classifier: Programming Language :: Python :: 3.9
|
15
13
|
Description-Content-Type: text/markdown
|
14
|
+
Requires-Dist: uvicorn>=0.24.0.post1
|
15
|
+
Requires-Dist: fastapi>=0.104.1
|
16
|
+
Requires-Dist: python-multipart>=0.0.6
|
17
|
+
Requires-Dist: pydantic>=2.5.3
|
18
|
+
Requires-Dist: bcrypt>=4.1.2
|
19
|
+
Requires-Dist: pyjwt>=2.8.0
|
20
|
+
Requires-Dist: requests>=2.32.3
|
21
|
+
Requires-Dist: cryptography>=42.0.7
|
22
|
+
Requires-Dist: square_commons>=1.0.0
|
23
|
+
Requires-Dist: square_logger>=2.0.0
|
24
|
+
Requires-Dist: square_database_helper>=2.0.0
|
25
|
+
Requires-Dist: square_database_structure>=2.3.1
|
26
|
+
Requires-Dist: square_file_store_helper>=2.1.0
|
27
|
+
Requires-Dist: pytest>=8.0.0
|
28
|
+
Requires-Dist: httpx>=0.27.2
|
29
|
+
Dynamic: author
|
30
|
+
Dynamic: author-email
|
31
|
+
Dynamic: classifier
|
32
|
+
Dynamic: description
|
33
|
+
Dynamic: description-content-type
|
34
|
+
Dynamic: home-page
|
35
|
+
Dynamic: requires-dist
|
36
|
+
Dynamic: summary
|
16
37
|
|
17
38
|
# square_authentication
|
18
39
|
|
@@ -32,6 +53,22 @@ pip install square_authentication
|
|
32
53
|
|
33
54
|
## changelog
|
34
55
|
|
56
|
+
### v5.2.0
|
57
|
+
|
58
|
+
- add temp folder to .gitignore.
|
59
|
+
- add square_file_store_helper as a dependency.
|
60
|
+
- config
|
61
|
+
- add config section for file store helper.
|
62
|
+
- initialise file store helper and database helper in config.py
|
63
|
+
- add profile router
|
64
|
+
- profile
|
65
|
+
- add update_profile_photo/v0
|
66
|
+
- update messages.
|
67
|
+
|
68
|
+
### v5.1.5
|
69
|
+
|
70
|
+
- bump square_logger to >=2.0.0.
|
71
|
+
|
35
72
|
### v5.1.4
|
36
73
|
|
37
74
|
- re bug fix v5.1.3
|
@@ -139,5 +176,3 @@ pip install square_authentication
|
|
139
176
|
- initial implementation.
|
140
177
|
|
141
178
|
## Feedback is appreciated. Thank you!
|
142
|
-
|
143
|
-
|
@@ -14,7 +14,9 @@ square_authentication/pydantic_models/__init__.py
|
|
14
14
|
square_authentication/pydantic_models/core.py
|
15
15
|
square_authentication/routes/__init__.py
|
16
16
|
square_authentication/routes/core.py
|
17
|
+
square_authentication/routes/profile.py
|
17
18
|
square_authentication/routes/utility.py
|
18
19
|
square_authentication/utils/__init__.py
|
19
20
|
square_authentication/utils/encryption.py
|
20
|
-
square_authentication/utils/token.py
|
21
|
+
square_authentication/utils/token.py
|
22
|
+
tests/test_1.py
|
@@ -1,13 +1,15 @@
|
|
1
1
|
uvicorn>=0.24.0.post1
|
2
2
|
fastapi>=0.104.1
|
3
|
+
python-multipart>=0.0.6
|
3
4
|
pydantic>=2.5.3
|
4
5
|
bcrypt>=4.1.2
|
5
6
|
pyjwt>=2.8.0
|
6
7
|
requests>=2.32.3
|
7
8
|
cryptography>=42.0.7
|
8
9
|
square_commons>=1.0.0
|
9
|
-
square_logger>=
|
10
|
+
square_logger>=2.0.0
|
10
11
|
square_database_helper>=2.0.0
|
11
12
|
square_database_structure>=2.3.1
|
13
|
+
square_file_store_helper>=2.1.0
|
12
14
|
pytest>=8.0.0
|
13
15
|
httpx>=0.27.2
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from fastapi.testclient import TestClient
|
2
|
+
from square_commons import get_api_output_in_standard_format
|
3
|
+
|
4
|
+
from square_authentication.configuration import config_str_module_name
|
5
|
+
from square_authentication.main import (
|
6
|
+
app,
|
7
|
+
)
|
8
|
+
|
9
|
+
client = TestClient(app)
|
10
|
+
|
11
|
+
|
12
|
+
def test_read_main():
|
13
|
+
response = client.get("/")
|
14
|
+
assert response.status_code == 200
|
15
|
+
assert response.json() == get_api_output_in_standard_format(
|
16
|
+
log=config_str_module_name
|
17
|
+
)
|
File without changes
|
{square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/routes/__init__.py
RENAMED
File without changes
|
{square_authentication-5.1.4 → square_authentication-5.2.0}/square_authentication/utils/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|