codecraftai-credentials 1.2.0__py3-none-any.whl
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.
- ccai/credentials/__init__.py +13 -0
- ccai/credentials/apitokencredential.py +86 -0
- ccai/credentials/awsaccesskeycredential.py +105 -0
- ccai/credentials/azureclientsecretcredential.py +116 -0
- ccai/credentials/azuremanagedidentitycredential.py +131 -0
- ccai/credentials/azureserviceprincipalcredential.py +150 -0
- ccai/credentials/basecredential.py +187 -0
- ccai/credentials/basiccredential.py +104 -0
- ccai/credentials/coreweaveapicredential.py +130 -0
- ccai/credentials/credentialmanager.py +453 -0
- ccai/credentials/crusoeapikeycredential.py +131 -0
- ccai/credentials/digitaloceanapitokencredential.py +181 -0
- ccai/credentials/equinixmetalapitokencredential.py +113 -0
- ccai/credentials/gcpserviceaccountkeycredential.py +188 -0
- ccai/credentials/gcpworkloadidentitycredential.py +173 -0
- ccai/credentials/githubappcredential.py +167 -0
- ccai/credentials/githubtokencredential.py +106 -0
- ccai/credentials/hetznerapitokencredential.py +113 -0
- ccai/credentials/lambdalabsapikeycredential.py +113 -0
- ccai/credentials/linodeapitokencredential.py +113 -0
- ccai/credentials/nebiusserviceaccountcredential.py +113 -0
- ccai/credentials/nutanixprismcredential.py +161 -0
- ccai/credentials/oraclecloudapikeycredential.py +211 -0
- ccai/credentials/personalapitokencredential.py +101 -0
- ccai/credentials/proxmoxapitokencredential.py +145 -0
- ccai/credentials/publickeycredential.py +104 -0
- ccai/credentials/py.typed +0 -0
- ccai/credentials/runpodapikeycredential.py +113 -0
- ccai/credentials/secrettokencredential.py +103 -0
- ccai/credentials/sshcredential.py +221 -0
- ccai/credentials/tailscaleauthkeycredential.py +145 -0
- ccai/credentials/tailscaleoauthcredential.py +139 -0
- ccai/credentials/twingateserviceaccountcredential.py +146 -0
- ccai/credentials/venueregistry.py +89 -0
- ccai/credentials/vspherecredential.py +178 -0
- ccai/credentials/vultrapikeycredential.py +113 -0
- ccai/credentials/wellknown.py +160 -0
- ccai/credentials/wifichoicecredential.py +107 -0
- codecraftai_credentials-1.2.0.dist-info/METADATA +88 -0
- codecraftai_credentials-1.2.0.dist-info/RECORD +42 -0
- codecraftai_credentials-1.2.0.dist-info/WHEEL +4 -0
- codecraftai_credentials-1.2.0.dist-info/licenses/LICENSE.md +204 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: tailscaleauthkeycredential
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module that contains the :class:`TailscaleAuthKeyCredential` which
|
|
5
|
+
represents a pre-minted Tailscale auth key credential.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__author__ = "Myron Walker"
|
|
11
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
12
|
+
__credits__ = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
16
|
+
|
|
17
|
+
from ccai.errors.exceptions import ConfigurationError
|
|
18
|
+
|
|
19
|
+
from ccai.credentials.basecredential import BaseCredential
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TailscaleAuthKeyCredential(BaseCredential):
|
|
23
|
+
"""
|
|
24
|
+
The :class:`TailscaleAuthKeyCredential` is a container object for a pre-minted
|
|
25
|
+
Tailscale auth key used to join nodes to a tailnet.
|
|
26
|
+
|
|
27
|
+
.. code:: yaml
|
|
28
|
+
"identifier": "ts-lab-key"
|
|
29
|
+
"category": "tailscale-authkey"
|
|
30
|
+
"authkey": "tskey-auth-XXXX-YYYY"
|
|
31
|
+
"reusable": false
|
|
32
|
+
"ephemeral": true
|
|
33
|
+
"preauthorized": true
|
|
34
|
+
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def __init__(self, *, identifier: str, categories: List[str], authkey: str,
|
|
38
|
+
reusable: bool = False, ephemeral: bool = True, preauthorized: bool = True,
|
|
39
|
+
role: Optional[str] = "priv"):
|
|
40
|
+
"""
|
|
41
|
+
Initializes a :class:`TailscaleAuthKeyCredential` instance.
|
|
42
|
+
|
|
43
|
+
:param identifier: The identifier that is used to reference this credential. (required)
|
|
44
|
+
:param categories: The categories of authentication that are supported by the credential.
|
|
45
|
+
:param authkey: The pre-minted Tailscale auth key value.
|
|
46
|
+
:param reusable: Indicates whether the key may be used to join more than one node.
|
|
47
|
+
:param ephemeral: Indicates whether nodes joined with this key are ephemeral.
|
|
48
|
+
:param preauthorized: Indicates whether nodes joined with this key are pre-authorized.
|
|
49
|
+
:param role: Identifies the role of the credential.
|
|
50
|
+
"""
|
|
51
|
+
super().__init__(identifier=identifier, categories=categories, role=role)
|
|
52
|
+
|
|
53
|
+
if "tailscale-authkey" not in categories:
|
|
54
|
+
raise ConfigurationError("The TailscaleAuthKeyCredential should only be given credentials of category 'tailscale-authkey'.")
|
|
55
|
+
if authkey is None or len(authkey) == 0:
|
|
56
|
+
raise ConfigurationError("The TailscaleAuthKeyCredential constructor requires a non-empty 'authkey' parameter be provided.")
|
|
57
|
+
|
|
58
|
+
self._authkey = authkey
|
|
59
|
+
self._reusable = reusable
|
|
60
|
+
self._ephemeral = ephemeral
|
|
61
|
+
self._preauthorized = preauthorized
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def authkey(self) -> str:
|
|
66
|
+
"""
|
|
67
|
+
Returns the Tailscale auth key string.
|
|
68
|
+
|
|
69
|
+
:returns: The auth key value.
|
|
70
|
+
"""
|
|
71
|
+
return self._authkey
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def reusable(self) -> bool:
|
|
75
|
+
"""
|
|
76
|
+
Indicates whether the auth key is reusable.
|
|
77
|
+
|
|
78
|
+
:returns: True if the key is reusable, False otherwise.
|
|
79
|
+
"""
|
|
80
|
+
return self._reusable
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def ephemeral(self) -> bool:
|
|
84
|
+
"""
|
|
85
|
+
Indicates whether nodes joined with this key are ephemeral.
|
|
86
|
+
|
|
87
|
+
:returns: True if joined nodes are ephemeral, False otherwise.
|
|
88
|
+
"""
|
|
89
|
+
return self._ephemeral
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def preauthorized(self) -> bool:
|
|
93
|
+
"""
|
|
94
|
+
Indicates whether nodes joined with this key are pre-authorized.
|
|
95
|
+
|
|
96
|
+
:returns: True if joined nodes are pre-authorized, False otherwise.
|
|
97
|
+
"""
|
|
98
|
+
return self._preauthorized
|
|
99
|
+
|
|
100
|
+
@classmethod
|
|
101
|
+
def validate(cls, cred_info: Dict[str, Any]) -> Tuple[List[str], List[str]]:
|
|
102
|
+
"""
|
|
103
|
+
Validates the dictionary describing a Tailscale auth key credential.
|
|
104
|
+
|
|
105
|
+
:param cred_info: The credential information dictionary to validate.
|
|
106
|
+
|
|
107
|
+
:returns: A tuple of lists containing errors and warnings.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
errors = []
|
|
111
|
+
warnings = []
|
|
112
|
+
|
|
113
|
+
if "authkey" not in cred_info:
|
|
114
|
+
errors.append("missing 'authkey' in tailscale-authkey credential.")
|
|
115
|
+
|
|
116
|
+
warnings.append("TailscaleAuthKeyCredential is recommended for lab use only; prefer 'TailscaleOAuthCredential' for production provisioning.")
|
|
117
|
+
|
|
118
|
+
return errors, warnings
|
|
119
|
+
|
|
120
|
+
def as_dict(self) -> Dict[str, Any]:
|
|
121
|
+
"""
|
|
122
|
+
Returns a dictionary representation of this credential object.
|
|
123
|
+
"""
|
|
124
|
+
rtnval = super().as_dict()
|
|
125
|
+
|
|
126
|
+
rtnval["authkey"] = self._authkey
|
|
127
|
+
rtnval["reusable"] = self._reusable
|
|
128
|
+
rtnval["ephemeral"] = self._ephemeral
|
|
129
|
+
rtnval["preauthorized"] = self._preauthorized
|
|
130
|
+
|
|
131
|
+
return rtnval
|
|
132
|
+
|
|
133
|
+
def __repr__(self) -> str:
|
|
134
|
+
"""
|
|
135
|
+
Returns a debug representation of this credential with the auth key redacted.
|
|
136
|
+
|
|
137
|
+
:returns: A redacted string representation safe for logs.
|
|
138
|
+
"""
|
|
139
|
+
rtnval = (
|
|
140
|
+
"TailscaleAuthKeyCredential("
|
|
141
|
+
"identifier={!r}, categories={!r}, authkey='***', "
|
|
142
|
+
"reusable={!r}, ephemeral={!r}, preauthorized={!r})"
|
|
143
|
+
).format(self._identifier, self._categories, self._reusable, self._ephemeral, self._preauthorized)
|
|
144
|
+
|
|
145
|
+
return rtnval
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: tailscaleoauthcredential
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module that contains the :class:`TailscaleOAuthCredential` which
|
|
5
|
+
represents a Tailscale OAuth client used to mint ephemeral auth keys.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__author__ = "Myron Walker"
|
|
11
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
12
|
+
__credits__ = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
16
|
+
|
|
17
|
+
from ccai.errors.exceptions import ConfigurationError
|
|
18
|
+
|
|
19
|
+
from ccai.credentials.basecredential import BaseCredential
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TailscaleOAuthCredential(BaseCredential):
|
|
23
|
+
"""
|
|
24
|
+
The :class:`TailscaleOAuthCredential` is a container object for a Tailscale
|
|
25
|
+
OAuth client used by the control plane to mint short-lived ephemeral auth keys.
|
|
26
|
+
|
|
27
|
+
.. code:: yaml
|
|
28
|
+
"identifier": "ts-prov-oauth"
|
|
29
|
+
"category": "tailscale-oauth"
|
|
30
|
+
"client_id": "ksXXXX"
|
|
31
|
+
"client_secret": "tskey-client-secret-XXXX"
|
|
32
|
+
"default_tags": ["tag:lab"]
|
|
33
|
+
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, *, identifier: str, categories: List[str], client_id: str,
|
|
37
|
+
client_secret: str, default_tags: Optional[List[str]] = None,
|
|
38
|
+
role: Optional[str] = "priv"):
|
|
39
|
+
"""
|
|
40
|
+
Initializes a :class:`TailscaleOAuthCredential` instance.
|
|
41
|
+
|
|
42
|
+
:param identifier: The identifier that is used to reference this credential. (required)
|
|
43
|
+
:param categories: The categories of authentication that are supported by the credential.
|
|
44
|
+
:param client_id: The Tailscale OAuth client identifier.
|
|
45
|
+
:param client_secret: The Tailscale OAuth client secret.
|
|
46
|
+
:param default_tags: Optional list of tags applied by default to keys minted from this client.
|
|
47
|
+
:param role: Identifies the role of the credential.
|
|
48
|
+
"""
|
|
49
|
+
super().__init__(identifier=identifier, categories=categories, role=role)
|
|
50
|
+
|
|
51
|
+
if "tailscale-oauth" not in categories:
|
|
52
|
+
raise ConfigurationError("The TailscaleOAuthCredential should only be given credentials of category 'tailscale-oauth'.")
|
|
53
|
+
if client_id is None or len(client_id) == 0:
|
|
54
|
+
raise ConfigurationError("The TailscaleOAuthCredential constructor requires a non-empty 'client_id' parameter be provided.")
|
|
55
|
+
if client_secret is None or len(client_secret) == 0:
|
|
56
|
+
raise ConfigurationError("The TailscaleOAuthCredential constructor requires a non-empty 'client_secret' parameter be provided.")
|
|
57
|
+
|
|
58
|
+
tags = default_tags
|
|
59
|
+
if tags is None:
|
|
60
|
+
tags = []
|
|
61
|
+
|
|
62
|
+
self._client_id = client_id
|
|
63
|
+
self._client_secret = client_secret
|
|
64
|
+
self._default_tags = tags
|
|
65
|
+
return
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def client_id(self) -> str:
|
|
69
|
+
"""
|
|
70
|
+
Returns the Tailscale OAuth client identifier.
|
|
71
|
+
|
|
72
|
+
:returns: The OAuth client id string.
|
|
73
|
+
"""
|
|
74
|
+
return self._client_id
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def client_secret(self) -> str:
|
|
78
|
+
"""
|
|
79
|
+
Returns the Tailscale OAuth client secret.
|
|
80
|
+
|
|
81
|
+
:returns: The OAuth client secret string.
|
|
82
|
+
"""
|
|
83
|
+
return self._client_secret
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def default_tags(self) -> List[str]:
|
|
87
|
+
"""
|
|
88
|
+
Returns the default tag list applied to keys minted from this client.
|
|
89
|
+
|
|
90
|
+
:returns: The list of default tag strings.
|
|
91
|
+
"""
|
|
92
|
+
return self._default_tags
|
|
93
|
+
|
|
94
|
+
@classmethod
|
|
95
|
+
def validate(cls, cred_info: Dict[str, Any]) -> Tuple[List[str], List[str]]:
|
|
96
|
+
"""
|
|
97
|
+
Validates the dictionary describing a Tailscale OAuth credential.
|
|
98
|
+
|
|
99
|
+
:param cred_info: The credential information dictionary to validate.
|
|
100
|
+
|
|
101
|
+
:returns: A tuple of lists containing errors and warnings.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
errors = []
|
|
105
|
+
warnings = []
|
|
106
|
+
|
|
107
|
+
if "client_id" not in cred_info:
|
|
108
|
+
errors.append("missing 'client_id' in tailscale-oauth credential.")
|
|
109
|
+
|
|
110
|
+
if "client_secret" not in cred_info:
|
|
111
|
+
errors.append("missing 'client_secret' in tailscale-oauth credential.")
|
|
112
|
+
|
|
113
|
+
return errors, warnings
|
|
114
|
+
|
|
115
|
+
def as_dict(self) -> Dict[str, Any]:
|
|
116
|
+
"""
|
|
117
|
+
Returns a dictionary representation of this credential object.
|
|
118
|
+
"""
|
|
119
|
+
rtnval = super().as_dict()
|
|
120
|
+
|
|
121
|
+
rtnval["client_id"] = self._client_id
|
|
122
|
+
rtnval["client_secret"] = self._client_secret
|
|
123
|
+
rtnval["default_tags"] = self._default_tags
|
|
124
|
+
|
|
125
|
+
return rtnval
|
|
126
|
+
|
|
127
|
+
def __repr__(self) -> str:
|
|
128
|
+
"""
|
|
129
|
+
Returns a debug representation of this credential with the client secret redacted.
|
|
130
|
+
|
|
131
|
+
:returns: A redacted string representation safe for logs.
|
|
132
|
+
"""
|
|
133
|
+
rtnval = (
|
|
134
|
+
"TailscaleOAuthCredential("
|
|
135
|
+
"identifier={!r}, categories={!r}, client_id={!r}, "
|
|
136
|
+
"client_secret='***', default_tags={!r})"
|
|
137
|
+
).format(self._identifier, self._categories, self._client_id, self._default_tags)
|
|
138
|
+
|
|
139
|
+
return rtnval
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: twingateserviceaccountcredential
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module that contains the :class:`TwingateServiceAccountCredential` which
|
|
5
|
+
represents a Twingate service-account API token and network slug pair.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__author__ = "Myron Walker"
|
|
11
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
12
|
+
__credits__ = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
16
|
+
|
|
17
|
+
from ccai.errors.exceptions import ConfigurationError
|
|
18
|
+
|
|
19
|
+
from ccai.credentials.basecredential import BaseCredential
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TwingateServiceAccountCredential(BaseCredential):
|
|
23
|
+
"""
|
|
24
|
+
The :class:`TwingateServiceAccountCredential` is a container object for a
|
|
25
|
+
Twingate service-account API token plus the network slug used to address the
|
|
26
|
+
Twingate GraphQL control plane.
|
|
27
|
+
|
|
28
|
+
.. code:: yaml
|
|
29
|
+
"identifier": "tg-prod"
|
|
30
|
+
"category": "twingate-service-account"
|
|
31
|
+
"api_token": "tg-svc-XXXX"
|
|
32
|
+
"network_slug": "acme"
|
|
33
|
+
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, *, identifier: str, categories: List[str], api_token: str,
|
|
37
|
+
network_slug: str, role: Optional[str] = "priv"):
|
|
38
|
+
"""
|
|
39
|
+
Initializes a :class:`TwingateServiceAccountCredential` instance.
|
|
40
|
+
|
|
41
|
+
:param identifier: The identifier that is used to reference this credential. (required)
|
|
42
|
+
:param categories: The categories of authentication that are supported by the credential.
|
|
43
|
+
:param api_token: The Twingate service-account API token value.
|
|
44
|
+
:param network_slug: The Twingate network slug (hostname-shaped, no whitespace).
|
|
45
|
+
:param role: Identifies the role of the credential.
|
|
46
|
+
"""
|
|
47
|
+
super().__init__(identifier=identifier, categories=categories, role=role)
|
|
48
|
+
|
|
49
|
+
if "twingate-service-account" not in categories:
|
|
50
|
+
raise ConfigurationError("The TwingateServiceAccountCredential should only be given credentials of category 'twingate-service-account'.")
|
|
51
|
+
if api_token is None or len(api_token) == 0:
|
|
52
|
+
raise ConfigurationError("The TwingateServiceAccountCredential constructor requires a non-empty 'api_token' parameter be provided.")
|
|
53
|
+
if network_slug is None or len(network_slug) == 0:
|
|
54
|
+
raise ConfigurationError("The TwingateServiceAccountCredential constructor requires a non-empty 'network_slug' parameter be provided.")
|
|
55
|
+
|
|
56
|
+
has_whitespace = False
|
|
57
|
+
for ch in network_slug:
|
|
58
|
+
if ch.isspace():
|
|
59
|
+
has_whitespace = True
|
|
60
|
+
break
|
|
61
|
+
|
|
62
|
+
if has_whitespace:
|
|
63
|
+
raise ConfigurationError("The TwingateServiceAccountCredential 'network_slug' must contain no whitespace.")
|
|
64
|
+
|
|
65
|
+
self._api_token = api_token
|
|
66
|
+
self._network_slug = network_slug
|
|
67
|
+
return
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def api_token(self) -> str:
|
|
71
|
+
"""
|
|
72
|
+
Returns the Twingate API token string.
|
|
73
|
+
|
|
74
|
+
:returns: The API token value.
|
|
75
|
+
"""
|
|
76
|
+
return self._api_token
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def network_slug(self) -> str:
|
|
80
|
+
"""
|
|
81
|
+
Returns the Twingate network slug.
|
|
82
|
+
|
|
83
|
+
:returns: The network slug string.
|
|
84
|
+
"""
|
|
85
|
+
return self._network_slug
|
|
86
|
+
|
|
87
|
+
@classmethod
|
|
88
|
+
def validate(cls, cred_info: Dict[str, Any]) -> Tuple[List[str], List[str]]:
|
|
89
|
+
"""
|
|
90
|
+
Validates the dictionary describing a Twingate service-account credential.
|
|
91
|
+
|
|
92
|
+
:param cred_info: The credential information dictionary to validate.
|
|
93
|
+
|
|
94
|
+
:returns: A tuple of lists containing errors and warnings.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
errors = []
|
|
98
|
+
warnings = []
|
|
99
|
+
|
|
100
|
+
if "api_token" not in cred_info:
|
|
101
|
+
errors.append("missing 'api_token' in twingate-service-account credential.")
|
|
102
|
+
else:
|
|
103
|
+
api_token = cred_info["api_token"]
|
|
104
|
+
if api_token is None or len(api_token) == 0:
|
|
105
|
+
errors.append("empty 'api_token' in twingate-service-account credential.")
|
|
106
|
+
|
|
107
|
+
if "network_slug" not in cred_info:
|
|
108
|
+
errors.append("missing 'network_slug' in twingate-service-account credential.")
|
|
109
|
+
else:
|
|
110
|
+
network_slug = cred_info["network_slug"]
|
|
111
|
+
if network_slug is None or len(network_slug) == 0:
|
|
112
|
+
errors.append("empty 'network_slug' in twingate-service-account credential.")
|
|
113
|
+
else:
|
|
114
|
+
has_whitespace = False
|
|
115
|
+
for ch in network_slug:
|
|
116
|
+
if ch.isspace():
|
|
117
|
+
has_whitespace = True
|
|
118
|
+
break
|
|
119
|
+
if has_whitespace:
|
|
120
|
+
errors.append("'network_slug' in twingate-service-account credential must contain no whitespace.")
|
|
121
|
+
|
|
122
|
+
return errors, warnings
|
|
123
|
+
|
|
124
|
+
def as_dict(self) -> Dict[str, Any]:
|
|
125
|
+
"""
|
|
126
|
+
Returns a dictionary representation of this credential object.
|
|
127
|
+
"""
|
|
128
|
+
rtnval = super().as_dict()
|
|
129
|
+
|
|
130
|
+
rtnval["api_token"] = self._api_token
|
|
131
|
+
rtnval["network_slug"] = self._network_slug
|
|
132
|
+
|
|
133
|
+
return rtnval
|
|
134
|
+
|
|
135
|
+
def __repr__(self) -> str:
|
|
136
|
+
"""
|
|
137
|
+
Returns a debug representation of this credential with the API token redacted.
|
|
138
|
+
|
|
139
|
+
:returns: A redacted string representation safe for logs.
|
|
140
|
+
"""
|
|
141
|
+
rtnval = (
|
|
142
|
+
"TwingateServiceAccountCredential("
|
|
143
|
+
"identifier={!r}, categories={!r}, api_token='***', network_slug={!r})"
|
|
144
|
+
).format(self._identifier, self._categories, self._network_slug)
|
|
145
|
+
|
|
146
|
+
return rtnval
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: venueregistry
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Registry that maps a venue credential ``provider`` discriminator to
|
|
5
|
+
its concrete credential class.
|
|
6
|
+
|
|
7
|
+
The venue umbrella categories (``cloud-venue`` / ``vm-venue`` / ``hpc-venue``)
|
|
8
|
+
are shared by many providers whose credential payloads can be structurally
|
|
9
|
+
identical (for example DigitalOcean, Hetzner, Linode and Vultr all serialize
|
|
10
|
+
as ``{category: cloud-venue, token: ...}``). A credential definition therefore
|
|
11
|
+
carries an explicit ``provider`` field so the :class:`CredentialManager` can
|
|
12
|
+
dispatch to the correct concrete class.
|
|
13
|
+
|
|
14
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
__author__ = "Myron Walker"
|
|
18
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
19
|
+
__credits__ = []
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
from typing import Dict, Type
|
|
23
|
+
|
|
24
|
+
from ccai.credentials.basecredential import BaseCredential
|
|
25
|
+
|
|
26
|
+
from ccai.credentials.azuremanagedidentitycredential import AzureManagedIdentityCredential
|
|
27
|
+
from ccai.credentials.azureserviceprincipalcredential import AzureServicePrincipalCredential
|
|
28
|
+
from ccai.credentials.coreweaveapicredential import CoreweaveApiCredential
|
|
29
|
+
from ccai.credentials.crusoeapikeycredential import CrusoeApiKeyCredential
|
|
30
|
+
from ccai.credentials.digitaloceanapitokencredential import DigitalOceanApiTokenCredential
|
|
31
|
+
from ccai.credentials.equinixmetalapitokencredential import EquinixMetalApiTokenCredential
|
|
32
|
+
from ccai.credentials.gcpserviceaccountkeycredential import GcpServiceAccountKeyCredential
|
|
33
|
+
from ccai.credentials.gcpworkloadidentitycredential import GcpWorkloadIdentityCredential
|
|
34
|
+
from ccai.credentials.hetznerapitokencredential import HetznerApiTokenCredential
|
|
35
|
+
from ccai.credentials.lambdalabsapikeycredential import LambdalabsApiKeyCredential
|
|
36
|
+
from ccai.credentials.linodeapitokencredential import LinodeApiTokenCredential
|
|
37
|
+
from ccai.credentials.nebiusserviceaccountcredential import NebiusServiceAccountCredential
|
|
38
|
+
from ccai.credentials.nutanixprismcredential import NutanixPrismCredential
|
|
39
|
+
from ccai.credentials.oraclecloudapikeycredential import OracleCloudApiKeyCredential
|
|
40
|
+
from ccai.credentials.proxmoxapitokencredential import ProxmoxApiTokenCredential
|
|
41
|
+
from ccai.credentials.runpodapikeycredential import RunpodApiKeyCredential
|
|
42
|
+
from ccai.credentials.vspherecredential import VSphereCredential
|
|
43
|
+
from ccai.credentials.vultrapikeycredential import VultrApiKeyCredential
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
CATEGORY_CLOUD_VENUE = "cloud-venue"
|
|
47
|
+
CATEGORY_VM_VENUE = "vm-venue"
|
|
48
|
+
CATEGORY_HPC_VENUE = "hpc-venue"
|
|
49
|
+
|
|
50
|
+
VENUE_UMBRELLA_CATEGORIES = {
|
|
51
|
+
CATEGORY_CLOUD_VENUE,
|
|
52
|
+
CATEGORY_VM_VENUE,
|
|
53
|
+
CATEGORY_HPC_VENUE,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Maps the ``provider`` discriminator carried by a venue credential definition to
|
|
58
|
+
# the concrete credential class that should be constructed for it.
|
|
59
|
+
VENUE_PROVIDER_REGISTRY: Dict[str, Type[BaseCredential]] = {
|
|
60
|
+
"azure-managed-identity": AzureManagedIdentityCredential,
|
|
61
|
+
"azure-service-principal": AzureServicePrincipalCredential,
|
|
62
|
+
"coreweave": CoreweaveApiCredential,
|
|
63
|
+
"crusoe": CrusoeApiKeyCredential,
|
|
64
|
+
"digitalocean": DigitalOceanApiTokenCredential,
|
|
65
|
+
"equinix-metal": EquinixMetalApiTokenCredential,
|
|
66
|
+
"gcp-service-account": GcpServiceAccountKeyCredential,
|
|
67
|
+
"gcp-workload-identity": GcpWorkloadIdentityCredential,
|
|
68
|
+
"hetzner": HetznerApiTokenCredential,
|
|
69
|
+
"lambdalabs": LambdalabsApiKeyCredential,
|
|
70
|
+
"linode": LinodeApiTokenCredential,
|
|
71
|
+
"nebius": NebiusServiceAccountCredential,
|
|
72
|
+
"nutanix-prism": NutanixPrismCredential,
|
|
73
|
+
"oracle-cloud": OracleCloudApiKeyCredential,
|
|
74
|
+
"proxmox": ProxmoxApiTokenCredential,
|
|
75
|
+
"runpod": RunpodApiKeyCredential,
|
|
76
|
+
"vsphere": VSphereCredential,
|
|
77
|
+
"vultr": VultrApiKeyCredential,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def known_providers() -> str:
|
|
82
|
+
"""
|
|
83
|
+
Returns a sorted, comma-joined list of the registered venue provider names,
|
|
84
|
+
for use in error messages.
|
|
85
|
+
|
|
86
|
+
:returns: The known provider discriminators as a display string.
|
|
87
|
+
"""
|
|
88
|
+
rtnval = ", ".join(sorted(VENUE_PROVIDER_REGISTRY.keys()))
|
|
89
|
+
return rtnval
|