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.
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/PKG-INFO +1 -1
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/auth_validators.py +58 -29
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/PKG-INFO +1 -1
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/pyproject.toml +1 -1
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/README.md +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/auth_middleware.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/base.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/dispatcher.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/exceptions.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/fetcher.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/handler.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/context/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/context/session.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/context/state_validator.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/database_proxy.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/external_database_proxy.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/external_mongo_manager.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/mongo_manager.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/executor.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/fetcher.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/handler.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/task_base.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/api_client.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/exceptions.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/lambda_invoker.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/base.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/fetcher.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/handler.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_index_sync/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_index_sync/base.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_query/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_query/base.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/monitoring/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/monitoring/run.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/permissions/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/permissions/catalog.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/repository/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/repository/audit.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/repository/base.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sns/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sns/publisher.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sqs/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sqs/consumer_base.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sqs/fetcher.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sqs/handler.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/utils/__init__.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/utils/json_encoder.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/utils/response.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/utils/serializer.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/SOURCES.txt +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/dependency_links.txt +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/requires.txt +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/top_level.txt +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/setup.cfg +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/tests/test_audit_stamp.py +0 -0
- {aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/tests/test_sns_publisher.py +0 -0
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/auth_validators.py
RENAMED
|
@@ -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.
|
|
67
|
-
|
|
68
|
-
if
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
187
|
-
if
|
|
188
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/api/auth_middleware.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/context/state_validator.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/__init__.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/database_proxy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/database/mongo_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/fargate/task_base.py
RENAMED
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/api_client.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/exceptions.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/invoker/lambda_invoker.py
RENAMED
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/base.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/fetcher.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/lambda_standalone/handler.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_index_sync/__init__.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_index_sync/base.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/model_query/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/monitoring/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/permissions/__init__.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/permissions/catalog.py
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/repository/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/sqs/consumer_base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper/utils/json_encoder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/requires.txt
RENAMED
|
File without changes
|
{aws_python_helper-1.12.0 → aws_python_helper-1.13.0}/aws_python_helper.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|