Encryptors 2.56__tar.gz → 2.57__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.56 → encryptors-2.57}/PKG-INFO +1 -1
- {encryptors-2.56 → encryptors-2.57}/setup.py +1 -1
- {encryptors-2.56 → encryptors-2.57}/src/Encryptors.egg-info/PKG-INFO +1 -1
- {encryptors-2.56 → encryptors-2.57}/src/Encryptors.egg-info/SOURCES.txt +1 -2
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Constants/Message.py +0 -2
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Decorators/SecureResolver.py +117 -25
- encryptors-2.57/src/Osdental/Enums/ErrorSource.py +5 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Exception/ControlledException.py +26 -3
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/_Helpers/_AuditHelper.py +2 -2
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Helpers/AuditDispatcher.py +0 -2
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Helpers/_AuthTokenProcessor.py +1 -2
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Http/APIClient.py +3 -2
- encryptors-2.56/src/Osdental/Models/AuditConfig.py +0 -9
- encryptors-2.56/src/Osdental/Models/_Audit.py +0 -14
- {encryptors-2.56 → encryptors-2.57}/README.md +0 -0
- {encryptors-2.56 → encryptors-2.57}/setup.cfg +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Encryptors.egg-info/dependency_links.txt +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Encryptors.egg-info/entry_points.txt +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Encryptors.egg-info/requires.txt +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Encryptors.egg-info/top_level.txt +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Cache/Redis.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Cache/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Cli/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Constants/Constant.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Constants/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Database/BaseRepository.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Database/Connection.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Database/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Decorators/Grpc.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Decorators/Retry.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Decorators/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Encryptor/Aes.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Encryptor/Argon2.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Encryptor/Bcrypt.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Encryptor/Jwt.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Encryptor/Rsa.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Encryptor/Sha512.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Encryptor/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Enums/FileType.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Enums/GrahpqlOperation.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Enums/Profile.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Enums/StatusCode.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Enums/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Exception/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/Extensions/AuditExtension.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/Extensions/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/Models/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/_Exceptions/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/_Helpers/_ExtractAuthToken.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/_Helpers/_TenantPolicy.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/_Helpers/_TokenService.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/_Helpers/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Graphql/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Helpers/AzureClassifier.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Helpers/GrpcConnection.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Helpers/JwtTokenHelper.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Helpers/Resilience.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Helpers/ResponseDecryptor.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Helpers/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Http/_Helpers.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Http/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Messaging/AzureServiceBus.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Messaging/Kafka.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Messaging/RabbitMQ.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Messaging/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Models/ApiResponse.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Models/Notification.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Models/Response.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Models/Token.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Models/TokenClaims.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Models/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Rest/Context/RequestContext.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Rest/Context/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Rest/Middlewares/RequestContextMiddleware.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Rest/Middlewares/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Rest/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Secrets/AzureKeyVaultProvider.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Secrets/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Services/JwtAuthTokenService.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Services/WebsocketClient.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Services/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Storage/AzureBlobStorage.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Storage/S3Storage.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Storage/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/CaseConverter.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/CodeGenerator.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/DataNormalizer.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/DataUtils.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/DateUtils.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/FileMetaData.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/HashValidator.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/Mapper.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/PasswordGenerator.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/QueryGenerator.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/RsaUtils.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/TextProcessor.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/src/Osdental/Utils/__init__.py +0 -0
- {encryptors-2.56 → encryptors-2.57}/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.57",
|
|
6
6
|
author="OSDental LLC",
|
|
7
7
|
author_email="support@osdental.ai",
|
|
8
8
|
description="End-to-end algorithm library",
|
|
@@ -27,6 +27,7 @@ src/Osdental/Encryptor/Jwt.py
|
|
|
27
27
|
src/Osdental/Encryptor/Rsa.py
|
|
28
28
|
src/Osdental/Encryptor/Sha512.py
|
|
29
29
|
src/Osdental/Encryptor/__init__.py
|
|
30
|
+
src/Osdental/Enums/ErrorSource.py
|
|
30
31
|
src/Osdental/Enums/FileType.py
|
|
31
32
|
src/Osdental/Enums/GrahpqlOperation.py
|
|
32
33
|
src/Osdental/Enums/Profile.py
|
|
@@ -60,12 +61,10 @@ src/Osdental/Messaging/Kafka.py
|
|
|
60
61
|
src/Osdental/Messaging/RabbitMQ.py
|
|
61
62
|
src/Osdental/Messaging/__init__.py
|
|
62
63
|
src/Osdental/Models/ApiResponse.py
|
|
63
|
-
src/Osdental/Models/AuditConfig.py
|
|
64
64
|
src/Osdental/Models/Notification.py
|
|
65
65
|
src/Osdental/Models/Response.py
|
|
66
66
|
src/Osdental/Models/Token.py
|
|
67
67
|
src/Osdental/Models/TokenClaims.py
|
|
68
|
-
src/Osdental/Models/_Audit.py
|
|
69
68
|
src/Osdental/Models/__init__.py
|
|
70
69
|
src/Osdental/Rest/__init__.py
|
|
71
70
|
src/Osdental/Rest/Context/RequestContext.py
|
|
@@ -31,8 +31,6 @@ class Message:
|
|
|
31
31
|
UNEXPECTED_DECRYPTED_DATA_FORMAT_MSG = "Unexpected format in decrypted data."
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
DATABASE_EXECUTION_ERROR_MSG = "An unexpected error occurred while executing a database operation."
|
|
35
|
-
DATABASE_INTEGRITY_ERROR_MSG = "A database integrity constraint was violated during execution."
|
|
36
34
|
QUERY_NOT_PROVIDED_MSG = "Query not provided. Please include a valid query in your request."
|
|
37
35
|
FILE_PATH_NOT_PROVIDED_MSG = "File path not provided."
|
|
38
36
|
|
|
@@ -15,30 +15,108 @@ 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
|
|
18
|
-
from Osdental.
|
|
19
|
-
|
|
18
|
+
from Osdental.Storage import IStorageService
|
|
19
|
+
from Osdental.Messaging import IMessageQueue
|
|
20
|
+
from Osdental.Graphql._Helpers._AuditHelper import AuditHelper
|
|
21
|
+
from Osdental.Constants.Constant import Constant
|
|
22
|
+
from Osdental.Helpers.ResponseDecryptor import decryptor_data, VALID_TYPES
|
|
20
23
|
|
|
21
24
|
logger = logging.getLogger(__name__)
|
|
22
25
|
|
|
23
26
|
|
|
24
|
-
def __test(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
async def __test(
|
|
28
|
+
messaging: IMessageQueue,
|
|
29
|
+
storage: IStorageService,
|
|
27
30
|
request_payload: Dict[str, Any],
|
|
31
|
+
request,
|
|
28
32
|
result: Response,
|
|
29
|
-
decrypted_key: str
|
|
33
|
+
decrypted_key: str,
|
|
34
|
+
audit_type: str
|
|
30
35
|
) -> None:
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
|
|
37
|
+
import json
|
|
38
|
+
|
|
39
|
+
if not request_payload.get("is_auditable"):
|
|
40
|
+
logger.info("Auditing is disabled. Skipping audit processing.")
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
operation_name = request_payload.get("operation_name")
|
|
44
|
+
if operation_name == 'UnknownOperation':
|
|
45
|
+
logger.info("Skipping audit: no data in GraphQL response")
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
request_audit_payload = AuditHelper.build_request_payload(
|
|
33
49
|
request=request,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
metadata={
|
|
37
|
-
"decrypted_key": decrypted_key
|
|
38
|
-
},
|
|
39
|
-
audit_type="MESSAGE_LOG_INTERNAL"
|
|
50
|
+
payload=request_payload,
|
|
51
|
+
audit_type=audit_type
|
|
40
52
|
)
|
|
41
53
|
|
|
54
|
+
status_code = result.status
|
|
55
|
+
message = result.message
|
|
56
|
+
data = result.data
|
|
57
|
+
error = result.error if result.error else message
|
|
58
|
+
|
|
59
|
+
if audit_type == Constant.MESSAGE_LOG_INTERNAL:
|
|
60
|
+
ERROR_PREFIXES = ("ERROR", "WARNING")
|
|
61
|
+
if isinstance(status_code, int):
|
|
62
|
+
is_error = not (200 <= status_code < 300)
|
|
63
|
+
elif isinstance(status_code, str):
|
|
64
|
+
is_error = status_code.upper().startswith(ERROR_PREFIXES)
|
|
65
|
+
else:
|
|
66
|
+
try:
|
|
67
|
+
is_error = not (200 <= status_code < 300)
|
|
68
|
+
except ValueError:
|
|
69
|
+
is_error = True
|
|
70
|
+
|
|
71
|
+
if is_error:
|
|
72
|
+
err_payload = AuditHelper.build_final_payload(
|
|
73
|
+
_type="ERROR",
|
|
74
|
+
status_code=status_code,
|
|
75
|
+
error=error
|
|
76
|
+
)
|
|
77
|
+
audit_message = request_audit_payload | err_payload
|
|
78
|
+
else:
|
|
79
|
+
if isinstance(result, Response):
|
|
80
|
+
|
|
81
|
+
encryption_type = result.encryption_type
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if encryption_type in VALID_TYPES and decrypted_key and data:
|
|
85
|
+
data = decryptor_data(encryption_type, decrypted_key, data)
|
|
86
|
+
|
|
87
|
+
res_payload = AuditHelper.build_final_payload(
|
|
88
|
+
_type="RESPONSE",
|
|
89
|
+
status_code=status_code,
|
|
90
|
+
result=data
|
|
91
|
+
)
|
|
92
|
+
audit_message = request_audit_payload | res_payload
|
|
93
|
+
|
|
94
|
+
message_log_id = request.headers.get("Idmessagelog")
|
|
95
|
+
if not message_log_id:
|
|
96
|
+
logger.warning("No Idmessagelog header found. Skipping audit storage.")
|
|
97
|
+
return
|
|
98
|
+
|
|
99
|
+
data = json.dumps(audit_message)
|
|
100
|
+
# print(f"data: {data}")
|
|
101
|
+
# blob_name = f"audits/{message_log_id}.text"
|
|
102
|
+
# success = await storage.upload(blob_name, data)
|
|
103
|
+
|
|
104
|
+
# if not success:
|
|
105
|
+
# logger.error("Failed to upload audit log to storage. Skipping message dispatch.")
|
|
106
|
+
# return
|
|
107
|
+
|
|
108
|
+
# await messaging.send_message(blob_name)
|
|
109
|
+
|
|
110
|
+
# dispatcher.dispatch(
|
|
111
|
+
# request=request,
|
|
112
|
+
# request_payload=request_payload,
|
|
113
|
+
# result=result,
|
|
114
|
+
# metadata={
|
|
115
|
+
# "decrypted_key": decrypted_key
|
|
116
|
+
# },
|
|
117
|
+
# audit_type="MESSAGE_LOG_INTERNAL"
|
|
118
|
+
# )
|
|
119
|
+
|
|
42
120
|
def resolver(public: bool = False, action=None):
|
|
43
121
|
|
|
44
122
|
def decorator(func: Callable):
|
|
@@ -61,7 +139,7 @@ def resolver(public: bool = False, action=None):
|
|
|
61
139
|
token_service: IAuthTokenService = container.auth_token_service
|
|
62
140
|
user_token = extract_bearer_token(headers)
|
|
63
141
|
|
|
64
|
-
claims: UserTokenClaims = token_service.validate_internal_access_token(
|
|
142
|
+
claims: UserTokenClaims = await token_service.validate_internal_access_token(
|
|
65
143
|
user_token
|
|
66
144
|
)
|
|
67
145
|
|
|
@@ -123,31 +201,45 @@ def resolver(public: bool = False, action=None):
|
|
|
123
201
|
|
|
124
202
|
if isinstance(result, Response):
|
|
125
203
|
decrypted_key = result.key if not token else token.aes_key_auth
|
|
126
|
-
|
|
127
|
-
dispatcher = AuditDispatcher(
|
|
128
|
-
messaging=container.az_sb_audit,
|
|
129
|
-
storage=container.az_blob_storage
|
|
130
|
-
)
|
|
131
204
|
|
|
132
|
-
__test(
|
|
133
|
-
|
|
205
|
+
await __test(
|
|
206
|
+
messaging=container.az_sb_audit,
|
|
207
|
+
storage=container.az_blob_storage,
|
|
134
208
|
request_payload=request_payload,
|
|
135
209
|
request=request,
|
|
136
210
|
decrypted_key=decrypted_key,
|
|
137
|
-
result=result
|
|
211
|
+
result=result,
|
|
212
|
+
audit_type="MESSAGE_LOG_INTERNAL"
|
|
138
213
|
)
|
|
139
214
|
|
|
140
215
|
return result
|
|
141
216
|
|
|
142
217
|
except OSDException as e:
|
|
143
|
-
logger.warning(f"Business error: {str(e)}")
|
|
218
|
+
# logger.warning(f"Business error: {str(e)}")
|
|
219
|
+
if e.is_external:
|
|
220
|
+
err_payload = AuditHelper.build_final_payload(
|
|
221
|
+
_type="ERROR",
|
|
222
|
+
status_code=e.status_code,
|
|
223
|
+
error=result.error if result.error else e.message
|
|
224
|
+
)
|
|
225
|
+
else:
|
|
226
|
+
err_payload = AuditHelper.build_final_payload(
|
|
227
|
+
_type="ERROR",
|
|
228
|
+
status_code=e.audit_status_code,
|
|
229
|
+
error=result.error if result.error else e.message
|
|
230
|
+
)
|
|
144
231
|
return Response(
|
|
145
232
|
status=e.status_code,
|
|
146
233
|
message=e.message,
|
|
147
234
|
error=e.error
|
|
148
235
|
)
|
|
149
236
|
except Exception as e:
|
|
150
|
-
logger.exception(f"Unexpected error: {str(e)}")
|
|
237
|
+
# logger.exception(f"Unexpected error: {str(e)}")
|
|
238
|
+
err_payload = AuditHelper.build_final_payload(
|
|
239
|
+
_type="ERROR",
|
|
240
|
+
status_code=StatusCode.INTERNAL_SERVER_ERROR,
|
|
241
|
+
error=str(e)
|
|
242
|
+
)
|
|
151
243
|
return Response(
|
|
152
244
|
status=StatusCode.INTERNAL_SERVER_ERROR,
|
|
153
245
|
message="Could not process request.",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
from Osdental.Enums.StatusCode import StatusCode
|
|
3
3
|
from Osdental.Constants.Message import Message
|
|
4
|
+
from Osdental.Enums.ErrorSource import ErrorSource
|
|
4
5
|
|
|
5
6
|
class OSDException(Exception):
|
|
6
7
|
""" Base class for all custom exceptions. """
|
|
@@ -9,16 +10,28 @@ class OSDException(Exception):
|
|
|
9
10
|
message: str = Message.UNEXPECTED_ERROR_MSG,
|
|
10
11
|
error: str = None,
|
|
11
12
|
status_code: Any = StatusCode.INTERNAL_SERVER_ERROR,
|
|
13
|
+
source: ErrorSource = ErrorSource.INTERNAL,
|
|
14
|
+
raw_status_code: Any = None,
|
|
12
15
|
):
|
|
13
16
|
super().__init__(error)
|
|
14
17
|
self.message = message
|
|
15
18
|
self.error = error
|
|
16
19
|
self.status_code = status_code
|
|
17
|
-
|
|
20
|
+
self.source = source
|
|
21
|
+
self.raw_status_code = raw_status_code
|
|
18
22
|
|
|
19
23
|
def __str__(self):
|
|
20
24
|
error_detail = self.error if self.error else "None"
|
|
21
|
-
return f"[{self.status_code}] {self.message} | {error_detail}"
|
|
25
|
+
return f"[{self.source} | {self.status_code}] {self.message} | {error_detail}]"
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def is_external(self) -> bool:
|
|
29
|
+
return self.source == ErrorSource.EXTERNAL
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def audit_status_code(self) -> Any:
|
|
33
|
+
"""El que va a la auditoría: real si existe, propio si no."""
|
|
34
|
+
return self.raw_status_code if self.raw_status_code is not None else self.status_code
|
|
22
35
|
|
|
23
36
|
class UnauthorizedException(OSDException):
|
|
24
37
|
def __init__(
|
|
@@ -29,6 +42,8 @@ class UnauthorizedException(OSDException):
|
|
|
29
42
|
):
|
|
30
43
|
super().__init__(message=message, error=error, status_code=status_code)
|
|
31
44
|
|
|
45
|
+
|
|
46
|
+
|
|
32
47
|
class AccessDeniedException(OSDException):
|
|
33
48
|
def __init__(
|
|
34
49
|
self,
|
|
@@ -119,5 +134,13 @@ class HttpClientException(OSDException):
|
|
|
119
134
|
message: str = Message.UNEXPECTED_ERROR_MSG,
|
|
120
135
|
error: str = None,
|
|
121
136
|
status_code: str = StatusCode.INTERNAL_SERVER_ERROR,
|
|
137
|
+
source: ErrorSource = ErrorSource.EXTERNAL,
|
|
138
|
+
raw_status_code: Any = None,
|
|
122
139
|
):
|
|
123
|
-
super().__init__(
|
|
140
|
+
super().__init__(
|
|
141
|
+
message=message,
|
|
142
|
+
error=error,
|
|
143
|
+
status_code=status_code,
|
|
144
|
+
source=source,
|
|
145
|
+
raw_status_code=raw_status_code
|
|
146
|
+
)
|
|
@@ -4,10 +4,10 @@ from typing import Dict, Literal, Any, Optional
|
|
|
4
4
|
class AuditHelper:
|
|
5
5
|
|
|
6
6
|
@staticmethod
|
|
7
|
-
|
|
7
|
+
def build_request_payload(
|
|
8
8
|
request,
|
|
9
9
|
payload: Dict[str, Any],
|
|
10
|
-
audit_type
|
|
10
|
+
audit_type: str
|
|
11
11
|
) -> Dict[str, Any]:
|
|
12
12
|
|
|
13
13
|
default_value = "*"
|
|
@@ -91,8 +91,6 @@ class AuditDispatcher:
|
|
|
91
91
|
result: Response | ApiResponse = payload["result"]
|
|
92
92
|
audit_type = payload["audit_type"]
|
|
93
93
|
|
|
94
|
-
print(request_payload)
|
|
95
|
-
|
|
96
94
|
if not request_payload.get("is_auditable"):
|
|
97
95
|
logger.info("Auditing is disabled. Skipping audit processing.")
|
|
98
96
|
return
|
|
@@ -17,7 +17,6 @@ def extract_bearer_token(headers: Headers) -> str:
|
|
|
17
17
|
return authorization.removeprefix("Bearer ").strip()
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
def build_auth_token(
|
|
22
21
|
claims: UserTokenClaims,
|
|
23
22
|
headers: Headers,
|
|
@@ -31,6 +30,7 @@ def build_auth_token(
|
|
|
31
30
|
decrypted_payload.get("idExternalEnterprise")
|
|
32
31
|
if decrypted_payload else None
|
|
33
32
|
)
|
|
33
|
+
mk_id_external_enterprise = None
|
|
34
34
|
|
|
35
35
|
if external_enterprise_req:
|
|
36
36
|
final_id = external_enterprise_req
|
|
@@ -50,7 +50,6 @@ def build_auth_token(
|
|
|
50
50
|
|
|
51
51
|
final_id = str(UUID(int=0))
|
|
52
52
|
|
|
53
|
-
|
|
54
53
|
token = AuthToken(
|
|
55
54
|
id_token=claims.id_token,
|
|
56
55
|
id_user=claims.id_user,
|
|
@@ -53,7 +53,8 @@ class APIClient:
|
|
|
53
53
|
audit_http_error(exc.response, method, url, kwargs)
|
|
54
54
|
raise HttpClientException(
|
|
55
55
|
status_code=StatusCode.BAD_GATEWAY,
|
|
56
|
-
error=exc.response.text
|
|
56
|
+
error=exc.response.text,
|
|
57
|
+
raw_status_code=exc.response.status_code,
|
|
57
58
|
) from exc
|
|
58
59
|
|
|
59
60
|
except httpx.RequestError as exc:
|
|
@@ -61,7 +62,7 @@ class APIClient:
|
|
|
61
62
|
audit_exception_error(exc, method, url, kwargs)
|
|
62
63
|
raise HttpClientException(
|
|
63
64
|
status_code=StatusCode.GATEWAY_TIMEOUT,
|
|
64
|
-
error=str(exc)
|
|
65
|
+
error=str(exc),
|
|
65
66
|
) from exc
|
|
66
67
|
|
|
67
68
|
except Exception as exc:
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass, field
|
|
2
|
-
from typing import Any, Optional
|
|
3
|
-
from fastapi import Request
|
|
4
|
-
from Osdental.Models.AuditConfig import AuditConfig
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@dataclass
|
|
8
|
-
class Audit:
|
|
9
|
-
request: Request
|
|
10
|
-
audit_config: AuditConfig
|
|
11
|
-
payload: Any = field(default_factory=dict)
|
|
12
|
-
audit_type: str = field(default="MESSAGE_LOG_INTERNAL")
|
|
13
|
-
operation_name: Optional[str] = "Unknown"
|
|
14
|
-
full_name: Optional[str] = "Joe Doe"
|
|
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
|
{encryptors-2.56 → encryptors-2.57}/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
|