square-authentication 10.0.1__tar.gz → 10.0.3__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-10.0.1 → square_authentication-10.0.3}/PKG-INFO +8 -3
- {square_authentication-10.0.1 → square_authentication-10.0.3}/README.md +6 -1
- {square_authentication-10.0.1 → square_authentication-10.0.3}/setup.py +2 -2
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/configuration.py +12 -4
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/data/config.sample.ini +3 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/data/config.testing.sample.ini +3 -0
- square_authentication-10.0.3/square_authentication/routes/core.py +494 -0
- square_authentication-10.0.3/square_authentication/routes/profile.py +126 -0
- square_authentication-10.0.3/square_authentication/routes/utility.py +31 -0
- square_authentication-10.0.3/square_authentication/utils/routes/__init__.py +0 -0
- {square_authentication-10.0.1/square_authentication → square_authentication-10.0.3/square_authentication/utils}/routes/core.py +33 -123
- {square_authentication-10.0.1/square_authentication → square_authentication-10.0.3/square_authentication/utils}/routes/profile.py +15 -35
- {square_authentication-10.0.1/square_authentication → square_authentication-10.0.3/square_authentication/utils}/routes/utility.py +2 -8
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication.egg-info/PKG-INFO +8 -3
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication.egg-info/SOURCES.txt +4 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication.egg-info/requires.txt +1 -1
- {square_authentication-10.0.1 → square_authentication-10.0.3}/LICENSE +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/pyproject.toml +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/setup.cfg +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/__init__.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/main.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/messages.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/pydantic_models/__init__.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/pydantic_models/core.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/pydantic_models/profile.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/routes/__init__.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/utils/__init__.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/utils/core.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/utils/encryption.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/utils/token.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication.egg-info/dependency_links.txt +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication.egg-info/top_level.txt +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/tests/test_1.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/tests/test_authentication.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/tests/test_delete_user.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/tests/test_email_verification.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/tests/test_login.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/tests/test_profile_management.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/tests/test_token_management.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/tests/test_update_profile.py +0 -0
- {square_authentication-10.0.1 → square_authentication-10.0.3}/tests/test_username.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: square_authentication
|
3
|
-
Version: 10.0.
|
3
|
+
Version: 10.0.3
|
4
4
|
Summary: authentication layer for my personal server.
|
5
5
|
Home-page: https://github.com/thepmsquare/square_authentication
|
6
6
|
Author: Parth Mukesh Mangtani
|
@@ -27,7 +27,7 @@ Requires-Dist: pyjwt>=2.8.0
|
|
27
27
|
Requires-Dist: requests>=2.32.3
|
28
28
|
Requires-Dist: cryptography>=42.0.7
|
29
29
|
Requires-Dist: square_commons>=3.0.0
|
30
|
-
Requires-Dist: square_logger>=
|
30
|
+
Requires-Dist: square_logger>=3.0.0
|
31
31
|
Requires-Dist: square_database_helper>=2.6.1
|
32
32
|
Requires-Dist: square_database_structure>=2.6.0
|
33
33
|
Requires-Dist: square_file_store_helper>=3.0.0
|
@@ -54,7 +54,12 @@ authentication layer for my personal server.
|
|
54
54
|
|
55
55
|
## goals
|
56
56
|
|
57
|
-
|
57
|
+
- integration with square_*
|
58
|
+
- unified authentication api across all projects
|
59
|
+
- jwt token support
|
60
|
+
- simple user and user profile management
|
61
|
+
- oauth support
|
62
|
+
- future extensibility
|
58
63
|
|
59
64
|
## Installation
|
60
65
|
|
@@ -8,7 +8,12 @@ authentication layer for my personal server.
|
|
8
8
|
|
9
9
|
## goals
|
10
10
|
|
11
|
-
|
11
|
+
- integration with square_*
|
12
|
+
- unified authentication api across all projects
|
13
|
+
- jwt token support
|
14
|
+
- simple user and user profile management
|
15
|
+
- oauth support
|
16
|
+
- future extensibility
|
12
17
|
|
13
18
|
## Installation
|
14
19
|
|
@@ -4,7 +4,7 @@ package_name = "square_authentication"
|
|
4
4
|
|
5
5
|
setup(
|
6
6
|
name=package_name,
|
7
|
-
version="10.0.
|
7
|
+
version="10.0.3",
|
8
8
|
packages=find_packages(),
|
9
9
|
package_data={
|
10
10
|
package_name: ["data/*"],
|
@@ -19,7 +19,7 @@ setup(
|
|
19
19
|
"requests>=2.32.3",
|
20
20
|
"cryptography>=42.0.7",
|
21
21
|
"square_commons>=3.0.0",
|
22
|
-
"square_logger>=
|
22
|
+
"square_logger>=3.0.0",
|
23
23
|
"square_database_helper>=2.6.1",
|
24
24
|
"square_database_structure>=2.6.0",
|
25
25
|
"square_file_store_helper>=3.0.0",
|
{square_authentication-10.0.1 → square_authentication-10.0.3}/square_authentication/configuration.py
RENAMED
@@ -93,6 +93,12 @@ try:
|
|
93
93
|
config_int_square_file_store_port = int(
|
94
94
|
ldict_configuration["SQUARE_FILE_STORE_HELPER"]["SQUARE_FILE_STORE_PORT"]
|
95
95
|
)
|
96
|
+
config_formatter_choice = ldict_configuration["SQUARE_LOGGER"]["FORMATTER_CHOICE"]
|
97
|
+
if config_formatter_choice not in ("human_readable", "json"):
|
98
|
+
raise ValueError(f"Invalid formatter choice: {config_formatter_choice}")
|
99
|
+
config_bool_enable_redaction = eval(
|
100
|
+
ldict_configuration["SQUARE_LOGGER"]["ENABLE_REDACTION"]
|
101
|
+
)
|
96
102
|
# ===========================================
|
97
103
|
|
98
104
|
# ===========================================
|
@@ -143,10 +149,12 @@ try:
|
|
143
149
|
|
144
150
|
# Initialize logger
|
145
151
|
global_object_square_logger = SquareLogger(
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
152
|
+
log_file_name=config_str_log_file_name,
|
153
|
+
log_level=config_int_log_level,
|
154
|
+
log_path=config_str_log_path,
|
155
|
+
log_backup_count=config_int_log_backup_count,
|
156
|
+
formatter_choice=config_formatter_choice,
|
157
|
+
enable_redaction=config_bool_enable_redaction,
|
150
158
|
)
|
151
159
|
global_object_square_database_helper = SquareDatabaseHelper(
|
152
160
|
param_str_square_database_ip=config_str_square_database_ip,
|
@@ -40,6 +40,9 @@ LOG_PATH = logs
|
|
40
40
|
# number of backup log files to keep during rotation
|
41
41
|
# if backupCount is zero, rollover never occurs.
|
42
42
|
LOG_BACKUP_COUNT = 3
|
43
|
+
# json or human_readable
|
44
|
+
FORMATTER_CHOICE = json
|
45
|
+
ENABLE_REDACTION = True
|
43
46
|
|
44
47
|
[SQUARE_DATABASE_HELPER]
|
45
48
|
|
@@ -40,6 +40,9 @@ LOG_PATH = logs
|
|
40
40
|
# number of backup log files to keep during rotation
|
41
41
|
# if backupCount is zero, rollover never occurs.
|
42
42
|
LOG_BACKUP_COUNT = 3
|
43
|
+
# json or human_readable
|
44
|
+
FORMATTER_CHOICE = json
|
45
|
+
ENABLE_REDACTION = True
|
43
46
|
|
44
47
|
[SQUARE_DATABASE_HELPER]
|
45
48
|
|
@@ -0,0 +1,494 @@
|
|
1
|
+
from typing import Annotated, List
|
2
|
+
|
3
|
+
from fastapi import APIRouter, Header, HTTPException, status
|
4
|
+
from fastapi.params import Query
|
5
|
+
from fastapi.responses import JSONResponse
|
6
|
+
from square_commons import get_api_output_in_standard_format
|
7
|
+
from square_database_structure.square.authentication.enums import (
|
8
|
+
RecoveryMethodEnum,
|
9
|
+
)
|
10
|
+
|
11
|
+
from square_authentication.configuration import (
|
12
|
+
global_object_square_logger,
|
13
|
+
)
|
14
|
+
from square_authentication.messages import messages
|
15
|
+
from square_authentication.pydantic_models.core import (
|
16
|
+
DeleteUserV0,
|
17
|
+
LoginUsernameV0,
|
18
|
+
LogoutAppsV0,
|
19
|
+
RegisterUsernameV0,
|
20
|
+
TokenType,
|
21
|
+
UpdatePasswordV0,
|
22
|
+
ResetPasswordAndLoginUsingBackupCodeV0,
|
23
|
+
SendResetPasswordEmailV0,
|
24
|
+
ResetPasswordAndLoginUsingResetEmailCodeV0,
|
25
|
+
RegisterLoginGoogleV0,
|
26
|
+
)
|
27
|
+
from square_authentication.utils.routes.core import (
|
28
|
+
util_register_username_v0,
|
29
|
+
util_register_login_google_v0,
|
30
|
+
util_get_user_details_v0,
|
31
|
+
util_update_user_app_ids_v0,
|
32
|
+
util_login_username_v0,
|
33
|
+
util_generate_access_token_v0,
|
34
|
+
util_logout_v0,
|
35
|
+
util_logout_apps_v0,
|
36
|
+
util_logout_all_v0,
|
37
|
+
util_update_username_v0,
|
38
|
+
util_delete_user_v0,
|
39
|
+
util_update_password_v0,
|
40
|
+
util_validate_and_get_payload_from_token_v0,
|
41
|
+
util_update_user_recovery_methods_v0,
|
42
|
+
util_generate_account_backup_codes_v0,
|
43
|
+
util_reset_password_and_login_using_backup_code_v0,
|
44
|
+
util_send_reset_password_email_v0,
|
45
|
+
util_reset_password_and_login_using_reset_email_code_v0,
|
46
|
+
)
|
47
|
+
|
48
|
+
router = APIRouter(
|
49
|
+
tags=["core"],
|
50
|
+
)
|
51
|
+
|
52
|
+
|
53
|
+
@router.post("/register_username/v0")
|
54
|
+
@global_object_square_logger.auto_logger()
|
55
|
+
async def register_username_v0(
|
56
|
+
body: RegisterUsernameV0,
|
57
|
+
):
|
58
|
+
try:
|
59
|
+
return util_register_username_v0(
|
60
|
+
username=body.username,
|
61
|
+
password=body.password,
|
62
|
+
app_id=body.app_id,
|
63
|
+
)
|
64
|
+
except HTTPException as he:
|
65
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
66
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
67
|
+
except Exception as e:
|
68
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
69
|
+
output_content = get_api_output_in_standard_format(
|
70
|
+
message=messages["GENERIC_500"], log=str(e)
|
71
|
+
)
|
72
|
+
return JSONResponse(
|
73
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
74
|
+
)
|
75
|
+
|
76
|
+
|
77
|
+
@router.post("/register_login_google/v0")
|
78
|
+
async def register_login_google_v0(body: RegisterLoginGoogleV0):
|
79
|
+
try:
|
80
|
+
return util_register_login_google_v0(
|
81
|
+
app_id=body.app_id,
|
82
|
+
google_id=body.google_id,
|
83
|
+
assign_app_id_if_missing=body.assign_app_id_if_missing,
|
84
|
+
)
|
85
|
+
except HTTPException as he:
|
86
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
87
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
88
|
+
except Exception as e:
|
89
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
90
|
+
output_content = get_api_output_in_standard_format(
|
91
|
+
message=messages["GENERIC_500"], log=str(e)
|
92
|
+
)
|
93
|
+
return JSONResponse(
|
94
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
95
|
+
)
|
96
|
+
|
97
|
+
|
98
|
+
@router.get("/get_user_details/v0")
|
99
|
+
@global_object_square_logger.auto_logger()
|
100
|
+
async def get_user_details_v0(
|
101
|
+
access_token: Annotated[str, Header()],
|
102
|
+
):
|
103
|
+
try:
|
104
|
+
return util_get_user_details_v0(access_token=access_token)
|
105
|
+
except HTTPException as he:
|
106
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
107
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
108
|
+
except Exception as e:
|
109
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
110
|
+
output_content = get_api_output_in_standard_format(
|
111
|
+
message=messages["GENERIC_500"], log=str(e)
|
112
|
+
)
|
113
|
+
return JSONResponse(
|
114
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
115
|
+
)
|
116
|
+
|
117
|
+
|
118
|
+
@router.patch("/update_user_app_ids/v0")
|
119
|
+
@global_object_square_logger.auto_logger()
|
120
|
+
async def update_user_app_ids_v0(
|
121
|
+
access_token: Annotated[str, Header()],
|
122
|
+
app_ids_to_add: List[int],
|
123
|
+
app_ids_to_remove: List[int],
|
124
|
+
):
|
125
|
+
try:
|
126
|
+
return util_update_user_app_ids_v0(
|
127
|
+
access_token=access_token,
|
128
|
+
app_ids_to_add=app_ids_to_add,
|
129
|
+
app_ids_to_remove=app_ids_to_remove,
|
130
|
+
)
|
131
|
+
except HTTPException as he:
|
132
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
133
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
134
|
+
except Exception as e:
|
135
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
136
|
+
output_content = get_api_output_in_standard_format(
|
137
|
+
message=messages["GENERIC_500"], log=str(e)
|
138
|
+
)
|
139
|
+
return JSONResponse(
|
140
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
141
|
+
)
|
142
|
+
|
143
|
+
|
144
|
+
@router.post("/login_username/v0")
|
145
|
+
@global_object_square_logger.auto_logger()
|
146
|
+
async def login_username_v0(body: LoginUsernameV0):
|
147
|
+
username = body.username
|
148
|
+
password = body.password
|
149
|
+
app_id = body.app_id
|
150
|
+
assign_app_id_if_missing = body.assign_app_id_if_missing
|
151
|
+
username = username.lower()
|
152
|
+
try:
|
153
|
+
return util_login_username_v0(
|
154
|
+
username=username,
|
155
|
+
password=password,
|
156
|
+
app_id=app_id,
|
157
|
+
assign_app_id_if_missing=assign_app_id_if_missing,
|
158
|
+
)
|
159
|
+
except HTTPException as he:
|
160
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
161
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
162
|
+
except Exception as e:
|
163
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
164
|
+
output_content = get_api_output_in_standard_format(
|
165
|
+
message=messages["GENERIC_500"], log=str(e)
|
166
|
+
)
|
167
|
+
return JSONResponse(
|
168
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
169
|
+
)
|
170
|
+
|
171
|
+
|
172
|
+
@router.get("/generate_access_token/v0")
|
173
|
+
@global_object_square_logger.auto_logger()
|
174
|
+
async def generate_access_token_v0(
|
175
|
+
refresh_token: Annotated[str, Header()],
|
176
|
+
):
|
177
|
+
try:
|
178
|
+
return util_generate_access_token_v0(
|
179
|
+
refresh_token=refresh_token,
|
180
|
+
)
|
181
|
+
except HTTPException as he:
|
182
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
183
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
184
|
+
except Exception as e:
|
185
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
186
|
+
output_content = get_api_output_in_standard_format(
|
187
|
+
message=messages["GENERIC_500"], log=str(e)
|
188
|
+
)
|
189
|
+
return JSONResponse(
|
190
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
191
|
+
)
|
192
|
+
|
193
|
+
|
194
|
+
@router.delete("/logout/v0")
|
195
|
+
@global_object_square_logger.auto_logger()
|
196
|
+
async def logout_v0(
|
197
|
+
refresh_token: Annotated[str, Header()],
|
198
|
+
):
|
199
|
+
try:
|
200
|
+
return util_logout_v0(
|
201
|
+
refresh_token=refresh_token,
|
202
|
+
)
|
203
|
+
except HTTPException as he:
|
204
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
205
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
206
|
+
except Exception as e:
|
207
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
208
|
+
output_content = get_api_output_in_standard_format(
|
209
|
+
message=messages["GENERIC_500"], log=str(e)
|
210
|
+
)
|
211
|
+
return JSONResponse(
|
212
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
213
|
+
)
|
214
|
+
|
215
|
+
|
216
|
+
@router.post("/logout/apps/v0")
|
217
|
+
@global_object_square_logger.auto_logger()
|
218
|
+
async def logout_apps_v0(
|
219
|
+
access_token: Annotated[str, Header()],
|
220
|
+
body: LogoutAppsV0,
|
221
|
+
):
|
222
|
+
app_ids = body.app_ids
|
223
|
+
try:
|
224
|
+
return util_logout_apps_v0(access_token=access_token, app_ids=app_ids)
|
225
|
+
except HTTPException as he:
|
226
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
227
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
228
|
+
except Exception as e:
|
229
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
230
|
+
output_content = get_api_output_in_standard_format(
|
231
|
+
message=messages["GENERIC_500"], log=str(e)
|
232
|
+
)
|
233
|
+
return JSONResponse(
|
234
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
235
|
+
)
|
236
|
+
|
237
|
+
|
238
|
+
@router.delete("/logout/all/v0")
|
239
|
+
@global_object_square_logger.auto_logger()
|
240
|
+
async def logout_all_v0(
|
241
|
+
access_token: Annotated[str, Header()],
|
242
|
+
):
|
243
|
+
try:
|
244
|
+
return util_logout_all_v0(access_token=access_token)
|
245
|
+
except HTTPException as he:
|
246
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
247
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
248
|
+
except Exception as e:
|
249
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
250
|
+
output_content = get_api_output_in_standard_format(
|
251
|
+
message=messages["GENERIC_500"], log=str(e)
|
252
|
+
)
|
253
|
+
return JSONResponse(
|
254
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
255
|
+
)
|
256
|
+
|
257
|
+
|
258
|
+
@router.patch("/update_username/v0")
|
259
|
+
@global_object_square_logger.auto_logger()
|
260
|
+
async def update_username_v0(
|
261
|
+
new_username: str,
|
262
|
+
access_token: Annotated[str, Header()],
|
263
|
+
):
|
264
|
+
try:
|
265
|
+
return util_update_username_v0(
|
266
|
+
new_username=new_username, access_token=access_token
|
267
|
+
)
|
268
|
+
|
269
|
+
except HTTPException as he:
|
270
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
271
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
272
|
+
except Exception as e:
|
273
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
274
|
+
output_content = get_api_output_in_standard_format(
|
275
|
+
message=messages["GENERIC_500"], log=str(e)
|
276
|
+
)
|
277
|
+
return JSONResponse(
|
278
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
279
|
+
)
|
280
|
+
|
281
|
+
|
282
|
+
@router.post("/delete_user/v0")
|
283
|
+
@global_object_square_logger.auto_logger()
|
284
|
+
async def delete_user_v0(
|
285
|
+
body: DeleteUserV0,
|
286
|
+
access_token: Annotated[str, Header()],
|
287
|
+
):
|
288
|
+
password = body.password
|
289
|
+
try:
|
290
|
+
return util_delete_user_v0(
|
291
|
+
password=password,
|
292
|
+
access_token=access_token,
|
293
|
+
)
|
294
|
+
except HTTPException as he:
|
295
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
296
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
297
|
+
except Exception as e:
|
298
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
299
|
+
output_content = get_api_output_in_standard_format(
|
300
|
+
message=messages["GENERIC_500"], log=str(e)
|
301
|
+
)
|
302
|
+
return JSONResponse(
|
303
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
304
|
+
)
|
305
|
+
|
306
|
+
|
307
|
+
@router.patch("/update_password/v0")
|
308
|
+
@global_object_square_logger.auto_logger()
|
309
|
+
async def update_password_v0(
|
310
|
+
body: UpdatePasswordV0,
|
311
|
+
access_token: Annotated[str, Header()],
|
312
|
+
):
|
313
|
+
old_password = body.old_password
|
314
|
+
new_password = body.new_password
|
315
|
+
logout_other_sessions = body.logout_other_sessions
|
316
|
+
preserve_session_refresh_token = body.preserve_session_refresh_token
|
317
|
+
try:
|
318
|
+
return util_update_password_v0(
|
319
|
+
old_password=old_password,
|
320
|
+
new_password=new_password,
|
321
|
+
logout_other_sessions=logout_other_sessions,
|
322
|
+
preserve_session_refresh_token=preserve_session_refresh_token,
|
323
|
+
access_token=access_token,
|
324
|
+
)
|
325
|
+
except HTTPException as he:
|
326
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
327
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
328
|
+
except Exception as e:
|
329
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
330
|
+
output_content = get_api_output_in_standard_format(
|
331
|
+
message=messages["GENERIC_500"], log=str(e)
|
332
|
+
)
|
333
|
+
return JSONResponse(
|
334
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
335
|
+
)
|
336
|
+
|
337
|
+
|
338
|
+
@router.get("/validate_and_get_payload_from_token/v0")
|
339
|
+
@global_object_square_logger.auto_logger()
|
340
|
+
async def validate_and_get_payload_from_token_v0(
|
341
|
+
app_id: int,
|
342
|
+
token: Annotated[str, Header()],
|
343
|
+
token_type: TokenType = Query(...),
|
344
|
+
):
|
345
|
+
try:
|
346
|
+
return util_validate_and_get_payload_from_token_v0(
|
347
|
+
app_id=app_id,
|
348
|
+
token=token,
|
349
|
+
token_type=token_type,
|
350
|
+
)
|
351
|
+
except HTTPException as he:
|
352
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
353
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
354
|
+
except Exception as e:
|
355
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
356
|
+
output_content = get_api_output_in_standard_format(
|
357
|
+
message=messages["GENERIC_500"], log=str(e)
|
358
|
+
)
|
359
|
+
return JSONResponse(
|
360
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
361
|
+
)
|
362
|
+
|
363
|
+
|
364
|
+
@router.patch("/update_user_recovery_methods/v0")
|
365
|
+
@global_object_square_logger.auto_logger()
|
366
|
+
async def update_user_recovery_methods_v0(
|
367
|
+
access_token: Annotated[str, Header()],
|
368
|
+
recovery_methods_to_add: List[RecoveryMethodEnum] = None,
|
369
|
+
recovery_methods_to_remove: List[RecoveryMethodEnum] = None,
|
370
|
+
):
|
371
|
+
try:
|
372
|
+
return util_update_user_recovery_methods_v0(
|
373
|
+
access_token=access_token,
|
374
|
+
recovery_methods_to_add=recovery_methods_to_add,
|
375
|
+
recovery_methods_to_remove=recovery_methods_to_remove,
|
376
|
+
)
|
377
|
+
except HTTPException as he:
|
378
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
379
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
380
|
+
except Exception as e:
|
381
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
382
|
+
output_content = get_api_output_in_standard_format(
|
383
|
+
message=messages["GENERIC_500"], log=str(e)
|
384
|
+
)
|
385
|
+
return JSONResponse(
|
386
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
387
|
+
)
|
388
|
+
|
389
|
+
|
390
|
+
@router.post("/generate_account_backup_codes/v0")
|
391
|
+
@global_object_square_logger.auto_logger()
|
392
|
+
async def generate_account_backup_codes_v0(
|
393
|
+
access_token: Annotated[str, Header()],
|
394
|
+
):
|
395
|
+
try:
|
396
|
+
return util_generate_account_backup_codes_v0(
|
397
|
+
access_token=access_token,
|
398
|
+
)
|
399
|
+
except HTTPException as he:
|
400
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
401
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
402
|
+
except Exception as e:
|
403
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
404
|
+
output_content = get_api_output_in_standard_format(
|
405
|
+
message=messages["GENERIC_500"], log=str(e)
|
406
|
+
)
|
407
|
+
return JSONResponse(
|
408
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
409
|
+
)
|
410
|
+
|
411
|
+
|
412
|
+
@router.post("/reset_password_and_login_using_backup_code/v0")
|
413
|
+
@global_object_square_logger.auto_logger()
|
414
|
+
async def reset_password_and_login_using_backup_code_v0(
|
415
|
+
body: ResetPasswordAndLoginUsingBackupCodeV0,
|
416
|
+
):
|
417
|
+
backup_code = body.backup_code
|
418
|
+
username = body.username
|
419
|
+
new_password = body.new_password
|
420
|
+
app_id = body.app_id
|
421
|
+
logout_other_sessions = body.logout_other_sessions
|
422
|
+
try:
|
423
|
+
return util_reset_password_and_login_using_backup_code_v0(
|
424
|
+
backup_code=backup_code,
|
425
|
+
username=username,
|
426
|
+
new_password=new_password,
|
427
|
+
app_id=app_id,
|
428
|
+
logout_other_sessions=logout_other_sessions,
|
429
|
+
)
|
430
|
+
except HTTPException as he:
|
431
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
432
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
433
|
+
except Exception as e:
|
434
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
435
|
+
output_content = get_api_output_in_standard_format(
|
436
|
+
message=messages["GENERIC_500"], log=str(e)
|
437
|
+
)
|
438
|
+
return JSONResponse(
|
439
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
440
|
+
)
|
441
|
+
|
442
|
+
|
443
|
+
@router.post("/send_reset_password_email/v0")
|
444
|
+
@global_object_square_logger.auto_logger()
|
445
|
+
async def send_reset_password_email_v0(
|
446
|
+
body: SendResetPasswordEmailV0,
|
447
|
+
):
|
448
|
+
username = body.username
|
449
|
+
try:
|
450
|
+
return util_send_reset_password_email_v0(
|
451
|
+
username=username,
|
452
|
+
)
|
453
|
+
except HTTPException as he:
|
454
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
455
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
456
|
+
except Exception as e:
|
457
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
458
|
+
output_content = get_api_output_in_standard_format(
|
459
|
+
message=messages["GENERIC_500"], log=str(e)
|
460
|
+
)
|
461
|
+
return JSONResponse(
|
462
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
463
|
+
)
|
464
|
+
|
465
|
+
|
466
|
+
@router.post("/reset_password_and_login_using_reset_email_code/v0")
|
467
|
+
@global_object_square_logger.auto_logger()
|
468
|
+
async def reset_password_and_login_using_reset_email_code_v0(
|
469
|
+
body: ResetPasswordAndLoginUsingResetEmailCodeV0,
|
470
|
+
):
|
471
|
+
reset_email_code = body.reset_email_code
|
472
|
+
username = body.username
|
473
|
+
new_password = body.new_password
|
474
|
+
app_id = body.app_id
|
475
|
+
logout_other_sessions = body.logout_other_sessions
|
476
|
+
try:
|
477
|
+
return util_reset_password_and_login_using_reset_email_code_v0(
|
478
|
+
reset_email_code=reset_email_code,
|
479
|
+
username=username,
|
480
|
+
new_password=new_password,
|
481
|
+
app_id=app_id,
|
482
|
+
logout_other_sessions=logout_other_sessions,
|
483
|
+
)
|
484
|
+
except HTTPException as he:
|
485
|
+
global_object_square_logger.logger.error(he, exc_info=True)
|
486
|
+
return JSONResponse(status_code=he.status_code, content=he.detail)
|
487
|
+
except Exception as e:
|
488
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
489
|
+
output_content = get_api_output_in_standard_format(
|
490
|
+
message=messages["GENERIC_500"], log=str(e)
|
491
|
+
)
|
492
|
+
return JSONResponse(
|
493
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
494
|
+
)
|