Encryptors 2.43__tar.gz → 2.44__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.
- {encryptors-2.43 → encryptors-2.44}/PKG-INFO +1 -1
- {encryptors-2.43 → encryptors-2.44}/setup.py +1 -1
- {encryptors-2.43 → encryptors-2.44}/src/Encryptors.egg-info/PKG-INFO +1 -1
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Decorators/SecureResolver.py +7 -9
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/Extensions/AuditExtension.py +26 -35
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/_Helpers/_AuditHelper.py +1 -1
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Helpers/AuditDispatcher.py +1 -1
- {encryptors-2.43 → encryptors-2.44}/README.md +0 -0
- {encryptors-2.43 → encryptors-2.44}/setup.cfg +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Encryptors.egg-info/SOURCES.txt +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Encryptors.egg-info/dependency_links.txt +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Encryptors.egg-info/entry_points.txt +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Encryptors.egg-info/requires.txt +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Encryptors.egg-info/top_level.txt +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Cli/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Database/BaseRepository.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Database/Connection.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Database/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Decorators/Grpc.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Decorators/PublicResolver.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Decorators/Retry.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Decorators/SqlDataNormalizer.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Decorators/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Encryptor/Aes.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Encryptor/Argon2.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Encryptor/Bcrypt.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Encryptor/Jwt.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Encryptor/Rsa.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Encryptor/Sha512.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Encryptor/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Exception/ControlledException.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Exception/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/Extensions/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/Models/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/_Exceptions/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/_Helpers/_ExtractAuthToken.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/_Helpers/_TenantPolicy.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/_Helpers/_TokenService.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/_Helpers/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Graphql/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Helpers/KeyVaultService.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Helpers/ResponseDecryptor.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Helpers/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Http/APIClient.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Http/_Exceptions.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Http/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Messaging/AzureServiceBus.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Messaging/Kafka.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Messaging/RabbitMQ.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Messaging/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Models/AuditConfig.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Models/Response.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Models/Token.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Models/_Audit.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Models/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/RedisCache/Redis.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/RedisCache/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Rest/Context/RequestContext.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Rest/Context/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Rest/Middlewares/RequestContextMiddleware.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Rest/Middlewares/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Rest/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Enums/Code.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Enums/Constant.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Enums/FileType.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Enums/GrahpqlOperation.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Enums/Message.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Enums/Profile.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Enums/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Logger.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/CaseConverter.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/CodeGenerator.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/DataNormalizer.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/DataUtils.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/DateUtils.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/FileMetaData.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/HashValidator.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/Mapper.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/PasswordGenerator.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/QueryGenerator.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/RsaUtils.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/TextProcessor.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/Utils/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Shared/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Storage/AzureBlobStorage.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Storage/S3Storage.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/Storage/__init__.py +0 -0
- {encryptors-2.43 → encryptors-2.44}/src/Osdental/__init__.py +0 -0
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
# ANDERSON ESTO YA SE SUBIO Y ESTA ESTABLE, AUN TE QUEDA PENDIENTE LA AUDITORIA CON RSA Y AES DE ACCESSTOKEN
|
|
3
3
|
setup(
|
|
4
4
|
name="Encryptors",
|
|
5
|
-
version="2.
|
|
5
|
+
version="2.44",
|
|
6
6
|
author="OSDental LLC",
|
|
7
7
|
author_email="support@osdental.ai",
|
|
8
8
|
description="End-to-end algorithm library",
|
|
@@ -2,27 +2,27 @@ from functools import wraps
|
|
|
2
2
|
from typing import Callable
|
|
3
3
|
from Osdental.Models.Response import Response
|
|
4
4
|
from Osdental.Shared.Enums.Profile import Profile
|
|
5
|
-
from Osdental.Exception.ControlledException import OSDException, AccessDeniedException
|
|
5
|
+
from Osdental.Exception.ControlledException import OSDException, AccessDeniedException, UnauthorizedException
|
|
6
6
|
from Osdental.Shared.Logger import logger
|
|
7
7
|
|
|
8
8
|
def resolver(public: bool = False, action=None):
|
|
9
9
|
|
|
10
10
|
def decorator(func: Callable):
|
|
11
11
|
|
|
12
|
+
func._is_public = public
|
|
13
|
+
|
|
12
14
|
@wraps(func)
|
|
13
15
|
async def wrapper(obj, info, **kwargs):
|
|
14
16
|
try:
|
|
15
17
|
context = info.context
|
|
16
18
|
token = getattr(context, "token", None)
|
|
17
19
|
|
|
18
|
-
# 🔐 AUTH
|
|
19
20
|
if not public:
|
|
20
21
|
if not token:
|
|
21
|
-
raise
|
|
22
|
+
raise UnauthorizedException(
|
|
22
23
|
error="Authorization required"
|
|
23
24
|
)
|
|
24
25
|
|
|
25
|
-
# 🎯 AUTHORIZATION (roles)
|
|
26
26
|
if action:
|
|
27
27
|
if Profile(token.abbreviation) not in action.allowed_roles:
|
|
28
28
|
raise AccessDeniedException(
|
|
@@ -42,8 +42,8 @@ def resolver(public: bool = False, action=None):
|
|
|
42
42
|
return Response(
|
|
43
43
|
status=e.status_code,
|
|
44
44
|
message=e.message,
|
|
45
|
-
error=
|
|
46
|
-
)
|
|
45
|
+
error=e.error
|
|
46
|
+
)
|
|
47
47
|
|
|
48
48
|
except Exception as e:
|
|
49
49
|
logger.exception(f"Unexpected error: {str(e)}")
|
|
@@ -52,9 +52,7 @@ def resolver(public: bool = False, action=None):
|
|
|
52
52
|
status="DB_ERROR_UNEXPECTED",
|
|
53
53
|
message="Could not process request.",
|
|
54
54
|
error=str(e)
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
wrapper._is_public = public
|
|
55
|
+
)
|
|
58
56
|
|
|
59
57
|
return wrapper
|
|
60
58
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import inspect
|
|
1
2
|
import json
|
|
2
3
|
from graphql.pyutils import is_awaitable
|
|
3
4
|
from ariadne.types import Extension
|
|
@@ -39,7 +40,6 @@ class AuditExtension(Extension):
|
|
|
39
40
|
|
|
40
41
|
# cache body
|
|
41
42
|
context._cached_body = getattr(context, "_cached_body", None) or await request.json()
|
|
42
|
-
|
|
43
43
|
body = context._cached_body
|
|
44
44
|
|
|
45
45
|
# skip introspection
|
|
@@ -55,7 +55,7 @@ class AuditExtension(Extension):
|
|
|
55
55
|
if is_root:
|
|
56
56
|
|
|
57
57
|
# identificar resolver público
|
|
58
|
-
resolver_fn =
|
|
58
|
+
resolver_fn = inspect.unwrap(next_)
|
|
59
59
|
is_public = getattr(resolver_fn, "_is_public", False)
|
|
60
60
|
|
|
61
61
|
# inicializar auth UNA SOLA VEZ
|
|
@@ -66,27 +66,20 @@ class AuditExtension(Extension):
|
|
|
66
66
|
container = context.container
|
|
67
67
|
token_service = container.token_service
|
|
68
68
|
|
|
69
|
-
aes_auth = request.app.state.aes_auth
|
|
70
|
-
aes_user = request.app.state.aes_user
|
|
71
|
-
|
|
72
|
-
if not aes_auth or not aes_user:
|
|
73
|
-
aes_auth = None
|
|
74
|
-
aes_user = None
|
|
75
|
-
|
|
76
69
|
original_token = None
|
|
70
|
+
context.aes_auth = None
|
|
77
71
|
if not is_public and headers.get("authorization"):
|
|
72
|
+
aes_auth = request.app.state.aes_auth
|
|
73
|
+
aes_user = request.app.state.aes_user
|
|
74
|
+
|
|
78
75
|
try:
|
|
79
76
|
original_token = await token_service.authenticate(headers, aes_user)
|
|
80
77
|
except Exception:
|
|
81
78
|
original_token = None
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
context.token = original_token
|
|
85
|
-
context.aes_auth = aes_auth
|
|
80
|
+
context.aes_auth = aes_auth
|
|
86
81
|
|
|
87
82
|
# VALIDACIÓN SOLO ROOT
|
|
88
|
-
original_token = getattr(context, "_original_token", None)
|
|
89
|
-
|
|
90
83
|
if not is_public and not original_token:
|
|
91
84
|
raise ValueError("Authorization required")
|
|
92
85
|
|
|
@@ -100,30 +93,30 @@ class AuditExtension(Extension):
|
|
|
100
93
|
|
|
101
94
|
decrypted_payload = None
|
|
102
95
|
|
|
103
|
-
if encrypted_payload is not None:
|
|
104
|
-
if isinstance(encrypted_payload, dict):
|
|
105
|
-
decrypted_payload = encrypted_payload
|
|
96
|
+
if not is_public and encrypted_payload is not None:
|
|
106
97
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
pass
|
|
118
|
-
except Exception:
|
|
119
|
-
decrypted_payload = None
|
|
98
|
+
if not isinstance(encrypted_payload, str):
|
|
99
|
+
raise ValueError("Encrypted payload must be a string")
|
|
100
|
+
|
|
101
|
+
if not context.aes_auth:
|
|
102
|
+
raise ValueError("Missing AES configuration")
|
|
103
|
+
|
|
104
|
+
try:
|
|
105
|
+
decrypted = AES.decrypt(context.aes_auth, encrypted_payload)
|
|
106
|
+
except Exception:
|
|
107
|
+
raise ValueError("Invalid encrypted payload")
|
|
120
108
|
|
|
109
|
+
try:
|
|
110
|
+
decrypted_payload = json.loads(decrypted)
|
|
111
|
+
except Exception:
|
|
112
|
+
raise ValueError("Decrypted payload is not valid JSON")
|
|
113
|
+
|
|
121
114
|
if decrypted_payload is not None:
|
|
122
115
|
kwargs["data"] = decrypted_payload
|
|
123
116
|
|
|
124
117
|
if not is_public:
|
|
125
118
|
token = TenantPolicy.resolve(
|
|
126
|
-
token=
|
|
119
|
+
token=original_token,
|
|
127
120
|
headers=request.headers,
|
|
128
121
|
decrypted_payload=decrypted_payload,
|
|
129
122
|
operation_type=info.operation.operation.value
|
|
@@ -171,12 +164,10 @@ class AuditExtension(Extension):
|
|
|
171
164
|
if self.result is None:
|
|
172
165
|
return
|
|
173
166
|
|
|
174
|
-
decrypted_key =
|
|
167
|
+
decrypted_key = context.aes_auth
|
|
175
168
|
|
|
176
169
|
if isinstance(self.result, Response):
|
|
177
|
-
decrypted_key = self.result.key or
|
|
178
|
-
else:
|
|
179
|
-
decrypted_key = context.aes_auth
|
|
170
|
+
decrypted_key = self.result.key or decrypted_key
|
|
180
171
|
|
|
181
172
|
dispatcher = context.request.app.state.audit_dispatcher
|
|
182
173
|
|
|
@@ -103,7 +103,7 @@ class AuditDispatcher:
|
|
|
103
103
|
|
|
104
104
|
# Obtencion de campos adicionales cuando es otro tipo de encriptacion o clave
|
|
105
105
|
encryption_type = result.encryption_type
|
|
106
|
-
decrypted_key = metadata
|
|
106
|
+
decrypted_key = metadata.get("decrypted_key")
|
|
107
107
|
|
|
108
108
|
if audit_type == Constant.MESSAGE_LOG_INTERNAL:
|
|
109
109
|
|
|
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
|
|
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
|
{encryptors-2.43 → encryptors-2.44}/src/Osdental/Rest/Middlewares/RequestContextMiddleware.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
|
|
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
|