square-authentication 6.0.2__py3-none-any.whl → 6.0.4__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/configuration.py +9 -6
- square_authentication/data/config.ini +5 -0
- square_authentication/data/config.testing.ini +53 -0
- square_authentication/routes/profile.py +51 -32
- {square_authentication-6.0.2.dist-info → square_authentication-6.0.4.dist-info}/METADATA +9 -1
- {square_authentication-6.0.2.dist-info → square_authentication-6.0.4.dist-info}/RECORD +8 -7
- {square_authentication-6.0.2.dist-info → square_authentication-6.0.4.dist-info}/WHEEL +1 -1
- {square_authentication-6.0.2.dist-info → square_authentication-6.0.4.dist-info}/top_level.txt +0 -0
@@ -7,12 +7,8 @@ from square_file_store_helper import SquareFileStoreHelper
|
|
7
7
|
from square_logger.main import SquareLogger
|
8
8
|
|
9
9
|
try:
|
10
|
-
config_file_path = (
|
11
|
-
os.path.dirname(os.path.abspath(__file__))
|
12
|
-
+ os.sep
|
13
|
-
+ "data"
|
14
|
-
+ os.sep
|
15
|
-
+ "config.ini"
|
10
|
+
config_file_path = os.path.join(
|
11
|
+
os.path.dirname(os.path.abspath(__file__)), "data", "config.ini"
|
16
12
|
)
|
17
13
|
ldict_configuration = ConfigReader(config_file_path).read_configuration()
|
18
14
|
|
@@ -45,6 +41,13 @@ try:
|
|
45
41
|
config_str_ssl_key_file_path = ldict_configuration["ENVIRONMENT"][
|
46
42
|
"SSL_KEY_FILE_PATH"
|
47
43
|
]
|
44
|
+
config_str_db_ip = ldict_configuration["ENVIRONMENT"]["DB_IP"]
|
45
|
+
|
46
|
+
config_int_db_port = int(ldict_configuration["ENVIRONMENT"]["DB_PORT"])
|
47
|
+
|
48
|
+
config_str_db_username = ldict_configuration["ENVIRONMENT"]["DB_USERNAME"]
|
49
|
+
|
50
|
+
config_str_db_password = ldict_configuration["ENVIRONMENT"]["DB_PASSWORD"]
|
48
51
|
# ===========================================
|
49
52
|
|
50
53
|
# ===========================================
|
@@ -0,0 +1,53 @@
|
|
1
|
+
[GENERAL]
|
2
|
+
MODULE_NAME = square_authentication
|
3
|
+
|
4
|
+
[ENVIRONMENT]
|
5
|
+
HOST_IP = 0.0.0.0
|
6
|
+
HOST_PORT = 10011
|
7
|
+
|
8
|
+
LOG_FILE_NAME = square_authentication
|
9
|
+
|
10
|
+
SECRET_KEY_FOR_ACCESS_TOKEN = dummy_access
|
11
|
+
SECRET_KEY_FOR_REFRESH_TOKEN = dummy_refresh
|
12
|
+
|
13
|
+
ACCESS_TOKEN_VALID_MINUTES = 1440
|
14
|
+
REFRESH_TOKEN_VALID_MINUTES = 10080
|
15
|
+
|
16
|
+
# absolute path (mandatory only for http)
|
17
|
+
SSL_CRT_FILE_PATH = ssl.crt
|
18
|
+
SSL_KEY_FILE_PATH = ssl.key
|
19
|
+
|
20
|
+
DB_IP = raspi.thepmsquare.com
|
21
|
+
DB_PORT = 15432
|
22
|
+
DB_USERNAME = postgres
|
23
|
+
DB_PASSWORD = testing_password
|
24
|
+
|
25
|
+
[SQUARE_LOGGER]
|
26
|
+
|
27
|
+
# | Log Level | Value |
|
28
|
+
# | --------- | ----- |
|
29
|
+
# | CRITICAL | 50 |
|
30
|
+
# | ERROR | 40 |
|
31
|
+
# | WARNING | 30 |
|
32
|
+
# | INFO | 20 |
|
33
|
+
# | DEBUG | 10 |
|
34
|
+
# | NOTSET | 0 |
|
35
|
+
|
36
|
+
LOG_LEVEL = 20
|
37
|
+
# absolute or relative path
|
38
|
+
LOG_PATH = logs
|
39
|
+
# number of backup log files to keep during rotation
|
40
|
+
# if backupCount is zero, rollover never occurs.
|
41
|
+
LOG_BACKUP_COUNT = 3
|
42
|
+
|
43
|
+
[SQUARE_DATABASE_HELPER]
|
44
|
+
|
45
|
+
SQUARE_DATABASE_PROTOCOL = http
|
46
|
+
SQUARE_DATABASE_IP = raspi.thepmsquare.com
|
47
|
+
SQUARE_DATABASE_PORT = 20010
|
48
|
+
|
49
|
+
[SQUARE_FILE_STORE_HELPER]
|
50
|
+
|
51
|
+
SQUARE_FILE_STORE_PROTOCOL = http
|
52
|
+
SQUARE_FILE_STORE_IP = raspi.thepmsquare.com
|
53
|
+
SQUARE_FILE_STORE_PORT = 20010
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Annotated
|
1
|
+
from typing import Annotated, Optional
|
2
2
|
|
3
3
|
from fastapi import APIRouter, HTTPException, status, Header, UploadFile
|
4
4
|
from fastapi.responses import JSONResponse
|
@@ -27,7 +27,7 @@ router = APIRouter(
|
|
27
27
|
@global_object_square_logger.auto_logger()
|
28
28
|
async def update_profile_photo_v0(
|
29
29
|
access_token: Annotated[str, Header()],
|
30
|
-
profile_photo: UploadFile,
|
30
|
+
profile_photo: Optional[UploadFile] = None,
|
31
31
|
):
|
32
32
|
|
33
33
|
try:
|
@@ -50,7 +50,9 @@ async def update_profile_photo_v0(
|
|
50
50
|
user_id = local_dict_access_token_payload["user_id"]
|
51
51
|
|
52
52
|
# validate file format
|
53
|
-
if not profile_photo.filename.endswith(
|
53
|
+
if profile_photo and not profile_photo.filename.endswith(
|
54
|
+
(".jpg", ".jpeg", ".png")
|
55
|
+
):
|
54
56
|
output_content = get_api_output_in_standard_format(
|
55
57
|
message=messages["INVALID_FILE_FORMAT"]
|
56
58
|
)
|
@@ -61,7 +63,9 @@ async def update_profile_photo_v0(
|
|
61
63
|
|
62
64
|
# validate file size
|
63
65
|
file_size_limit_in_mib = 5
|
64
|
-
if profile_photo.size > (
|
66
|
+
if profile_photo and profile_photo.size > (
|
67
|
+
file_size_limit_in_mib * 1024 * 1024
|
68
|
+
):
|
65
69
|
output_content = get_api_output_in_standard_format(
|
66
70
|
message=messages["FILE_SIZE_EXCEEDS_LIMIT"]
|
67
71
|
)
|
@@ -72,20 +76,6 @@ async def update_profile_photo_v0(
|
|
72
76
|
"""
|
73
77
|
main process
|
74
78
|
"""
|
75
|
-
# uploading to square file store
|
76
|
-
|
77
|
-
file_upload_response = (
|
78
|
-
global_object_square_file_store_helper.upload_file_using_tuple_v0(
|
79
|
-
file=(
|
80
|
-
profile_photo.filename,
|
81
|
-
profile_photo.file,
|
82
|
-
profile_photo.content_type,
|
83
|
-
),
|
84
|
-
system_relative_path="global/users/profile_photos",
|
85
|
-
)
|
86
|
-
)
|
87
|
-
|
88
|
-
# adding file storage token to user profile
|
89
79
|
old_profile_photo_response = global_object_square_database_helper.get_rows_v0(
|
90
80
|
database_name=global_string_database_name,
|
91
81
|
schema_name=global_string_schema_name,
|
@@ -98,20 +88,49 @@ async def update_profile_photo_v0(
|
|
98
88
|
old_profile_photo_token = old_profile_photo_response["data"]["main"][0][
|
99
89
|
"user_profile_photo_storage_token"
|
100
90
|
]
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
91
|
+
|
92
|
+
if profile_photo:
|
93
|
+
# uploading to square file store
|
94
|
+
file_upload_response = (
|
95
|
+
global_object_square_file_store_helper.upload_file_using_tuple_v0(
|
96
|
+
file=(
|
97
|
+
profile_photo.filename,
|
98
|
+
profile_photo.file,
|
99
|
+
profile_photo.content_type,
|
100
|
+
),
|
101
|
+
system_relative_path="global/users/profile_photos",
|
102
|
+
)
|
103
|
+
)
|
104
|
+
# updating user profile
|
105
|
+
profile_update_response = global_object_square_database_helper.edit_rows_v0(
|
106
|
+
data={
|
107
|
+
UserProfile.user_profile_photo_storage_token.name: file_upload_response[
|
108
|
+
"data"
|
109
|
+
][
|
110
|
+
"main"
|
111
|
+
]
|
112
|
+
},
|
113
|
+
filters=FiltersV0(
|
114
|
+
root={UserProfile.user_id.name: FilterConditionsV0(eq=user_id)}
|
115
|
+
),
|
116
|
+
database_name=global_string_database_name,
|
117
|
+
schema_name=global_string_schema_name,
|
118
|
+
table_name=UserProfile.__tablename__,
|
119
|
+
apply_filters=True,
|
120
|
+
)
|
121
|
+
else:
|
122
|
+
# updating user profile
|
123
|
+
profile_update_response = global_object_square_database_helper.edit_rows_v0(
|
124
|
+
data={UserProfile.user_profile_photo_storage_token.name: None},
|
125
|
+
filters=FiltersV0(
|
126
|
+
root={UserProfile.user_id.name: FilterConditionsV0(eq=user_id)}
|
127
|
+
),
|
128
|
+
database_name=global_string_database_name,
|
129
|
+
schema_name=global_string_schema_name,
|
130
|
+
table_name=UserProfile.__tablename__,
|
131
|
+
apply_filters=True,
|
132
|
+
)
|
133
|
+
|
115
134
|
if old_profile_photo_token:
|
116
135
|
global_object_square_file_store_helper.delete_file_v0(
|
117
136
|
[old_profile_photo_token]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: square_authentication
|
3
|
-
Version: 6.0.
|
3
|
+
Version: 6.0.4
|
4
4
|
Summary: authentication layer for my personal server.
|
5
5
|
Home-page: https://github.com/thepmsquare/square_authentication
|
6
6
|
Author: thePmSquare
|
@@ -53,6 +53,14 @@ pip install square_authentication
|
|
53
53
|
|
54
54
|
## changelog
|
55
55
|
|
56
|
+
### v6.0.4
|
57
|
+
|
58
|
+
- mock ini file for pytest.
|
59
|
+
|
60
|
+
### v6.0.3
|
61
|
+
|
62
|
+
- make profile photo upload optional in update_profile_photo/v0, to enable users to remove their profile photo.
|
63
|
+
|
56
64
|
### v6.0.2
|
57
65
|
|
58
66
|
- bump square_file_store_helper to >=3.0.0.
|
@@ -1,18 +1,19 @@
|
|
1
1
|
square_authentication/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
square_authentication/configuration.py,sha256=
|
2
|
+
square_authentication/configuration.py,sha256=o-fx1zLipECyEQQm7jtMR2hYBW3gZ6uyFojSzuJ7Pqs,4475
|
3
3
|
square_authentication/main.py,sha256=zADc2vmV8yDylmbihj4FzLDEs5b-9nItFoB5c4AoKGk,1704
|
4
4
|
square_authentication/messages.py,sha256=vhcl4bw8Ar1npiErjGh3kkNPmW1rmDRtf6rKn5JF8W8,1364
|
5
|
-
square_authentication/data/config.ini,sha256=
|
5
|
+
square_authentication/data/config.ini,sha256=mJUGsEMqpAOVrHW3KmiZzH92340DkX69wDG4jBv1YWw,1111
|
6
|
+
square_authentication/data/config.testing.ini,sha256=wW727RRUgQl4euKJ17uLqlVJTrQ6ISER_9GA5GgW83o,1158
|
6
7
|
square_authentication/pydantic_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
8
|
square_authentication/pydantic_models/core.py,sha256=qeNETcJv7mnRKGhATOW2bg0NlHuyzvot1dZ1b1qqhwU,610
|
8
9
|
square_authentication/routes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
10
|
square_authentication/routes/core.py,sha256=Ui2kJI3DHK1tsb4_cCle8iurZlU__O_nptk2-YLZ2vg,56778
|
10
|
-
square_authentication/routes/profile.py,sha256=
|
11
|
+
square_authentication/routes/profile.py,sha256=3b-PtMaD9cxvf112MOn9rPu5F2KG4sRxAbuPvll8dUU,6216
|
11
12
|
square_authentication/routes/utility.py,sha256=KDr8KdkT0jAGPjfP-b5XXYG7p49WU7J1FiK6oSIckQI,1779
|
12
13
|
square_authentication/utils/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
13
14
|
square_authentication/utils/encryption.py,sha256=WakaiEAgWpTJltxBzqOtv81_DCDKfzJqt60fWSPoNvo,2027
|
14
15
|
square_authentication/utils/token.py,sha256=t-RPBY4cYyT1ro3lkLBTOy2BeRGBfluBVBivL5DLmDg,680
|
15
|
-
square_authentication-6.0.
|
16
|
-
square_authentication-6.0.
|
17
|
-
square_authentication-6.0.
|
18
|
-
square_authentication-6.0.
|
16
|
+
square_authentication-6.0.4.dist-info/METADATA,sha256=xvcPTkLQ-Z-DREOI_0tmIlwsu-vXuT8skKTfQ8vJKBA,5158
|
17
|
+
square_authentication-6.0.4.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
18
|
+
square_authentication-6.0.4.dist-info/top_level.txt,sha256=wDssVJIl9KIEJPj5rR3rv4uRI7yCndMBrvHd_6BGXQA,22
|
19
|
+
square_authentication-6.0.4.dist-info/RECORD,,
|
{square_authentication-6.0.2.dist-info → square_authentication-6.0.4.dist-info}/top_level.txt
RENAMED
File without changes
|