Skip to content

Commit 91def1e

Browse files
committed
xuy-UID2-4719 use operator-key as name
1 parent 3301aa4 commit 91def1e

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

scripts/aws/ec2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import yaml
1717

1818
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
19-
from confidential_compute import ConfidentialCompute, ConfidentialComputeConfig, MissingInstanceProfile, ApiTokenNotFound, InvalidConfigValue, ConfidentialComputeStartupException
19+
from confidential_compute import ConfidentialCompute, ConfidentialComputeConfig, MissingInstanceProfile, OperatorKeyNotFound, InvalidConfigValue, ConfidentialComputeStartupException
2020

2121
class AWSConfidentialComputeConfig(ConfidentialComputeConfig):
2222
enclave_memory_mb: int
@@ -103,7 +103,7 @@ def add_defaults(configs: Dict[str, any]) -> None:
103103
except NoCredentialsError as _:
104104
raise MissingInstanceProfile(self.__class__.__name__)
105105
except ClientError as _:
106-
raise ApiTokenNotFound(self.__class__.__name__, f"Secret Manager {secret_identifier} in {region}")
106+
raise OperatorKeyNotFound(self.__class__.__name__, f"Secret Manager {secret_identifier} in {region}")
107107

108108
@staticmethod
109109
def __get_max_capacity():

scripts/azure-cc/azureEntryPoint.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import logging
1111

1212
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
13-
from confidential_compute import ConfidentialCompute, MissingConfig, MissingInstanceProfile, AuxiliariesException, SecretAccessDenied, ApiTokenNotFound, ConfidentialComputeStartupException
13+
from confidential_compute import ConfidentialCompute, MissingConfig, MissingInstanceProfile, AuxiliariesException, OperatorKeyAccessDenied, OperatorKeyNotFound, ConfidentialComputeStartupException
1414
from azure.keyvault.secrets import SecretClient
1515
from azure.identity import DefaultAzureCredential, CredentialUnavailableError
1616
from azure.core.exceptions import ResourceNotFoundError, ClientAuthenticationError
@@ -73,30 +73,30 @@ def __set_base_urls(self):
7373
self.configs["core_base_url"] = jdata["core_attest_url"]
7474
self.configs["optout_base_url"] = jdata["optout_api_uri"]
7575

76-
def __set_api_token(self):
76+
def __set_operator_key(self):
7777
try:
7878
credential = DefaultAzureCredential()
7979
kv_URL = f"https://{AzureEntryPoint.kv_name}.vault.azure.net"
8080
secret_client = SecretClient(vault_url=kv_URL, credential=credential)
8181
secret = secret_client.get_secret(AzureEntryPoint.secret_name)
8282
# print(f"Secret Value: {secret.value}")
83-
self.configs["api_token"] = secret.value
83+
self.configs["operator_key"] = secret.value
8484

8585
except (CredentialUnavailableError, ClientAuthenticationError) as auth_error:
8686
logging.error(f"Read operator key, authentication error: {auth_error}")
87-
raise SecretAccessDenied(self.__class__.__name__, str(auth_error))
87+
raise OperatorKeyAccessDenied(self.__class__.__name__, str(auth_error))
8888
except ResourceNotFoundError as not_found_error:
8989
logging.error(f"Read operator key, secret not found: {AzureEntryPoint.secret_name}. Error: {not_found_error}")
90-
raise ApiTokenNotFound(self.__class__.__name__, str(not_found_error))
90+
raise OperatorKeyNotFound(self.__class__.__name__, str(not_found_error))
9191

9292

9393
def _set_confidential_config(self, secret_identifier: str = None):
9494
self.configs["skip_validations"] = os.getenv("SKIP_VALIDATIONS", "false").lower() == "true"
9595
self.configs["debug_mode"] = os.getenv("DEBUG_MODE", "false").lower() == "true"
9696
self.configs["environment"] = AzureEntryPoint.env_name
9797

98-
# set self.configs["api_token"]
99-
self.__set_api_token()
98+
# set self.configs["operator_key"]
99+
self.__set_operator_key()
100100
# set base urls from final config file
101101
self.__set_base_urls()
102102

scripts/confidential_compute.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import logging
99

1010
class ConfidentialComputeConfig(TypedDict):
11-
api_token: str
11+
operator_key: str
1212
core_base_url: str
1313
optout_base_url: str
1414
environment: str
@@ -29,7 +29,7 @@ class MissingInstanceProfile(ConfidentialComputeStartupException):
2929
def __init__(self, cls, message = None):
3030
super().__init__(error_name=f"E01: {self.__class__.__name__}", provider=cls, extra_message=message)
3131

32-
class ApiTokenNotFound(ConfidentialComputeStartupException):
32+
class OperatorKeyNotFound(ConfidentialComputeStartupException):
3333
def __init__(self, cls, message = None):
3434
super().__init__(error_name=f"E02: {self.__class__.__name__}", provider=cls, extra_message=message)
3535

@@ -53,7 +53,7 @@ class AuxiliariesException(ConfidentialComputeStartupException):
5353
def __init__(self, cls, inner_message = None):
5454
super().__init__(error_name=f"E07: {self.__class__.__name__}", provider=cls, extra_message=inner_message)
5555

56-
class SecretAccessDenied(ConfidentialComputeStartupException):
56+
class OperatorKeyAccessDenied(ConfidentialComputeStartupException):
5757
def __init__(self, cls, message = None):
5858
super().__init__(error_name=f"E08: {self.__class__.__name__}", provider=cls, extra_message=message)
5959

@@ -67,7 +67,7 @@ def validate_configuration(self):
6767
logging.info("Validating configurations provided")
6868
def validate_operator_key():
6969
""" Validates the operator key format and its environment alignment."""
70-
operator_key = self.configs.get("api_token")
70+
operator_key = self.configs.get("operator_key")
7171
pattern = r"^(UID2|EUID)-.\-(I|P|L)-\d+-.*$"
7272
if re.match(pattern, operator_key):
7373
env = self.configs.get("environment", "").lower()

scripts/gcp-oidc/gcp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from google.api_core.exceptions import PermissionDenied, NotFound
1111

1212
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
13-
from confidential_compute import ConfidentialCompute, ConfidentialComputeConfig, MissingConfig, ApiTokenNotFound, SecretAccessDenied, ConfidentialComputeStartupException
13+
from confidential_compute import ConfidentialCompute, ConfidentialComputeConfig, MissingConfig, OperatorKeyNotFound, OperatorKeyAccessDenied, ConfidentialComputeStartupException
1414

1515
class GCPEntryPoint(ConfidentialCompute):
1616

@@ -39,10 +39,10 @@ def _set_confidential_config(self, secret_identifier=None) -> None:
3939
response = client.access_secret_version(name=secret_version_name)
4040
secret_value = response.payload.data.decode("UTF-8")
4141
except (PermissionDenied, DefaultCredentialsError) as e:
42-
raise SecretAccessDenied(self.__class__.__name__, str(e))
42+
raise OperatorKeyAccessDenied(self.__class__.__name__, str(e))
4343
except NotFound:
44-
raise ApiTokenNotFound(self.__class__.__name__, f"Secret Manager {os.getenv("API_TOKEN_SECRET_NAME")}")
45-
self.config["api_token"] = secret_value
44+
raise OperatorKeyNotFound(self.__class__.__name__, f"Secret Manager {os.getenv("API_TOKEN_SECRET_NAME")}")
45+
self.config["operator_key"] = secret_value
4646

4747
def __populate_operator_config(self, destination):
4848
target_config = f"/app/conf/{self.configs["environment"].lower()}-config.json"

0 commit comments

Comments
 (0)