Encryptors 2.59__tar.gz → 2.61__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.59 → encryptors-2.61}/PKG-INFO +1 -1
- {encryptors-2.59 → encryptors-2.61}/setup.py +1 -1
- {encryptors-2.59 → encryptors-2.61}/src/Encryptors.egg-info/PKG-INFO +1 -1
- {encryptors-2.59 → encryptors-2.61}/src/Encryptors.egg-info/SOURCES.txt +2 -1
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Decorators/SecureResolver.py +1 -1
- encryptors-2.61/src/Osdental/Helpers/AuditQueue.py +45 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Http/APIClient.py +14 -12
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Services/ServiceBusAuditEmitter.py +6 -2
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Services/__init__.py +1 -1
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Storage/__init__.py +2 -2
- {encryptors-2.59 → encryptors-2.61}/README.md +0 -0
- {encryptors-2.59 → encryptors-2.61}/setup.cfg +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Encryptors.egg-info/dependency_links.txt +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Encryptors.egg-info/entry_points.txt +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Encryptors.egg-info/requires.txt +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Encryptors.egg-info/top_level.txt +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Cache/Redis.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Cache/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Cli/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Constants/Constant.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Constants/Message.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Constants/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Context/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Database/BaseRepository.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Database/Connection.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Database/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Decorators/Grpc.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Decorators/Retry.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Decorators/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Encryptor/Aes.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Encryptor/Argon2.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Encryptor/Bcrypt.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Encryptor/Jwt.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Encryptor/Rsa.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Encryptor/Sha512.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Encryptor/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Enums/AuditType.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Enums/ErrorSource.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Enums/FileType.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Enums/GrahpqlOperation.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Enums/Profile.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Enums/ResultType.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Enums/StatusCode.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Enums/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Exception/ControlledException.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Exception/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Helpers/AuditHelper.py +0 -0
- /encryptors-2.59/src/Osdental/Helpers/_AuthTokenProcessor.py → /encryptors-2.61/src/Osdental/Helpers/AuthTokenProcessor.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Helpers/AzureClassifier.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Helpers/GrpcConnection.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Helpers/JwtTokenHelper.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Helpers/Resilience.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Helpers/ResponseDecryptor.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Helpers/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Http/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Messaging/AzureServiceBus.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Messaging/Kafka.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Messaging/RabbitMQ.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Messaging/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Models/ApiResponse.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Models/AuditContext.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Models/Graphql.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Models/Notification.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Models/Response.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Models/Token.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Models/TokenClaims.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Models/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Secrets/AzureKeyVaultProvider.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Secrets/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Services/JwtAuthTokenService.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Services/WebsocketClient.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Storage/AzureBlobStorage.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Storage/S3Storage.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/CaseConverter.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/CodeGenerator.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/DataNormalizer.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/DataUtils.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/DateUtils.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/FileMetaData.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/HashValidator.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/Mapper.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/PasswordGenerator.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/QueryGenerator.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/RsaUtils.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/TextProcessor.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/Utils/__init__.py +0 -0
- {encryptors-2.59 → encryptors-2.61}/src/Osdental/__init__.py +0 -0
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
# ANDERSON REVISAR EL CACHE LOCAL DEL KEYVAULT PARA VALIDAR SI FUNCIONA
|
|
3
3
|
setup(
|
|
4
4
|
name="Encryptors",
|
|
5
|
-
version="2.
|
|
5
|
+
version="2.61",
|
|
6
6
|
author="OSDental LLC",
|
|
7
7
|
author_email="support@osdental.ai",
|
|
8
8
|
description="End-to-end algorithm library",
|
|
@@ -39,12 +39,13 @@ src/Osdental/Enums/__init__.py
|
|
|
39
39
|
src/Osdental/Exception/ControlledException.py
|
|
40
40
|
src/Osdental/Exception/__init__.py
|
|
41
41
|
src/Osdental/Helpers/AuditHelper.py
|
|
42
|
+
src/Osdental/Helpers/AuditQueue.py
|
|
43
|
+
src/Osdental/Helpers/AuthTokenProcessor.py
|
|
42
44
|
src/Osdental/Helpers/AzureClassifier.py
|
|
43
45
|
src/Osdental/Helpers/GrpcConnection.py
|
|
44
46
|
src/Osdental/Helpers/JwtTokenHelper.py
|
|
45
47
|
src/Osdental/Helpers/Resilience.py
|
|
46
48
|
src/Osdental/Helpers/ResponseDecryptor.py
|
|
47
|
-
src/Osdental/Helpers/_AuthTokenProcessor.py
|
|
48
49
|
src/Osdental/Helpers/__init__.py
|
|
49
50
|
src/Osdental/Http/APIClient.py
|
|
50
51
|
src/Osdental/Http/__init__.py
|
|
@@ -11,7 +11,7 @@ from Osdental.Exception.ControlledException import (
|
|
|
11
11
|
OSDException, AccessDeniedException
|
|
12
12
|
)
|
|
13
13
|
from Osdental.Services import IAuthTokenService
|
|
14
|
-
from Osdental.Helpers.
|
|
14
|
+
from Osdental.Helpers.AuthTokenProcessor import (
|
|
15
15
|
extract_bearer_token, build_auth_token, decrypt_and_parse_payload
|
|
16
16
|
)
|
|
17
17
|
from Osdental.Enums.StatusCode import StatusCode
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
logger = logging.getLogger(__name__)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AuditQueue:
|
|
8
|
+
|
|
9
|
+
def __init__(
|
|
10
|
+
self,
|
|
11
|
+
worker,
|
|
12
|
+
maxsize: int = 1000,
|
|
13
|
+
workers: int = 5
|
|
14
|
+
):
|
|
15
|
+
self._worker = worker
|
|
16
|
+
self._queue = asyncio.Queue(maxsize=maxsize)
|
|
17
|
+
self._workers = workers
|
|
18
|
+
self._tasks: list[asyncio.Task] = []
|
|
19
|
+
|
|
20
|
+
async def emit(self, payload):
|
|
21
|
+
await self._queue.put(payload)
|
|
22
|
+
|
|
23
|
+
def start(self):
|
|
24
|
+
for _ in range(self._workers):
|
|
25
|
+
task = asyncio.create_task(self._consume())
|
|
26
|
+
self._tasks.append(task)
|
|
27
|
+
|
|
28
|
+
async def _consume(self):
|
|
29
|
+
while True:
|
|
30
|
+
payload = await self._queue.get()
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
await self._worker(payload)
|
|
34
|
+
|
|
35
|
+
except Exception:
|
|
36
|
+
logger.exception("Error processing audit")
|
|
37
|
+
|
|
38
|
+
finally:
|
|
39
|
+
self._queue.task_done()
|
|
40
|
+
|
|
41
|
+
async def stop(self):
|
|
42
|
+
await self._queue.join()
|
|
43
|
+
|
|
44
|
+
for task in self._tasks:
|
|
45
|
+
task.cancel()
|
|
@@ -20,11 +20,11 @@ class APIClient:
|
|
|
20
20
|
|
|
21
21
|
def __init__(
|
|
22
22
|
self,
|
|
23
|
-
|
|
23
|
+
audit_emit: Optional[IAuditEmitter] = None,
|
|
24
24
|
timeout: Optional[httpx.Timeout] = None,
|
|
25
25
|
limits: Optional[httpx.Limits] = None
|
|
26
26
|
):
|
|
27
|
-
self.
|
|
27
|
+
self._audit_emit = audit_emit
|
|
28
28
|
|
|
29
29
|
self._client = httpx.AsyncClient(
|
|
30
30
|
follow_redirects=True,
|
|
@@ -41,6 +41,9 @@ class APIClient:
|
|
|
41
41
|
@rest_retry
|
|
42
42
|
async def _request(self, method: HTTPMethod, url: str, **kwargs) -> httpx.Response:
|
|
43
43
|
|
|
44
|
+
audit_ctx = _ctx.get()
|
|
45
|
+
audit_ctx.headers = kwargs.get("headers") or {}
|
|
46
|
+
|
|
44
47
|
try:
|
|
45
48
|
|
|
46
49
|
response = await self._client.request(
|
|
@@ -49,10 +52,6 @@ class APIClient:
|
|
|
49
52
|
**kwargs
|
|
50
53
|
)
|
|
51
54
|
|
|
52
|
-
audit_ctx = _ctx.get()
|
|
53
|
-
|
|
54
|
-
audit_ctx.headers = kwargs["headers"] or {}
|
|
55
|
-
|
|
56
55
|
response.raise_for_status()
|
|
57
56
|
|
|
58
57
|
api_res = ApiResponse(
|
|
@@ -125,6 +124,9 @@ class APIClient:
|
|
|
125
124
|
headers: Optional[Dict[str, str]] = None
|
|
126
125
|
) -> Dict[str, Any]:
|
|
127
126
|
|
|
127
|
+
audit_ctx = _ctx.get()
|
|
128
|
+
audit_ctx.headers = headers or {}
|
|
129
|
+
|
|
128
130
|
payload = {
|
|
129
131
|
"query": query,
|
|
130
132
|
"variables": variables
|
|
@@ -139,11 +141,9 @@ class APIClient:
|
|
|
139
141
|
|
|
140
142
|
data = response.json()
|
|
141
143
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
_build_success_graphql_payload(audit_ctx, data)
|
|
144
|
+
await self._audit_emit.emit(
|
|
145
|
+
_build_success_graphql_payload(audit_ctx, data)
|
|
146
|
+
)
|
|
147
147
|
|
|
148
148
|
if "errors" in data:
|
|
149
149
|
|
|
@@ -152,7 +152,9 @@ class APIClient:
|
|
|
152
152
|
f"GraphQL error: {errors}"
|
|
153
153
|
)
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
await self._audit_emit.emit(
|
|
156
|
+
_build_error_graphql_payload(audit_ctx, errors)
|
|
157
|
+
)
|
|
156
158
|
raise HttpClientException(
|
|
157
159
|
message="GraphQL execution failed",
|
|
158
160
|
error=str(data["errors"])
|
|
@@ -8,10 +8,14 @@ class ServiceBusAuditEmitter:
|
|
|
8
8
|
def __init__(self, messaging: IMessageQueue, storage: IStorageService):
|
|
9
9
|
self._messaging = messaging
|
|
10
10
|
self._storage = storage
|
|
11
|
+
|
|
11
12
|
|
|
12
|
-
async def
|
|
13
|
+
async def process(self, payload: Dict[str, Any]) -> None:
|
|
13
14
|
message_log_id = payload.get("idMessageLog")
|
|
14
15
|
data = json.dumps(payload)
|
|
15
16
|
blob_name = f"audits/{message_log_id}.text"
|
|
16
|
-
await self._storage.upload(blob_name, data)
|
|
17
|
+
url = await self._storage.upload(blob_name, data)
|
|
18
|
+
if not url:
|
|
19
|
+
return
|
|
20
|
+
|
|
17
21
|
await self._messaging.send_message(blob_name)
|
|
@@ -6,13 +6,13 @@ from azure.storage.blob import BlobSasPermissions
|
|
|
6
6
|
class IStorageService(ABC):
|
|
7
7
|
|
|
8
8
|
@abstractmethod
|
|
9
|
-
async def upload(self, blob_name: str, data: bytes | str) -> str
|
|
9
|
+
async def upload(self, blob_name: str, data: bytes | str) -> str:
|
|
10
10
|
""" Upload a file to blob storage """
|
|
11
11
|
pass
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
@abstractmethod
|
|
15
|
-
async def download(self, blob_name: str) -> bytes
|
|
15
|
+
async def download(self, blob_name: str) -> bytes:
|
|
16
16
|
""" Download a file from blob storage """
|
|
17
17
|
pass
|
|
18
18
|
|
|
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
|
|
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
|