square-authentication 10.0.0__tar.gz → 10.0.2__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.
Files changed (41) hide show
  1. {square_authentication-10.0.0 → square_authentication-10.0.2}/PKG-INFO +7 -2
  2. {square_authentication-10.0.0 → square_authentication-10.0.2}/README.md +6 -1
  3. {square_authentication-10.0.0 → square_authentication-10.0.2}/setup.py +1 -1
  4. square_authentication-10.0.2/square_authentication/routes/core.py +494 -0
  5. square_authentication-10.0.2/square_authentication/routes/profile.py +126 -0
  6. square_authentication-10.0.2/square_authentication/routes/utility.py +31 -0
  7. square_authentication-10.0.2/square_authentication/utils/routes/__init__.py +0 -0
  8. {square_authentication-10.0.0/square_authentication → square_authentication-10.0.2/square_authentication/utils}/routes/core.py +44 -123
  9. {square_authentication-10.0.0/square_authentication → square_authentication-10.0.2/square_authentication/utils}/routes/profile.py +15 -35
  10. {square_authentication-10.0.0/square_authentication → square_authentication-10.0.2/square_authentication/utils}/routes/utility.py +2 -8
  11. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication.egg-info/PKG-INFO +7 -2
  12. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication.egg-info/SOURCES.txt +4 -0
  13. {square_authentication-10.0.0 → square_authentication-10.0.2}/LICENSE +0 -0
  14. {square_authentication-10.0.0 → square_authentication-10.0.2}/pyproject.toml +0 -0
  15. {square_authentication-10.0.0 → square_authentication-10.0.2}/setup.cfg +0 -0
  16. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/__init__.py +0 -0
  17. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/configuration.py +0 -0
  18. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/data/config.sample.ini +0 -0
  19. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/data/config.testing.sample.ini +0 -0
  20. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/main.py +0 -0
  21. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/messages.py +0 -0
  22. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/pydantic_models/__init__.py +0 -0
  23. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/pydantic_models/core.py +0 -0
  24. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/pydantic_models/profile.py +0 -0
  25. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/routes/__init__.py +0 -0
  26. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/utils/__init__.py +0 -0
  27. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/utils/core.py +0 -0
  28. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/utils/encryption.py +0 -0
  29. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication/utils/token.py +0 -0
  30. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication.egg-info/dependency_links.txt +0 -0
  31. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication.egg-info/requires.txt +0 -0
  32. {square_authentication-10.0.0 → square_authentication-10.0.2}/square_authentication.egg-info/top_level.txt +0 -0
  33. {square_authentication-10.0.0 → square_authentication-10.0.2}/tests/test_1.py +0 -0
  34. {square_authentication-10.0.0 → square_authentication-10.0.2}/tests/test_authentication.py +0 -0
  35. {square_authentication-10.0.0 → square_authentication-10.0.2}/tests/test_delete_user.py +0 -0
  36. {square_authentication-10.0.0 → square_authentication-10.0.2}/tests/test_email_verification.py +0 -0
  37. {square_authentication-10.0.0 → square_authentication-10.0.2}/tests/test_login.py +0 -0
  38. {square_authentication-10.0.0 → square_authentication-10.0.2}/tests/test_profile_management.py +0 -0
  39. {square_authentication-10.0.0 → square_authentication-10.0.2}/tests/test_token_management.py +0 -0
  40. {square_authentication-10.0.0 → square_authentication-10.0.2}/tests/test_update_profile.py +0 -0
  41. {square_authentication-10.0.0 → square_authentication-10.0.2}/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.0
3
+ Version: 10.0.2
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
@@ -54,7 +54,12 @@ authentication layer for my personal server.
54
54
 
55
55
  ## goals
56
56
 
57
- (wip)
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
- (wip)
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.0",
7
+ version="10.0.2",
8
8
  packages=find_packages(),
9
9
  package_data={
10
10
  package_name: ["data/*"],
@@ -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
+ )
@@ -0,0 +1,126 @@
1
+ from typing import Annotated, Optional
2
+
3
+ from fastapi import APIRouter, Header, HTTPException, UploadFile, status
4
+ from fastapi.responses import JSONResponse
5
+ from square_commons import get_api_output_in_standard_format
6
+
7
+ from square_authentication.configuration import (
8
+ global_object_square_logger,
9
+ )
10
+ from square_authentication.messages import messages
11
+ from square_authentication.pydantic_models.profile import (
12
+ ValidateEmailVerificationCodeV0,
13
+ )
14
+ from square_authentication.utils.routes.profile import (
15
+ util_update_profile_photo_v0,
16
+ util_update_profile_details_v0,
17
+ util_send_verification_email_v0,
18
+ util_validate_email_verification_code_v0,
19
+ )
20
+
21
+ router = APIRouter(
22
+ tags=["profile"],
23
+ )
24
+
25
+
26
+ @router.patch("/update_profile_photo/v0")
27
+ @global_object_square_logger.auto_logger()
28
+ async def update_profile_photo_v0(
29
+ access_token: Annotated[str, Header()],
30
+ profile_photo: Optional[UploadFile] = None,
31
+ ):
32
+ try:
33
+ return util_update_profile_photo_v0(
34
+ access_token=access_token,
35
+ profile_photo=profile_photo,
36
+ )
37
+ except HTTPException as he:
38
+ global_object_square_logger.logger.error(he, exc_info=True)
39
+ return JSONResponse(status_code=he.status_code, content=he.detail)
40
+ except Exception as e:
41
+ global_object_square_logger.logger.error(e, exc_info=True)
42
+ output_content = get_api_output_in_standard_format(
43
+ message=messages["GENERIC_500"], log=str(e)
44
+ )
45
+ return JSONResponse(
46
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
47
+ )
48
+
49
+
50
+ @router.patch("/update_profile_details/v0")
51
+ @global_object_square_logger.auto_logger()
52
+ async def update_profile_details_v0(
53
+ access_token: Annotated[str, Header()],
54
+ first_name: Optional[str] = None,
55
+ last_name: Optional[str] = None,
56
+ email: Optional[str] = None,
57
+ phone_number_country_code: Optional[str] = None,
58
+ phone_number: Optional[str] = None,
59
+ ):
60
+ try:
61
+ return util_update_profile_details_v0(
62
+ access_token=access_token,
63
+ first_name=first_name,
64
+ last_name=last_name,
65
+ email=email,
66
+ phone_number_country_code=phone_number_country_code,
67
+ phone_number=phone_number,
68
+ )
69
+ except HTTPException as he:
70
+ global_object_square_logger.logger.error(he, exc_info=True)
71
+ return JSONResponse(status_code=he.status_code, content=he.detail)
72
+ except Exception as e:
73
+ global_object_square_logger.logger.error(e, exc_info=True)
74
+ output_content = get_api_output_in_standard_format(
75
+ message=messages["GENERIC_500"], log=str(e)
76
+ )
77
+ return JSONResponse(
78
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
79
+ )
80
+
81
+
82
+ @router.post("/send_verification_email/v0")
83
+ @global_object_square_logger.auto_logger()
84
+ async def send_verification_email_v0(
85
+ access_token: Annotated[str, Header()],
86
+ ):
87
+ try:
88
+ return util_send_verification_email_v0(
89
+ access_token=access_token,
90
+ )
91
+ except HTTPException as he:
92
+ global_object_square_logger.logger.error(he, exc_info=True)
93
+ return JSONResponse(status_code=he.status_code, content=he.detail)
94
+ except Exception as e:
95
+ global_object_square_logger.logger.error(e, exc_info=True)
96
+ output_content = get_api_output_in_standard_format(
97
+ message=messages["GENERIC_500"], log=str(e)
98
+ )
99
+ return JSONResponse(
100
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
101
+ )
102
+
103
+
104
+ @router.post("/validate_email_verification_code/v0")
105
+ @global_object_square_logger.auto_logger()
106
+ async def validate_email_verification_code_v0(
107
+ access_token: Annotated[str, Header()],
108
+ body: ValidateEmailVerificationCodeV0,
109
+ ):
110
+ verification_code = body.verification_code
111
+ try:
112
+ return util_validate_email_verification_code_v0(
113
+ access_token=access_token,
114
+ verification_code=verification_code,
115
+ )
116
+ except HTTPException as he:
117
+ global_object_square_logger.logger.error(he, exc_info=True)
118
+ return JSONResponse(status_code=he.status_code, content=he.detail)
119
+ except Exception as e:
120
+ global_object_square_logger.logger.error(e, exc_info=True)
121
+ output_content = get_api_output_in_standard_format(
122
+ message=messages["GENERIC_500"], log=str(e)
123
+ )
124
+ return JSONResponse(
125
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
126
+ )
@@ -0,0 +1,31 @@
1
+ from fastapi import APIRouter, status, HTTPException
2
+ from fastapi.responses import JSONResponse
3
+ from square_commons import get_api_output_in_standard_format
4
+
5
+ from square_authentication.configuration import global_object_square_logger
6
+ from square_authentication.messages import messages
7
+ from square_authentication.utils.routes.utility import util_get_text_hash_v0
8
+
9
+ router = APIRouter(
10
+ tags=["utility"],
11
+ )
12
+
13
+
14
+ @router.get("/get_text_hash/v0")
15
+ @global_object_square_logger.auto_logger()
16
+ async def get_text_hash_v0(plain_text: str):
17
+ try:
18
+ return util_get_text_hash_v0(
19
+ plain_text=plain_text,
20
+ )
21
+ except HTTPException as he:
22
+ global_object_square_logger.logger.error(he, exc_info=True)
23
+ return JSONResponse(status_code=he.status_code, content=he.detail)
24
+ except Exception as e:
25
+ global_object_square_logger.logger.error(e, exc_info=True)
26
+ output_content = get_api_output_in_standard_format(
27
+ message=messages["GENERIC_500"], log=str(e)
28
+ )
29
+ return JSONResponse(
30
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
31
+ )
@@ -5,12 +5,10 @@ import random
5
5
  import re
6
6
  import uuid
7
7
  from datetime import datetime, timedelta, timezone
8
- from typing import Annotated, List
9
8
 
10
9
  import bcrypt
11
10
  import jwt
12
- from fastapi import APIRouter, Header, HTTPException, status
13
- from fastapi.params import Query
11
+ from fastapi import HTTPException, status
14
12
  from fastapi.responses import JSONResponse
15
13
  from google.auth.transport import requests as google_requests
16
14
  from google.oauth2 import id_token
@@ -45,6 +43,9 @@ from square_database_structure.square.public import (
45
43
  )
46
44
  from square_database_structure.square.public.tables import App
47
45
 
46
+ from square_authentication.configuration import (
47
+ GOOGLE_AUTH_PLATFORM_CLIENT_ID,
48
+ )
48
49
  from square_authentication.configuration import (
49
50
  config_int_access_token_valid_minutes,
50
51
  config_int_refresh_token_valid_minutes,
@@ -53,7 +54,6 @@ from square_authentication.configuration import (
53
54
  global_object_square_logger,
54
55
  global_object_square_database_helper,
55
56
  MAIL_GUN_API_KEY,
56
- GOOGLE_AUTH_PLATFORM_CLIENT_ID,
57
57
  NUMBER_OF_RECOVERY_CODES,
58
58
  NUMBER_OF_DIGITS_IN_EMAIL_PASSWORD_RESET_CODE,
59
59
  EXPIRY_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS,
@@ -62,34 +62,14 @@ from square_authentication.configuration import (
62
62
  )
63
63
  from square_authentication.messages import messages
64
64
  from square_authentication.pydantic_models.core import (
65
- DeleteUserV0,
66
- LoginUsernameV0,
67
- LogoutAppsV0,
68
- RegisterUsernameV0,
69
65
  TokenType,
70
- UpdatePasswordV0,
71
- ResetPasswordAndLoginUsingBackupCodeV0,
72
- SendResetPasswordEmailV0,
73
- ResetPasswordAndLoginUsingResetEmailCodeV0,
74
- RegisterLoginGoogleV0,
75
66
  )
76
67
  from square_authentication.utils.core import generate_default_username_for_google_users
77
68
  from square_authentication.utils.token import get_jwt_payload
78
69
 
79
- router = APIRouter(
80
- tags=["core"],
81
- )
82
-
83
70
 
84
- @router.post("/register_username/v0")
85
71
  @global_object_square_logger.auto_logger()
86
- async def register_username_v0(
87
- body: RegisterUsernameV0,
88
- ):
89
- username = body.username
90
- password = body.password
91
- app_id = body.app_id
92
-
72
+ def util_register_username_v0(username, password, app_id):
93
73
  local_str_user_id = None
94
74
  local_str_access_token = None
95
75
  local_str_refresh_token = None
@@ -296,11 +276,8 @@ async def register_username_v0(
296
276
  )
297
277
 
298
278
 
299
- @router.post("/register_login_google/v0")
300
- async def register_login_google_v0(body: RegisterLoginGoogleV0):
301
- app_id = body.app_id
302
- google_id = body.google_id
303
- assign_app_id_if_missing = body.assign_app_id_if_missing
279
+ @global_object_square_logger.auto_logger()
280
+ def util_register_login_google_v0(google_id, assign_app_id_if_missing, app_id):
304
281
  was_new_user = False
305
282
  try:
306
283
  """
@@ -656,11 +633,8 @@ async def register_login_google_v0(body: RegisterLoginGoogleV0):
656
633
  )
657
634
 
658
635
 
659
- @router.get("/get_user_details/v0")
660
636
  @global_object_square_logger.auto_logger()
661
- async def get_user_details_v0(
662
- access_token: Annotated[str, Header()],
663
- ):
637
+ def util_get_user_details_v0(access_token):
664
638
  try:
665
639
  """
666
640
  validation
@@ -682,6 +656,16 @@ async def get_user_details_v0(
682
656
  """
683
657
  main process
684
658
  """
659
+ local_list_user = global_object_square_database_helper.get_rows_v0(
660
+ database_name=global_string_database_name,
661
+ schema_name=global_string_schema_name,
662
+ table_name=User.__tablename__,
663
+ filters=FiltersV0(
664
+ root={
665
+ User.user_id.name: FilterConditionsV0(eq=user_id),
666
+ }
667
+ ),
668
+ )["data"]["main"]
685
669
  local_list_app = global_object_square_database_helper.get_rows_v0(
686
670
  database_name=global_string_database_name,
687
671
  schema_name=global_string_public_schema_name,
@@ -729,6 +713,7 @@ async def get_user_details_v0(
729
713
  """
730
714
  return_this = {
731
715
  "user_id": user_id,
716
+ "username": local_list_user[0][User.user_username.name],
732
717
  "profile": user_profile,
733
718
  "apps": [
734
719
  y[App.app_name.name]
@@ -782,13 +767,8 @@ async def get_user_details_v0(
782
767
  )
783
768
 
784
769
 
785
- @router.patch("/update_user_app_ids/v0")
786
770
  @global_object_square_logger.auto_logger()
787
- async def update_user_app_ids_v0(
788
- access_token: Annotated[str, Header()],
789
- app_ids_to_add: List[int],
790
- app_ids_to_remove: List[int],
791
- ):
771
+ def util_update_user_app_ids_v0(access_token, app_ids_to_add, app_ids_to_remove):
792
772
  try:
793
773
 
794
774
  """
@@ -943,14 +923,8 @@ async def update_user_app_ids_v0(
943
923
  )
944
924
 
945
925
 
946
- @router.post("/login_username/v0")
947
926
  @global_object_square_logger.auto_logger()
948
- async def login_username_v0(body: LoginUsernameV0):
949
- username = body.username
950
- password = body.password
951
- app_id = body.app_id
952
- assign_app_id_if_missing = body.assign_app_id_if_missing
953
- username = username.lower()
927
+ def util_login_username_v0(username, password, app_id, assign_app_id_if_missing):
954
928
  try:
955
929
  """
956
930
  validation
@@ -1173,11 +1147,8 @@ async def login_username_v0(body: LoginUsernameV0):
1173
1147
  )
1174
1148
 
1175
1149
 
1176
- @router.get("/generate_access_token/v0")
1177
1150
  @global_object_square_logger.auto_logger()
1178
- async def generate_access_token_v0(
1179
- refresh_token: Annotated[str, Header()],
1180
- ):
1151
+ def util_generate_access_token_v0(refresh_token):
1181
1152
  try:
1182
1153
  """
1183
1154
  validation
@@ -1264,11 +1235,8 @@ async def generate_access_token_v0(
1264
1235
  )
1265
1236
 
1266
1237
 
1267
- @router.delete("/logout/v0")
1268
1238
  @global_object_square_logger.auto_logger()
1269
- async def logout_v0(
1270
- refresh_token: Annotated[str, Header()],
1271
- ):
1239
+ def util_logout_v0(refresh_token):
1272
1240
  try:
1273
1241
  """
1274
1242
  validation
@@ -1356,13 +1324,8 @@ async def logout_v0(
1356
1324
  )
1357
1325
 
1358
1326
 
1359
- @router.post("/logout/apps/v0")
1360
1327
  @global_object_square_logger.auto_logger()
1361
- async def logout_apps_v0(
1362
- access_token: Annotated[str, Header()],
1363
- body: LogoutAppsV0,
1364
- ):
1365
- app_ids = body.app_ids
1328
+ def util_logout_apps_v0(access_token, app_ids):
1366
1329
  try:
1367
1330
  """
1368
1331
  validation
@@ -1449,12 +1412,8 @@ async def logout_apps_v0(
1449
1412
  )
1450
1413
 
1451
1414
 
1452
- @router.delete("/logout/all/v0")
1453
1415
  @global_object_square_logger.auto_logger()
1454
- async def logout_all_v0(
1455
- access_token: Annotated[str, Header()],
1456
- ):
1457
-
1416
+ def util_logout_all_v0(access_token):
1458
1417
  try:
1459
1418
  """
1460
1419
  validation
@@ -1513,12 +1472,8 @@ async def logout_all_v0(
1513
1472
  )
1514
1473
 
1515
1474
 
1516
- @router.patch("/update_username/v0")
1517
1475
  @global_object_square_logger.auto_logger()
1518
- async def update_username_v0(
1519
- new_username: str,
1520
- access_token: Annotated[str, Header()],
1521
- ):
1476
+ def util_update_username_v0(new_username, access_token):
1522
1477
  try:
1523
1478
  """
1524
1479
  validation
@@ -1641,13 +1596,8 @@ async def update_username_v0(
1641
1596
  )
1642
1597
 
1643
1598
 
1644
- @router.post("/delete_user/v0")
1645
1599
  @global_object_square_logger.auto_logger()
1646
- async def delete_user_v0(
1647
- body: DeleteUserV0,
1648
- access_token: Annotated[str, Header()],
1649
- ):
1650
- password = body.password
1600
+ def util_delete_user_v0(access_token, password):
1651
1601
  try:
1652
1602
  """
1653
1603
  validation
@@ -1770,16 +1720,14 @@ async def delete_user_v0(
1770
1720
  )
1771
1721
 
1772
1722
 
1773
- @router.patch("/update_password/v0")
1774
1723
  @global_object_square_logger.auto_logger()
1775
- async def update_password_v0(
1776
- body: UpdatePasswordV0,
1777
- access_token: Annotated[str, Header()],
1724
+ def util_update_password_v0(
1725
+ access_token,
1726
+ old_password,
1727
+ new_password,
1728
+ logout_other_sessions,
1729
+ preserve_session_refresh_token,
1778
1730
  ):
1779
- old_password = body.old_password
1780
- new_password = body.new_password
1781
- logout_other_sessions = body.logout_other_sessions
1782
- preserve_session_refresh_token = body.preserve_session_refresh_token
1783
1731
  try:
1784
1732
  """
1785
1733
  validation
@@ -1984,14 +1932,8 @@ async def update_password_v0(
1984
1932
  )
1985
1933
 
1986
1934
 
1987
- @router.get("/validate_and_get_payload_from_token/v0")
1988
1935
  @global_object_square_logger.auto_logger()
1989
- async def validate_and_get_payload_from_token_v0(
1990
- app_id: int,
1991
- token: Annotated[str, Header()],
1992
- token_type: TokenType = Query(...),
1993
- ):
1994
-
1936
+ def util_validate_and_get_payload_from_token_v0(app_id, token, token_type):
1995
1937
  try:
1996
1938
  """
1997
1939
  validation
@@ -2093,12 +2035,9 @@ async def validate_and_get_payload_from_token_v0(
2093
2035
  )
2094
2036
 
2095
2037
 
2096
- @router.patch("/update_user_recovery_methods/v0")
2097
2038
  @global_object_square_logger.auto_logger()
2098
- async def update_user_recovery_methods_v0(
2099
- access_token: Annotated[str, Header()],
2100
- recovery_methods_to_add: List[RecoveryMethodEnum] = None,
2101
- recovery_methods_to_remove: List[RecoveryMethodEnum] = None,
2039
+ def util_update_user_recovery_methods_v0(
2040
+ access_token, recovery_methods_to_add, recovery_methods_to_remove
2102
2041
  ):
2103
2042
  if recovery_methods_to_add is None:
2104
2043
  recovery_methods_to_add = []
@@ -2318,12 +2257,8 @@ async def update_user_recovery_methods_v0(
2318
2257
  )
2319
2258
 
2320
2259
 
2321
- @router.post("/generate_account_backup_codes/v0")
2322
2260
  @global_object_square_logger.auto_logger()
2323
- async def generate_account_backup_codes_v0(
2324
- access_token: Annotated[str, Header()],
2325
- ):
2326
-
2261
+ def util_generate_account_backup_codes_v0(access_token):
2327
2262
  try:
2328
2263
  """
2329
2264
  validation
@@ -2459,16 +2394,10 @@ async def generate_account_backup_codes_v0(
2459
2394
  )
2460
2395
 
2461
2396
 
2462
- @router.post("/reset_password_and_login_using_backup_code/v0")
2463
2397
  @global_object_square_logger.auto_logger()
2464
- async def reset_password_and_login_using_backup_code_v0(
2465
- body: ResetPasswordAndLoginUsingBackupCodeV0,
2398
+ def util_reset_password_and_login_using_backup_code_v0(
2399
+ backup_code, username, new_password, app_id, logout_other_sessions
2466
2400
  ):
2467
- backup_code = body.backup_code
2468
- username = body.username
2469
- new_password = body.new_password
2470
- app_id = body.app_id
2471
- logout_other_sessions = body.logout_other_sessions
2472
2401
  try:
2473
2402
  """
2474
2403
  validation
@@ -2742,12 +2671,10 @@ async def reset_password_and_login_using_backup_code_v0(
2742
2671
  )
2743
2672
 
2744
2673
 
2745
- @router.post("/send_reset_password_email/v0")
2746
2674
  @global_object_square_logger.auto_logger()
2747
- async def send_reset_password_email_v0(
2748
- body: SendResetPasswordEmailV0,
2675
+ def util_send_reset_password_email_v0(
2676
+ username,
2749
2677
  ):
2750
- username = body.username
2751
2678
  try:
2752
2679
  """
2753
2680
  validation
@@ -2952,7 +2879,7 @@ async def send_reset_password_email_v0(
2952
2879
  to_email=user_profile_data[UserProfile.user_profile_email.name],
2953
2880
  to_name=user_to_name,
2954
2881
  subject="Password Reset Verification Code",
2955
- body=f"Your Password Reset verification code is {verification_code}. It will expire in {EXPIRY_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS/60} minutes.",
2882
+ body=f"Your Password Reset verification code is {verification_code}. It will expire in {EXPIRY_TIME_FOR_EMAIL_PASSWORD_RESET_CODE_IN_SECONDS / 60} minutes.",
2956
2883
  api_key=MAIL_GUN_API_KEY,
2957
2884
  domain_name="thepmsquare.com",
2958
2885
  )
@@ -3010,16 +2937,10 @@ async def send_reset_password_email_v0(
3010
2937
  )
3011
2938
 
3012
2939
 
3013
- @router.post("/reset_password_and_login_using_reset_email_code/v0")
3014
2940
  @global_object_square_logger.auto_logger()
3015
- async def reset_password_and_login_using_reset_email_code_v0(
3016
- body: ResetPasswordAndLoginUsingResetEmailCodeV0,
2941
+ def util_reset_password_and_login_using_reset_email_code_v0(
2942
+ reset_email_code, username, new_password, app_id, logout_other_sessions
3017
2943
  ):
3018
- reset_email_code = body.reset_email_code
3019
- username = body.username
3020
- new_password = body.new_password
3021
- app_id = body.app_id
3022
- logout_other_sessions = body.logout_other_sessions
3023
2944
  try:
3024
2945
  """
3025
2946
  validation
@@ -1,9 +1,8 @@
1
1
  import random
2
2
  from datetime import datetime, timedelta, timezone
3
- from typing import Annotated, Optional
4
3
 
5
4
  import bcrypt
6
- from fastapi import APIRouter, Header, HTTPException, UploadFile, status
5
+ from fastapi import HTTPException, status
7
6
  from fastapi.responses import JSONResponse
8
7
  from square_commons import get_api_output_in_standard_format
9
8
  from square_commons.email import send_email_using_mailgun
@@ -31,27 +30,17 @@ from square_authentication.configuration import (
31
30
  RESEND_COOL_DOWN_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS,
32
31
  config_str_secret_key_for_access_token,
33
32
  global_object_square_database_helper,
34
- global_object_square_file_store_helper,
35
33
  global_object_square_logger,
36
34
  )
37
- from square_authentication.messages import messages
38
- from square_authentication.pydantic_models.profile import (
39
- ValidateEmailVerificationCodeV0,
35
+ from square_authentication.configuration import (
36
+ global_object_square_file_store_helper,
40
37
  )
38
+ from square_authentication.messages import messages
41
39
  from square_authentication.utils.token import get_jwt_payload
42
40
 
43
- router = APIRouter(
44
- tags=["profile"],
45
- )
46
41
 
47
-
48
- @router.patch("/update_profile_photo/v0")
49
42
  @global_object_square_logger.auto_logger()
50
- async def update_profile_photo_v0(
51
- access_token: Annotated[str, Header()],
52
- profile_photo: Optional[UploadFile] = None,
53
- ):
54
-
43
+ def util_update_profile_photo_v0(access_token, profile_photo):
55
44
  try:
56
45
  """
57
46
  validation
@@ -188,15 +177,14 @@ async def update_profile_photo_v0(
188
177
  )
189
178
 
190
179
 
191
- @router.patch("/update_profile_details/v0")
192
180
  @global_object_square_logger.auto_logger()
193
- async def update_profile_details_v0(
194
- access_token: Annotated[str, Header()],
195
- first_name: Optional[str] = None,
196
- last_name: Optional[str] = None,
197
- email: Optional[str] = None,
198
- phone_number_country_code: Optional[str] = None,
199
- phone_number: Optional[str] = None,
181
+ def util_update_profile_details_v0(
182
+ access_token,
183
+ first_name,
184
+ last_name,
185
+ email,
186
+ phone_number_country_code,
187
+ phone_number,
200
188
  ):
201
189
  try:
202
190
  """
@@ -308,11 +296,8 @@ async def update_profile_details_v0(
308
296
  )
309
297
 
310
298
 
311
- @router.post("/send_verification_email/v0")
312
299
  @global_object_square_logger.auto_logger()
313
- async def send_verification_email_v0(
314
- access_token: Annotated[str, Header()],
315
- ):
300
+ def util_send_verification_email_v0(access_token):
316
301
  try:
317
302
  """
318
303
  validation
@@ -455,7 +440,7 @@ async def send_verification_email_v0(
455
440
  to_email=user_profile_data[UserProfile.user_profile_email.name],
456
441
  to_name=user_to_name,
457
442
  subject="Email Verification",
458
- body=f"Your verification code is {verification_code}. It will expire in {EXPIRY_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS/60} minutes.",
443
+ body=f"Your verification code is {verification_code}. It will expire in {EXPIRY_TIME_FOR_EMAIL_VERIFICATION_CODE_IN_SECONDS / 60} minutes.",
459
444
  api_key=MAIL_GUN_API_KEY,
460
445
  domain_name="thepmsquare.com",
461
446
  )
@@ -512,13 +497,8 @@ async def send_verification_email_v0(
512
497
  )
513
498
 
514
499
 
515
- @router.post("/validate_email_verification_code/v0")
516
500
  @global_object_square_logger.auto_logger()
517
- async def validate_email_verification_code_v0(
518
- access_token: Annotated[str, Header()],
519
- body: ValidateEmailVerificationCodeV0,
520
- ):
521
- verification_code = body.verification_code
501
+ def util_validate_email_verification_code_v0(access_token, verification_code):
522
502
  try:
523
503
  """
524
504
  validation
@@ -1,20 +1,14 @@
1
1
  import bcrypt
2
- from fastapi import APIRouter, status, HTTPException
2
+ from fastapi import status, HTTPException
3
3
  from fastapi.responses import JSONResponse
4
4
  from square_commons import get_api_output_in_standard_format
5
5
 
6
6
  from square_authentication.configuration import global_object_square_logger
7
7
  from square_authentication.messages import messages
8
8
 
9
- router = APIRouter(
10
- tags=["utility"],
11
- )
12
9
 
13
-
14
- @router.get("/get_text_hash/v0")
15
10
  @global_object_square_logger.auto_logger()
16
- async def get_text_hash_v0(plain_text: str):
17
-
11
+ def util_get_text_hash_v0(plain_text):
18
12
  try:
19
13
  """
20
14
  validation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: square_authentication
3
- Version: 10.0.0
3
+ Version: 10.0.2
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
@@ -54,7 +54,12 @@ authentication layer for my personal server.
54
54
 
55
55
  ## goals
56
56
 
57
- (wip)
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
 
@@ -24,6 +24,10 @@ square_authentication/utils/__init__.py
24
24
  square_authentication/utils/core.py
25
25
  square_authentication/utils/encryption.py
26
26
  square_authentication/utils/token.py
27
+ square_authentication/utils/routes/__init__.py
28
+ square_authentication/utils/routes/core.py
29
+ square_authentication/utils/routes/profile.py
30
+ square_authentication/utils/routes/utility.py
27
31
  tests/test_1.py
28
32
  tests/test_authentication.py
29
33
  tests/test_delete_user.py