aws-python-helper 1.12.0__tar.gz → 1.13.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.
Files changed (62) hide show
  1. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/PKG-INFO +1 -1
  2. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/auth_validators.py +58 -29
  3. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/PKG-INFO +1 -1
  4. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/pyproject.toml +1 -1
  5. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/README.md +0 -0
  6. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/__init__.py +0 -0
  7. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/__init__.py +0 -0
  8. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/auth_middleware.py +0 -0
  9. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/base.py +0 -0
  10. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/dispatcher.py +0 -0
  11. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/exceptions.py +0 -0
  12. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/fetcher.py +0 -0
  13. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/handler.py +0 -0
  14. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/context/__init__.py +0 -0
  15. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/context/session.py +0 -0
  16. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/context/state_validator.py +0 -0
  17. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/__init__.py +0 -0
  18. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/database_proxy.py +0 -0
  19. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/external_database_proxy.py +0 -0
  20. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/external_mongo_manager.py +0 -0
  21. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/mongo_manager.py +0 -0
  22. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/__init__.py +0 -0
  23. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/executor.py +0 -0
  24. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/fetcher.py +0 -0
  25. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/handler.py +0 -0
  26. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/task_base.py +0 -0
  27. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/__init__.py +0 -0
  28. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/api_client.py +0 -0
  29. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/exceptions.py +0 -0
  30. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/lambda_invoker.py +0 -0
  31. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/__init__.py +0 -0
  32. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/base.py +0 -0
  33. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/fetcher.py +0 -0
  34. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/handler.py +0 -0
  35. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_index_sync/__init__.py +0 -0
  36. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_index_sync/base.py +0 -0
  37. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_query/__init__.py +0 -0
  38. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_query/base.py +0 -0
  39. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/monitoring/__init__.py +0 -0
  40. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/monitoring/run.py +0 -0
  41. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/permissions/__init__.py +0 -0
  42. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/permissions/catalog.py +0 -0
  43. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/repository/__init__.py +0 -0
  44. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/repository/audit.py +0 -0
  45. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/repository/base.py +0 -0
  46. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sns/__init__.py +0 -0
  47. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sns/publisher.py +0 -0
  48. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sqs/__init__.py +0 -0
  49. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sqs/consumer_base.py +0 -0
  50. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sqs/fetcher.py +0 -0
  51. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sqs/handler.py +0 -0
  52. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/utils/__init__.py +0 -0
  53. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/utils/json_encoder.py +0 -0
  54. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/utils/response.py +0 -0
  55. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/utils/serializer.py +0 -0
  56. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/SOURCES.txt +0 -0
  57. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/dependency_links.txt +0 -0
  58. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/requires.txt +0 -0
  59. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/top_level.txt +0 -0
  60. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/setup.cfg +0 -0
  61. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/tests/test_audit_stamp.py +0 -0
  62. {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/tests/test_sns_publisher.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aws-python-helper
3
- Version: 1.12.0
3
+ Version: 1.13.0
4
4
  Summary: AWS Python Helper Framework
5
5
  Author-email: Fabian Claros <neufabiae@gmail.com>
6
6
  License-Expression: MIT
@@ -13,6 +13,56 @@ from ..database.mongo_manager import MongoManager
13
13
  logger = logging.getLogger(__name__)
14
14
 
15
15
 
16
+ def _machine_caller(token: str) -> Optional[Dict[str, Any]]:
17
+ """Quién es, cuando quien llama no es una persona.
18
+
19
+ Dos tokens distintos, porque son dos cosas distintas y confundirlas deja una
20
+ puerta abierta más ancha de lo que nadie quiso:
21
+
22
+ - `INTER_SERVICE_TOKEN` dice **"soy un microservicio de los nuestros"**. Es
23
+ lo que un servicio manda cuando le habla a otro. No es un usuario y no
24
+ tiene permisos de nadie: un endpoint que lo acepta lo dice explícitamente.
25
+ - `AUTH_BYPASS_TOKEN` es la **llave maestra**, la forma de entrar cuando una
26
+ configuración de permisos quedó mal. Abre todo, y por eso no debería ser la
27
+ que un servicio usa todos los días.
28
+
29
+ Devuelve None si el token no es ninguno de los dos, y entonces se valida como
30
+ lo que es: el token de una persona.
31
+ """
32
+ service_token = os.getenv('INTER_SERVICE_TOKEN')
33
+ if service_token and token == service_token:
34
+ logger.info("Inter-service token used")
35
+ return {
36
+ 'user_id': 'service',
37
+ 'user': {
38
+ '_id': 'service',
39
+ 'email': 'service@system',
40
+ 'name': 'Service',
41
+ 'role': 'service',
42
+ },
43
+ 'is_service': True,
44
+ 'is_bypass': False,
45
+ 'token_data': None,
46
+ }
47
+
48
+ bypass_token = os.getenv('AUTH_BYPASS_TOKEN')
49
+ if bypass_token and token == bypass_token:
50
+ logger.info("Bypass token used - skipping validation")
51
+ return {
52
+ 'user_id': 'bypass',
53
+ 'user': {
54
+ '_id': 'bypass',
55
+ 'email': 'bypass@system',
56
+ 'name': 'Bypass User',
57
+ 'role': 'admin',
58
+ },
59
+ 'is_bypass': True,
60
+ 'token_data': None,
61
+ }
62
+
63
+ return None
64
+
65
+
16
66
  class AuthValidator(ABC):
17
67
  """
18
68
  Abstract base class for authentication validators
@@ -63,21 +113,11 @@ class TokenValidator(AuthValidator):
63
113
  UnauthorizedError: If token is invalid or expired
64
114
  """
65
115
 
66
- # 1. Check bypass token first (for development/testing)
67
- bypass_token = os.getenv('AUTH_BYPASS_TOKEN')
68
- if bypass_token and token == bypass_token:
69
- logger.info("Bypass token used - skipping DB validation")
70
- return {
71
- 'user_id': 'bypass',
72
- 'user': {
73
- 'email': 'bypass@system',
74
- 'role': 'admin',
75
- 'name': 'Bypass User',
76
- '_id': 'bypass'
77
- },
78
- 'is_bypass': True,
79
- 'token_data': None
80
- }
116
+ # 1. Quien llama puede no ser una persona: un servicio o la llave maestra.
117
+ caller = _machine_caller(token)
118
+ if caller:
119
+ return caller
120
+
81
121
 
82
122
  # 2. Get database name from environment
83
123
  db_name = os.getenv('AUTH_DB_NAME') or 'core'
@@ -183,20 +223,9 @@ class JWTValidator(AuthValidator):
183
223
  return key
184
224
 
185
225
  async def validate_token(self, token: str) -> Dict[str, Any]:
186
- bypass_token = os.getenv('AUTH_BYPASS_TOKEN')
187
- if bypass_token and token == bypass_token:
188
- logger.info("Bypass token used - skipping JWT validation")
189
- return {
190
- 'user_id': 'bypass',
191
- 'user': {
192
- 'email': 'bypass@system',
193
- 'role': 'admin',
194
- 'name': 'Bypass User',
195
- '_id': 'bypass'
196
- },
197
- 'is_bypass': True,
198
- 'token_data': None
199
- }
226
+ caller = _machine_caller(token)
227
+ if caller:
228
+ return caller
200
229
 
201
230
  try:
202
231
  import jwt
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aws-python-helper
3
- Version: 1.12.0
3
+ Version: 1.13.0
4
4
  Summary: AWS Python Helper Framework
5
5
  Author-email: Fabian Claros <neufabiae@gmail.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "aws-python-helper"
7
- version = "1.12.0"
7
+ version = "1.13.0"
8
8
  description = "AWS Python Helper Framework"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"