square-authentication 6.1.0__tar.gz → 6.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-6.1.0 → square_authentication-6.2.0}/PKG-INFO +6 -1
- {square_authentication-6.1.0 → square_authentication-6.2.0}/README.md +5 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/setup.py +1 -1
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/routes/core.py +148 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication.egg-info/PKG-INFO +6 -1
- {square_authentication-6.1.0 → square_authentication-6.2.0}/setup.cfg +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/__init__.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/configuration.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/data/config.ini +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/data/config.testing.ini +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/main.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/messages.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/pydantic_models/__init__.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/pydantic_models/core.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/routes/__init__.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/routes/profile.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/routes/utility.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/utils/__init__.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/utils/encryption.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/utils/token.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication.egg-info/SOURCES.txt +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication.egg-info/dependency_links.txt +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication.egg-info/requires.txt +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication.egg-info/top_level.txt +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/tests/test_1.py +0 -0
- {square_authentication-6.1.0 → square_authentication-6.2.0}/tests/test_username.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: square_authentication
|
3
|
-
Version: 6.
|
3
|
+
Version: 6.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
|
@@ -53,6 +53,11 @@ pip install square_authentication
|
|
53
53
|
|
54
54
|
## changelog
|
55
55
|
|
56
|
+
### v6.2.0
|
57
|
+
|
58
|
+
- core
|
59
|
+
- add update_user_recovery_methods_v0.
|
60
|
+
|
56
61
|
### v6.1.0
|
57
62
|
|
58
63
|
- add validation to username in register_username_v0 and update_username_v0.
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/routes/core.py
RENAMED
@@ -13,12 +13,14 @@ from square_commons import get_api_output_in_standard_format
|
|
13
13
|
from square_database_helper.pydantic_models import FilterConditionsV0, FiltersV0
|
14
14
|
from square_database_structure.square import global_string_database_name
|
15
15
|
from square_database_structure.square.authentication import global_string_schema_name
|
16
|
+
from square_database_structure.square.authentication.enums import RecoveryMethodEnum
|
16
17
|
from square_database_structure.square.authentication.tables import (
|
17
18
|
User,
|
18
19
|
UserApp,
|
19
20
|
UserCredential,
|
20
21
|
UserSession,
|
21
22
|
UserProfile,
|
23
|
+
UserRecoveryMethod,
|
22
24
|
)
|
23
25
|
from square_database_structure.square.public import (
|
24
26
|
global_string_schema_name as global_string_public_schema_name,
|
@@ -1540,3 +1542,149 @@ async def validate_and_get_payload_from_token_v0(
|
|
1540
1542
|
return JSONResponse(
|
1541
1543
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=output_content
|
1542
1544
|
)
|
1545
|
+
|
1546
|
+
|
1547
|
+
@router.patch("/update_user_recovery_methods/v0")
|
1548
|
+
@global_object_square_logger.auto_logger()
|
1549
|
+
async def update_user_recovery_methods_v0(
|
1550
|
+
access_token: Annotated[str, Header()],
|
1551
|
+
recovery_methods_to_add: List[RecoveryMethodEnum],
|
1552
|
+
recovery_methods_to_remove: List[RecoveryMethodEnum],
|
1553
|
+
):
|
1554
|
+
try:
|
1555
|
+
|
1556
|
+
"""
|
1557
|
+
validation
|
1558
|
+
"""
|
1559
|
+
# validate access token
|
1560
|
+
try:
|
1561
|
+
local_dict_access_token_payload = get_jwt_payload(
|
1562
|
+
access_token, config_str_secret_key_for_access_token
|
1563
|
+
)
|
1564
|
+
except Exception as error:
|
1565
|
+
output_content = get_api_output_in_standard_format(
|
1566
|
+
message=messages["INCORRECT_ACCESS_TOKEN"], log=str(error)
|
1567
|
+
)
|
1568
|
+
raise HTTPException(
|
1569
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
1570
|
+
detail=output_content,
|
1571
|
+
)
|
1572
|
+
user_id = local_dict_access_token_payload["user_id"]
|
1573
|
+
|
1574
|
+
recovery_methods_to_add = list(set(x.value for x in recovery_methods_to_add))
|
1575
|
+
recovery_methods_to_remove = list(
|
1576
|
+
set(x.value for x in recovery_methods_to_remove)
|
1577
|
+
)
|
1578
|
+
|
1579
|
+
# check if recovery_methods_to_add and recovery_methods_to_remove don't have common ids.
|
1580
|
+
local_list_common_recovery_methods = set(recovery_methods_to_add) & set(
|
1581
|
+
recovery_methods_to_remove
|
1582
|
+
)
|
1583
|
+
if len(local_list_common_recovery_methods) > 0:
|
1584
|
+
output_content = get_api_output_in_standard_format(
|
1585
|
+
message=messages["GENERIC_400"],
|
1586
|
+
log=f"invalid recovery_methods: {list(local_list_common_recovery_methods)}, present in both add list and remove list.",
|
1587
|
+
)
|
1588
|
+
raise HTTPException(
|
1589
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
1590
|
+
detail=output_content,
|
1591
|
+
)
|
1592
|
+
|
1593
|
+
"""
|
1594
|
+
main process
|
1595
|
+
"""
|
1596
|
+
# logic for adding new recovery_methods
|
1597
|
+
local_list_response_user_recovery_methods = (
|
1598
|
+
global_object_square_database_helper.get_rows_v0(
|
1599
|
+
database_name=global_string_database_name,
|
1600
|
+
schema_name=global_string_schema_name,
|
1601
|
+
table_name=UserRecoveryMethod.__tablename__,
|
1602
|
+
filters=FiltersV0(
|
1603
|
+
root={
|
1604
|
+
UserRecoveryMethod.user_id.name: FilterConditionsV0(eq=user_id)
|
1605
|
+
}
|
1606
|
+
),
|
1607
|
+
)["data"]["main"]
|
1608
|
+
)
|
1609
|
+
local_list_new_recovery_methods = [
|
1610
|
+
{
|
1611
|
+
UserRecoveryMethod.user_id.name: user_id,
|
1612
|
+
UserRecoveryMethod.user_recovery_method_name.name: x,
|
1613
|
+
}
|
1614
|
+
for x in recovery_methods_to_add
|
1615
|
+
if x
|
1616
|
+
not in [
|
1617
|
+
y[UserRecoveryMethod.user_recovery_method_name.name]
|
1618
|
+
for y in local_list_response_user_recovery_methods
|
1619
|
+
]
|
1620
|
+
]
|
1621
|
+
if len(local_list_new_recovery_methods) > 0:
|
1622
|
+
global_object_square_database_helper.insert_rows_v0(
|
1623
|
+
database_name=global_string_database_name,
|
1624
|
+
schema_name=global_string_schema_name,
|
1625
|
+
table_name=UserRecoveryMethod.__tablename__,
|
1626
|
+
data=local_list_new_recovery_methods,
|
1627
|
+
)
|
1628
|
+
|
1629
|
+
# logic for removing recovery_methods
|
1630
|
+
global_object_square_database_helper.delete_rows_v0(
|
1631
|
+
database_name=global_string_database_name,
|
1632
|
+
schema_name=global_string_schema_name,
|
1633
|
+
table_name=UserRecoveryMethod.__tablename__,
|
1634
|
+
filters=FiltersV0(
|
1635
|
+
root={
|
1636
|
+
UserRecoveryMethod.user_id.name: FilterConditionsV0(eq=user_id),
|
1637
|
+
UserRecoveryMethod.user_recovery_method_name.name: FilterConditionsV0(
|
1638
|
+
in_=recovery_methods_to_remove
|
1639
|
+
),
|
1640
|
+
}
|
1641
|
+
),
|
1642
|
+
)
|
1643
|
+
|
1644
|
+
"""
|
1645
|
+
return value
|
1646
|
+
"""
|
1647
|
+
# get latest recovery_methods
|
1648
|
+
local_list_response_user_recovery_methods = (
|
1649
|
+
global_object_square_database_helper.get_rows_v0(
|
1650
|
+
database_name=global_string_database_name,
|
1651
|
+
schema_name=global_string_schema_name,
|
1652
|
+
table_name=UserRecoveryMethod.__tablename__,
|
1653
|
+
filters=FiltersV0(
|
1654
|
+
root={
|
1655
|
+
UserRecoveryMethod.user_id.name: FilterConditionsV0(eq=user_id)
|
1656
|
+
}
|
1657
|
+
),
|
1658
|
+
)["data"]["main"]
|
1659
|
+
)
|
1660
|
+
output_content = get_api_output_in_standard_format(
|
1661
|
+
message=messages["GENERIC_UPDATE_SUCCESSFUL"],
|
1662
|
+
data={
|
1663
|
+
"main": [
|
1664
|
+
x[UserRecoveryMethod.user_recovery_method_name.name]
|
1665
|
+
for x in local_list_response_user_recovery_methods
|
1666
|
+
]
|
1667
|
+
},
|
1668
|
+
)
|
1669
|
+
return JSONResponse(
|
1670
|
+
status_code=status.HTTP_200_OK,
|
1671
|
+
content=output_content,
|
1672
|
+
)
|
1673
|
+
except HTTPException as http_exception:
|
1674
|
+
global_object_square_logger.logger.error(http_exception, exc_info=True)
|
1675
|
+
return JSONResponse(
|
1676
|
+
status_code=http_exception.status_code, content=http_exception.detail
|
1677
|
+
)
|
1678
|
+
except Exception as e:
|
1679
|
+
"""
|
1680
|
+
rollback logic
|
1681
|
+
"""
|
1682
|
+
global_object_square_logger.logger.error(e, exc_info=True)
|
1683
|
+
output_content = get_api_output_in_standard_format(
|
1684
|
+
message=messages["GENERIC_500"],
|
1685
|
+
log=str(e),
|
1686
|
+
)
|
1687
|
+
return JSONResponse(
|
1688
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
1689
|
+
content=output_content,
|
1690
|
+
)
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication.egg-info/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: square_authentication
|
3
|
-
Version: 6.
|
3
|
+
Version: 6.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
|
@@ -53,6 +53,11 @@ pip install square_authentication
|
|
53
53
|
|
54
54
|
## changelog
|
55
55
|
|
56
|
+
### v6.2.0
|
57
|
+
|
58
|
+
- core
|
59
|
+
- add update_user_recovery_methods_v0.
|
60
|
+
|
56
61
|
### v6.1.0
|
57
62
|
|
58
63
|
- add validation to username in register_username_v0 and update_username_v0.
|
File without changes
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/__init__.py
RENAMED
File without changes
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/configuration.py
RENAMED
File without changes
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/data/config.ini
RENAMED
File without changes
|
File without changes
|
File without changes
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/messages.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/routes/__init__.py
RENAMED
File without changes
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/routes/profile.py
RENAMED
File without changes
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/routes/utility.py
RENAMED
File without changes
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/utils/__init__.py
RENAMED
File without changes
|
File without changes
|
{square_authentication-6.1.0 → square_authentication-6.2.0}/square_authentication/utils/token.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|