mdbq 4.0.104__tar.gz → 4.0.105__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.

Potentially problematic release.


This version of mdbq might be problematic. Click here for more details.

Files changed (44) hide show
  1. {mdbq-4.0.104 → mdbq-4.0.105}/PKG-INFO +1 -1
  2. mdbq-4.0.105/mdbq/__version__.py +1 -0
  3. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/auth/auth_backend.py +27 -39
  4. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq.egg-info/PKG-INFO +1 -1
  5. mdbq-4.0.104/mdbq/__version__.py +0 -1
  6. {mdbq-4.0.104 → mdbq-4.0.105}/README.txt +0 -0
  7. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/__init__.py +0 -0
  8. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/auth/__init__.py +0 -0
  9. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/auth/rate_limiter.py +0 -0
  10. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/js/__init__.py +0 -0
  11. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/js/jc.py +0 -0
  12. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/log/__init__.py +0 -0
  13. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/log/mylogger.py +0 -0
  14. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/myconf/__init__.py +0 -0
  15. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/myconf/myconf.py +0 -0
  16. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/mysql/__init__.py +0 -0
  17. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/mysql/deduplicator.py +0 -0
  18. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/mysql/mysql.py +0 -0
  19. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/mysql/s_query.py +0 -0
  20. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/mysql/unique_.py +0 -0
  21. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/mysql/uploader.py +0 -0
  22. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/other/__init__.py +0 -0
  23. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/other/download_sku_picture.py +0 -0
  24. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/other/error_handler.py +0 -0
  25. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/other/otk.py +0 -0
  26. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/other/pov_city.py +0 -0
  27. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/other/ua_sj.py +0 -0
  28. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/pbix/__init__.py +0 -0
  29. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/pbix/pbix_refresh.py +0 -0
  30. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/pbix/refresh_all.py +0 -0
  31. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/redis/__init__.py +0 -0
  32. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/redis/getredis.py +0 -0
  33. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/route/__init__.py +0 -0
  34. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/route/analytics.py +0 -0
  35. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/route/monitor.py +0 -0
  36. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/route/routes.py +0 -0
  37. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/selenium/__init__.py +0 -0
  38. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/selenium/get_driver.py +0 -0
  39. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq/spider/__init__.py +0 -0
  40. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq.egg-info/SOURCES.txt +0 -0
  41. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq.egg-info/dependency_links.txt +0 -0
  42. {mdbq-4.0.104 → mdbq-4.0.105}/mdbq.egg-info/top_level.txt +0 -0
  43. {mdbq-4.0.104 → mdbq-4.0.105}/setup.cfg +0 -0
  44. {mdbq-4.0.104 → mdbq-4.0.105}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdbq
3
- Version: 4.0.104
3
+ Version: 4.0.105
4
4
  Home-page: https://pypi.org/project/mdbq
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -0,0 +1 @@
1
+ VERSION = '4.0.105'
@@ -516,13 +516,7 @@ class StandaloneAuthManager:
516
516
 
517
517
  # 检查账户锁定状态
518
518
  current_time = datetime.now()
519
- if locked_until:
520
- if locked_until.tzinfo is None:
521
- locked_until = locked_until.replace(tzinfo=timezone.utc)
522
- elif locked_until.tzinfo != timezone.utc:
523
- locked_until = locked_until.astimezone(timezone.utc)
524
-
525
- if locked_until > current_time:
519
+ if locked_until and locked_until > current_time:
526
520
  remaining_seconds = int((locked_until - current_time).total_seconds())
527
521
  self._log_login_attempt(username_or_email, ip_address, user_agent, 'failure', 'account_locked', user_id)
528
522
  self._record_ip_failure(ip_address, 'login')
@@ -849,7 +843,7 @@ class StandaloneAuthManager:
849
843
  cursor = conn.cursor()
850
844
 
851
845
  try:
852
- current_time_utc = datetime.now(timezone.utc)
846
+ current_time = datetime.now()
853
847
 
854
848
  # 先查询要登出的设备数量
855
849
  cursor.execute('''
@@ -864,7 +858,7 @@ class StandaloneAuthManager:
864
858
  UPDATE refresh_tokens
865
859
  SET is_revoked = 1, revoked_at = %s, revoked_reason = 'logout'
866
860
  WHERE user_id = %s AND is_revoked = 0
867
- ''', (current_time_utc, user_id))
861
+ ''', (current_time, user_id))
868
862
 
869
863
  # 停用用户的所有设备会话
870
864
  cursor.execute('''
@@ -919,7 +913,7 @@ class StandaloneAuthManager:
919
913
  new_salt = secrets.token_hex(32)
920
914
  new_password_hash = self._hash_password(new_password, new_salt)
921
915
 
922
- current_time_utc = datetime.now(timezone.utc)
916
+ current_time = datetime.now()
923
917
 
924
918
  # 更新密码
925
919
  cursor.execute('''
@@ -934,7 +928,7 @@ class StandaloneAuthManager:
934
928
  UPDATE refresh_tokens
935
929
  SET is_revoked = 1, revoked_at = %s, revoked_reason = 'password_changed'
936
930
  WHERE user_id = %s AND is_revoked = 0
937
- ''', (current_time_utc, user_id))
931
+ ''', (current_time, user_id))
938
932
 
939
933
  # 停用所有设备会话
940
934
  cursor.execute('''
@@ -1055,7 +1049,7 @@ class StandaloneAuthManager:
1055
1049
  if len(new_password) < 6:
1056
1050
  return {'success': False, 'message': '新密码至少需要6个字符'}
1057
1051
 
1058
- current_time_utc = datetime.now(timezone.utc)
1052
+ current_time = datetime.now()
1059
1053
 
1060
1054
  # 查找有效的重置令牌
1061
1055
  cursor.execute('''
@@ -1064,7 +1058,7 @@ class StandaloneAuthManager:
1064
1058
  WHERE password_reset_token = %s
1065
1059
  AND password_reset_expires > %s
1066
1060
  AND is_active = 1
1067
- ''', (reset_token, current_time_utc))
1061
+ ''', (reset_token, current_time))
1068
1062
 
1069
1063
  user = cursor.fetchone()
1070
1064
  if not user:
@@ -1088,7 +1082,7 @@ class StandaloneAuthManager:
1088
1082
  UPDATE refresh_tokens
1089
1083
  SET is_revoked = 1, revoked_at = %s, revoked_reason = 'password_reset'
1090
1084
  WHERE user_id = %s AND is_revoked = 0
1091
- ''', (current_time_utc, user['id']))
1085
+ ''', (current_time, user['id']))
1092
1086
 
1093
1087
  # 停用所有设备会话
1094
1088
  cursor.execute('''
@@ -1133,16 +1127,10 @@ class StandaloneAuthManager:
1133
1127
 
1134
1128
  locked_until = record['locked_until']
1135
1129
 
1136
- current_time_utc = datetime.now(timezone.utc)
1137
- if locked_until:
1138
- if locked_until.tzinfo is None:
1139
- locked_until = locked_until.replace(tzinfo=timezone.utc)
1140
- elif locked_until.tzinfo != timezone.utc:
1141
- locked_until = locked_until.astimezone(timezone.utc)
1142
-
1143
- if locked_until > current_time_utc:
1144
- remaining_seconds = int((locked_until - current_time_utc).total_seconds())
1145
- return {
1130
+ current_time = datetime.now()
1131
+ if locked_until and locked_until > current_time:
1132
+ remaining_seconds = int((locked_until - current_time).total_seconds())
1133
+ return {
1146
1134
  'blocked': True,
1147
1135
  'remaining_time': remaining_seconds,
1148
1136
  'reason': f'IP被锁定,剩余时间: {remaining_seconds}秒'
@@ -1163,7 +1151,7 @@ class StandaloneAuthManager:
1163
1151
  cursor = conn.cursor()
1164
1152
 
1165
1153
  try:
1166
- now = datetime.now(timezone.utc)
1154
+ now = datetime.now()
1167
1155
 
1168
1156
  cursor.execute('''
1169
1157
  SELECT failure_count, first_failure, lockout_count
@@ -1179,7 +1167,7 @@ class StandaloneAuthManager:
1179
1167
  window_start = now - timedelta(minutes=window_minutes)
1180
1168
  first_failure = record['first_failure']
1181
1169
 
1182
- if first_failure and first_failure.replace(tzinfo=timezone.utc) <= window_start:
1170
+ if first_failure and first_failure <= window_start:
1183
1171
  # 重置计数器
1184
1172
  cursor.execute('''
1185
1173
  UPDATE ip_rate_limits
@@ -1225,14 +1213,14 @@ class StandaloneAuthManager:
1225
1213
 
1226
1214
  def _revoke_device_session(self, cursor, device_session_id, reason='manual'):
1227
1215
  """撤销设备会话"""
1228
- current_time_utc = datetime.now(timezone.utc)
1216
+ current_time = datetime.now()
1229
1217
 
1230
1218
  # 撤销设备相关的refresh token
1231
1219
  cursor.execute('''
1232
1220
  UPDATE refresh_tokens
1233
1221
  SET is_revoked = 1, revoked_at = %s, revoked_reason = %s
1234
1222
  WHERE device_session_id = %s AND is_revoked = 0
1235
- ''', (current_time_utc, reason, device_session_id))
1223
+ ''', (current_time, reason, device_session_id))
1236
1224
 
1237
1225
  # 停用设备会话
1238
1226
  cursor.execute('''
@@ -1446,7 +1434,7 @@ class StandaloneAuthManager:
1446
1434
  cursor = conn.cursor()
1447
1435
 
1448
1436
  try:
1449
- current_time_utc = datetime.now(timezone.utc)
1437
+ current_time = datetime.now()
1450
1438
 
1451
1439
  if device_id:
1452
1440
  # 方式1:通过device_id查找设备(用于设备管理界面)
@@ -1504,7 +1492,7 @@ class StandaloneAuthManager:
1504
1492
  UPDATE refresh_tokens
1505
1493
  SET is_revoked = 1, revoked_at = %s, revoked_reason = %s
1506
1494
  WHERE device_session_id = %s AND is_revoked = 0
1507
- ''', (current_time_utc, logout_reason, device_session_id))
1495
+ ''', (current_time, logout_reason, device_session_id))
1508
1496
 
1509
1497
  # 停用设备会话
1510
1498
  cursor.execute('''
@@ -1537,7 +1525,7 @@ class StandaloneAuthManager:
1537
1525
  cursor = conn.cursor()
1538
1526
 
1539
1527
  try:
1540
- current_time_utc = datetime.now(timezone.utc)
1528
+ current_time = datetime.now()
1541
1529
 
1542
1530
  if access_token:
1543
1531
  # 方式1:通过access_token解析出设备会话信息
@@ -1586,7 +1574,7 @@ class StandaloneAuthManager:
1586
1574
  UPDATE refresh_tokens
1587
1575
  SET is_revoked = 1, revoked_at = %s, revoked_reason = 'current_device_logout'
1588
1576
  WHERE device_session_id = %s AND is_revoked = 0
1589
- ''', (current_time_utc, device_session_id))
1577
+ ''', (current_time, device_session_id))
1590
1578
 
1591
1579
  # 停用设备会话
1592
1580
  cursor.execute('''
@@ -1618,7 +1606,7 @@ class StandaloneAuthManager:
1618
1606
  cursor = conn.cursor()
1619
1607
 
1620
1608
  try:
1621
- current_time_utc = datetime.now(timezone.utc)
1609
+ current_time = datetime.now()
1622
1610
 
1623
1611
  # 通过device_id查找设备,确保属于该用户
1624
1612
  cursor.execute('''
@@ -1639,7 +1627,7 @@ class StandaloneAuthManager:
1639
1627
  UPDATE refresh_tokens
1640
1628
  SET is_revoked = 1, revoked_at = %s, revoked_reason = 'specific_device_logout'
1641
1629
  WHERE device_session_id = %s AND is_revoked = 0
1642
- ''', (current_time_utc, device_session_id))
1630
+ ''', (current_time, device_session_id))
1643
1631
 
1644
1632
  # 停用设备会话
1645
1633
  cursor.execute('''
@@ -1735,8 +1723,8 @@ class StandaloneAuthManager:
1735
1723
  cursor = conn.cursor()
1736
1724
 
1737
1725
  try:
1738
- current_time_utc = datetime.now(timezone.utc)
1739
- threshold_time = current_time_utc - timedelta(days=days_threshold)
1726
+ current_time = datetime.now()
1727
+ threshold_time = current_time - timedelta(days=days_threshold)
1740
1728
 
1741
1729
  # 查找不活跃的设备
1742
1730
  cursor.execute('''
@@ -1757,7 +1745,7 @@ class StandaloneAuthManager:
1757
1745
  WHERE device_session_id IN ({})
1758
1746
  AND is_revoked = 0
1759
1747
  '''.format(','.join(['%s'] * len(device_session_ids))),
1760
- [current_time_utc] + device_session_ids)
1748
+ [current_time] + device_session_ids)
1761
1749
 
1762
1750
  # 停用设备会话
1763
1751
  cursor.execute('''
@@ -1891,8 +1879,8 @@ class StandaloneAuthManager:
1891
1879
  cursor = conn.cursor()
1892
1880
 
1893
1881
  try:
1894
- current_time_utc = datetime.now(timezone.utc)
1895
- threshold_time = current_time_utc - timedelta(days=days_threshold)
1882
+ current_time = datetime.now()
1883
+ threshold_time = current_time - timedelta(days=days_threshold)
1896
1884
 
1897
1885
  if user_id:
1898
1886
  # 清理特定用户的旧记录
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdbq
3
- Version: 4.0.104
3
+ Version: 4.0.105
4
4
  Home-page: https://pypi.org/project/mdbq
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -1 +0,0 @@
1
- VERSION = '4.0.104'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes