Encryptors 2.67__tar.gz → 2.69__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 (87) hide show
  1. {encryptors-2.67 → encryptors-2.69}/PKG-INFO +1 -1
  2. {encryptors-2.67 → encryptors-2.69}/setup.py +1 -1
  3. {encryptors-2.67 → encryptors-2.69}/src/Encryptors.egg-info/PKG-INFO +1 -1
  4. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Decorators/SecureResolver.py +32 -22
  5. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Helpers/AuthTokenProcessor.py +19 -3
  6. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Models/AuditContext.py +5 -4
  7. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Models/Graphql.py +4 -3
  8. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Models/Token.py +0 -2
  9. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Services/ServiceBusAuditEmitter.py +1 -0
  10. {encryptors-2.67 → encryptors-2.69}/README.md +0 -0
  11. {encryptors-2.67 → encryptors-2.69}/setup.cfg +0 -0
  12. {encryptors-2.67 → encryptors-2.69}/src/Encryptors.egg-info/SOURCES.txt +0 -0
  13. {encryptors-2.67 → encryptors-2.69}/src/Encryptors.egg-info/dependency_links.txt +0 -0
  14. {encryptors-2.67 → encryptors-2.69}/src/Encryptors.egg-info/entry_points.txt +0 -0
  15. {encryptors-2.67 → encryptors-2.69}/src/Encryptors.egg-info/requires.txt +0 -0
  16. {encryptors-2.67 → encryptors-2.69}/src/Encryptors.egg-info/top_level.txt +0 -0
  17. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Cache/Redis.py +0 -0
  18. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Cache/__init__.py +0 -0
  19. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Cli/__init__.py +0 -0
  20. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Constants/Constant.py +0 -0
  21. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Constants/Message.py +0 -0
  22. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Constants/__init__.py +0 -0
  23. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Context/__init__.py +0 -0
  24. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Database/BaseRepository.py +0 -0
  25. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Database/Connection.py +0 -0
  26. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Database/__init__.py +0 -0
  27. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Decorators/Grpc.py +0 -0
  28. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Decorators/Retry.py +0 -0
  29. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Decorators/__init__.py +0 -0
  30. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Encryptor/Aes.py +0 -0
  31. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Encryptor/Argon2.py +0 -0
  32. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Encryptor/Bcrypt.py +0 -0
  33. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Encryptor/Jwt.py +0 -0
  34. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Encryptor/Rsa.py +0 -0
  35. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Encryptor/Sha512.py +0 -0
  36. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Encryptor/__init__.py +0 -0
  37. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Enums/AuditType.py +0 -0
  38. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Enums/CipherType.py +0 -0
  39. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Enums/FileType.py +0 -0
  40. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Enums/GrahpqlOperation.py +0 -0
  41. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Enums/Profile.py +0 -0
  42. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Enums/ResultType.py +0 -0
  43. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Enums/StatusCode.py +0 -0
  44. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Enums/__init__.py +0 -0
  45. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Exception/ControlledException.py +0 -0
  46. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Exception/__init__.py +0 -0
  47. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Helpers/AuditHelper.py +0 -0
  48. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Helpers/AuditQueue.py +0 -0
  49. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Helpers/AzureClassifier.py +0 -0
  50. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Helpers/CipherHelper.py +0 -0
  51. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Helpers/GrpcConnection.py +0 -0
  52. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Helpers/JwtTokenHelper.py +0 -0
  53. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Helpers/Resilience.py +0 -0
  54. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Helpers/__init__.py +0 -0
  55. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Http/APIClient.py +0 -0
  56. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Http/__init__.py +0 -0
  57. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Messaging/AzureServiceBus.py +0 -0
  58. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Messaging/Kafka.py +0 -0
  59. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Messaging/RabbitMQ.py +0 -0
  60. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Messaging/__init__.py +0 -0
  61. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Models/ApiResponse.py +0 -0
  62. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Models/Notification.py +0 -0
  63. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Models/Response.py +0 -0
  64. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Models/TokenClaims.py +0 -0
  65. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Models/__init__.py +0 -0
  66. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Secrets/AzureKeyVaultProvider.py +0 -0
  67. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Secrets/__init__.py +0 -0
  68. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Services/JwtAuthTokenService.py +0 -0
  69. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Services/WebsocketClient.py +0 -0
  70. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Services/__init__.py +0 -0
  71. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Storage/AzureBlobStorage.py +0 -0
  72. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Storage/S3Storage.py +0 -0
  73. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Storage/__init__.py +0 -0
  74. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/CaseConverter.py +0 -0
  75. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/CodeGenerator.py +0 -0
  76. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/DataNormalizer.py +0 -0
  77. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/DataUtils.py +0 -0
  78. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/DateUtils.py +0 -0
  79. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/FileMetaData.py +0 -0
  80. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/HashValidator.py +0 -0
  81. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/Mapper.py +0 -0
  82. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/PasswordGenerator.py +0 -0
  83. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/QueryGenerator.py +0 -0
  84. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/RsaUtils.py +0 -0
  85. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/TextProcessor.py +0 -0
  86. {encryptors-2.67 → encryptors-2.69}/src/Osdental/Utils/__init__.py +0 -0
  87. {encryptors-2.67 → encryptors-2.69}/src/Osdental/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Encryptors
3
- Version: 2.67
3
+ Version: 2.69
4
4
  Summary: End-to-end algorithm library
5
5
  Author: OSDental LLC
6
6
  Author-email: support@osdental.ai
@@ -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.67",
5
+ version="2.69",
6
6
  author="OSDental LLC",
7
7
  author_email="support@osdental.ai",
8
8
  description="End-to-end algorithm library",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Encryptors
3
- Version: 2.67
3
+ Version: 2.69
4
4
  Summary: End-to-end algorithm library
5
5
  Author: OSDental LLC
6
6
  Author-email: support@osdental.ai
@@ -4,7 +4,9 @@ from typing import Callable
4
4
  from graphql import GraphQLResolveInfo
5
5
  from Osdental.Models.Response import Response
6
6
  from Osdental.Models.Graphql import BaseGraphQLContext
7
- from Osdental.Models.TokenClaims import UserTokenClaims, AccessTokenClaims
7
+ from Osdental.Models.TokenClaims import (
8
+ UserTokenClaims, AccessTokenClaims
9
+ )
8
10
  from Osdental.Models.Token import AuthToken
9
11
  from Osdental.Enums.Profile import Profile
10
12
  from Osdental.Exception.ControlledException import (
@@ -12,7 +14,8 @@ from Osdental.Exception.ControlledException import (
12
14
  )
13
15
  from Osdental.Services import IAuthTokenService
14
16
  from Osdental.Helpers.AuthTokenProcessor import (
15
- extract_bearer_token, build_auth_token, decrypt_and_parse_payload
17
+ extract_bearer_token, build_auth_token, decrypt_and_parse_payload,
18
+ get_current_user, get_current_aes_key
16
19
  )
17
20
  from Osdental.Enums.StatusCode import StatusCode
18
21
  from Osdental.Models.AuditContext import AuditContext
@@ -38,33 +41,36 @@ def resolver(public: bool = False, action=None):
38
41
  headers = request.headers
39
42
  settings = container.settings
40
43
 
44
+ access_token = headers.get("Accesstoken")
41
45
  token: type[AuthToken] | None = None
42
46
  aes_key = None
43
- claims: UserTokenClaims | AccessTokenClaims
47
+ claims: UserTokenClaims | AccessTokenClaims | None = None
48
+ audit_ctx: AuditContext | None = None
49
+ operation_type = info.operation.operation.value
44
50
 
45
51
  # ── 1. AUTENTICACIÓN ──────────────────────────────
46
52
  token_service: IAuthTokenService = container.auth_token_service
47
53
  if not public:
48
-
49
54
  user_token = extract_bearer_token(headers)
50
55
  claims = await token_service.validate_internal_access_token(
51
56
  user_token
52
57
  )
53
58
  aes_key = claims.aes_key_auth
54
59
 
55
- else:
56
-
57
- access_token = request.get("Accesstoken")
60
+ elif public and access_token:
58
61
  claims = await token_service.validate_external_access_token(
59
62
  access_token
60
63
  )
61
64
  aes_key = claims.aes_key
62
- context.access_token = claims
65
+ context.access_token = access_token
66
+ context.access_token_claims = claims
63
67
 
64
68
  # ── 2. DECRYPT DEL PAYLOAD ────────────────────────
65
69
  body = await request.json()
66
- variables = body.get("variables") or {}
67
- encrypted_payload = kwargs.get("data") or variables.get("data")
70
+ encrypted_payload = (
71
+ kwargs.get("data")
72
+ or body.get("variables", {}).get("data")
73
+ )
68
74
  decrypted_payload = None
69
75
 
70
76
  if encrypted_payload is not None:
@@ -82,7 +88,7 @@ def resolver(public: bool = False, action=None):
82
88
  claims=claims,
83
89
  headers=request.headers,
84
90
  decrypted_payload=decrypted_payload,
85
- operation_type=info.operation.operation.value
91
+ operation_type=operation_type,
86
92
  )
87
93
 
88
94
  context.token = token
@@ -97,13 +103,15 @@ def resolver(public: bool = False, action=None):
97
103
 
98
104
  # ── 5. CONTEXTO DE AUDITORÍA ──────────────
99
105
  # Lo construimos antes del resolver para que siempre exista
100
-
106
+ user = get_current_user(context)
107
+ key = get_current_aes_key(context)
101
108
  audit_ctx = AuditContext.from_request(
102
109
  request=request,
103
110
  settings=settings,
104
111
  body=body,
105
- operation_type=info.operation.operation.value,
106
- token=token,
112
+ operation_type=operation_type,
113
+ id_user=user,
114
+ decrypted_key=key,
107
115
  decrypted_payload=decrypted_payload,
108
116
  )
109
117
 
@@ -123,20 +131,22 @@ def resolver(public: bool = False, action=None):
123
131
  return result
124
132
 
125
133
  except OSDException as e:
126
- # logger.warning(f"Business error: {str(e)}")
127
- await container.audit_emitter.emit(
128
- _build_error_payload(audit_ctx, e)
129
- )
134
+ logger.warning(f"Business error: {str(e)}")
135
+ if audit_ctx:
136
+ await container.audit_emitter.emit(
137
+ _build_error_payload(audit_ctx, e)
138
+ )
130
139
  return Response(
131
140
  status=e.status_code,
132
141
  message=e.message,
133
142
  error=e.error
134
143
  )
135
144
  except Exception as e:
136
- # logger.exception(f"Unexpected error: {str(e)}")
137
- await container.audit_emitter.emit(
138
- _build_unexpected_payload(audit_ctx, e)
139
- )
145
+ logger.exception(f"Unexpected error: {str(e)}")
146
+ if audit_ctx:
147
+ await container.audit_emitter.emit(
148
+ _build_unexpected_payload(audit_ctx, e)
149
+ )
140
150
  return Response(
141
151
  status=StatusCode.INTERNAL_SERVER_ERROR,
142
152
  message="Could not process request.",
@@ -7,6 +7,7 @@ from Osdental.Encryptor.Aes import AES
7
7
  from Osdental.Models.Token import AuthToken
8
8
  from Osdental.Enums.Profile import Profile
9
9
  from Osdental.Models.TokenClaims import UserTokenClaims
10
+ from Osdental.Models.Graphql import BaseGraphQLContext
10
11
 
11
12
  def extract_bearer_token(headers: Headers) -> str:
12
13
 
@@ -56,8 +57,6 @@ def build_auth_token(
56
57
  id_external_enterprise=final_id,
57
58
  id_profile=claims.id_profile,
58
59
  id_legacy=claims.id_legacy,
59
- id_authorization="000",
60
- id_item_report="000",
61
60
  id_enterprise=claims.id_enterprise,
62
61
  user_full_name=claims.user_full_name,
63
62
  abbreviation=claims.abbreviation,
@@ -95,4 +94,21 @@ def decrypt_and_parse_payload(aes_key_auth: str, encrypted_payload: str) -> Dict
95
94
  else:
96
95
  raise ValueError("Unsupported decrypted payload type")
97
96
 
98
- return decrypted_payload
97
+ return decrypted_payload
98
+
99
+
100
+ def get_current_user(context: BaseGraphQLContext):
101
+ if context.token:
102
+ return context.token.id_user
103
+
104
+ return "00000000-0000-0000-0000-000000000000"
105
+
106
+
107
+ def get_current_aes_key(context: BaseGraphQLContext):
108
+ if context.token:
109
+ return context.token.aes_key_auth
110
+
111
+ if context.access_token_claims:
112
+ return context.access_token_claims.aes_key
113
+
114
+ return None
@@ -1,7 +1,7 @@
1
1
  from dataclasses import dataclass
2
2
  from typing import Optional, Dict, Any
3
3
  from fastapi import Request
4
- from Osdental.Models.Token import AuthToken
4
+
5
5
 
6
6
  @dataclass
7
7
  class AuditContext:
@@ -30,7 +30,8 @@ class AuditContext:
30
30
  settings,
31
31
  body: Dict,
32
32
  operation_type: str,
33
- token: AuthToken = None,
33
+ id_user: str | None,
34
+ decrypted_key: str | None,
34
35
  decrypted_payload = None,
35
36
  ) -> "AuditContext":
36
37
 
@@ -51,9 +52,9 @@ class AuditContext:
51
52
  operation_name=body.get("operationName", "UnknownOperation"),
52
53
  query=body.get("query"),
53
54
  variables=decrypted_payload,
54
- user=token.id_user if token else "00000000-0000-0000-0000-000000000000",
55
+ user=id_user if id_user else "00000000-0000-0000-0000-000000000000",
55
56
  message_log_id=request.headers.get("Idmessagelog"),
56
- decrypted_key=token.aes_key_auth if token else None,
57
+ decrypted_key=decrypted_key,
57
58
  user_ip=user_ip,
58
59
  headers=safe_headers,
59
60
  url=str(request.url),
@@ -1,5 +1,5 @@
1
1
  from dataclasses import dataclass
2
- from typing import Optional, Any
2
+ from typing import Any
3
3
  from fastapi import Request
4
4
  from Osdental.Models.Token import AuthToken
5
5
  from Osdental.Models.TokenClaims import AccessTokenClaims
@@ -8,5 +8,6 @@ from Osdental.Models.TokenClaims import AccessTokenClaims
8
8
  class BaseGraphQLContext:
9
9
  request: Request
10
10
  container: Any
11
- access_token: Optional[AccessTokenClaims] = None
12
- token: Optional[AuthToken] = None
11
+ access_token: str | None = None
12
+ access_token_claims: AccessTokenClaims | None = None
13
+ token: AuthToken | None = None
@@ -8,8 +8,6 @@ class AuthToken:
8
8
  id_external_enterprise: str
9
9
  id_profile: str
10
10
  id_legacy: str
11
- id_authorization: str
12
- id_item_report: str
13
11
  id_enterprise: str
14
12
  user_full_name: str
15
13
  abbreviation: str
@@ -14,6 +14,7 @@ class ServiceBusAuditEmitter:
14
14
  message_log_id = payload.get("idMessageLog")
15
15
  data = json.dumps(payload)
16
16
  blob_name = f"audits/{message_log_id}.text"
17
+ print(data)
17
18
  # url = await self._storage.upload(blob_name, data)
18
19
  # if not url:
19
20
  # return
File without changes
File without changes