Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyoaev/credential/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)
from .materializer import CredentialCleanupError, MaterializedCredential, materialize
from .resolved import (
ApiTokenSecret,
AwsAccessKeySecret,
AwsAssumeRoleSecret,
AzureManagedIdentitySecret,
Expand All @@ -39,6 +40,7 @@ def build_single_referenced_credential_element(provider_name: str):


__all__ = [
"ApiTokenSecret",
"AwsAccessKeySecret",
"AwsAssumeRoleSecret",
"AwsSourceIdentityType",
Expand Down
10 changes: 10 additions & 0 deletions pyoaev/credential/resolved.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
SecretType.AZURE_MANAGED_IDENTITY: CredentialType.CLOUD_AZURE,
SecretType.GCP_SERVICE_ACCOUNT: CredentialType.CLOUD_GCP,
SecretType.GCP_OAUTH2: CredentialType.CLOUD_GCP,
SecretType.API_TOKEN: CredentialType.API,
}


Expand Down Expand Up @@ -207,6 +208,13 @@ class GcpOAuth2Secret(ResolvedSecret):
gcp_custom_oauth_access_token: Optional[str] = _secret(default=None)


@dataclass(frozen=True)
class ApiTokenSecret(ResolvedSecret):
secret_type: ClassVar[SecretType] = SecretType.API_TOKEN

api_token: str = _secret()


_RESOLVED_SECRET_CLASSES: Dict[SecretType, Type[ResolvedSecret]] = {
cls.secret_type: cls
for cls in (
Expand All @@ -218,6 +226,7 @@ class GcpOAuth2Secret(ResolvedSecret):
AzureManagedIdentitySecret,
GcpServiceAccountSecret,
GcpOAuth2Secret,
ApiTokenSecret,
)
}

Expand Down Expand Up @@ -308,6 +317,7 @@ def ensure_compatible(


__all__ = [
"ApiTokenSecret",
"AwsAccessKeySecret",
"AwsAssumeRoleSecret",
"AzureManagedIdentitySecret",
Expand Down
2 changes: 2 additions & 0 deletions pyoaev/credential/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CredentialType(str, Enum):
CLOUD_AWS = "CLOUD_AWS"
CLOUD_AZURE = "CLOUD_AZURE"
CLOUD_GCP = "CLOUD_GCP"
API = "API"


class SecretType(str, Enum):
Expand All @@ -27,6 +28,7 @@ class SecretType(str, Enum):
AZURE_MANAGED_IDENTITY = "AZURE_MANAGED_IDENTITY"
GCP_SERVICE_ACCOUNT = "GCP_SERVICE_ACCOUNT"
GCP_OAUTH2 = "GCP_OAUTH2"
API_TOKEN = "API_TOKEN"


class AwsSourceIdentityType(str, Enum):
Expand Down
5 changes: 5 additions & 0 deletions test/credential/test_credential_resolved.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
"gcp_oauth_client_secret": SECRET,
"gcp_oauth_refresh_token": SECRET,
},
SecretType.API_TOKEN: {
"api_token": SECRET,
},
}

EXPECTED_CREDENTIAL_TYPES = {
Expand All @@ -105,6 +108,7 @@
SecretType.AZURE_MANAGED_IDENTITY: CredentialType.CLOUD_AZURE,
SecretType.GCP_SERVICE_ACCOUNT: CredentialType.CLOUD_GCP,
SecretType.GCP_OAUTH2: CredentialType.CLOUD_GCP,
SecretType.API_TOKEN: CredentialType.API,
}


Expand All @@ -129,6 +133,7 @@ def test_secret_type_mirrors_platform_labels(self):
"AZURE_MANAGED_IDENTITY",
"GCP_SERVICE_ACCOUNT",
"GCP_OAUTH2",
"API_TOKEN",
],
)

Expand Down
1 change: 1 addition & 0 deletions test/credential/test_credential_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_every_value_matches_the_supported_platform_labels(self):
"CLOUD_AWS",
"CLOUD_AZURE",
"CLOUD_GCP",
"API",
}
actual_labels = {member.value for member in CredentialType}
self.assertEqual(actual_labels, expected_labels)
Expand Down
Loading