Skip to content

Commit a09939b

Browse files
committed
feat:Add support for CyberArk to external vault configuration
1 parent 134eceb commit a09939b

File tree

2 files changed

+81
-4
lines changed

2 files changed

+81
-4
lines changed

dynatrace/api/v2/credentials/vault/settings/externalvault/config.go

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,23 @@ type Config struct {
3838
RoleID *string `json:"roleId,omitempty"`
3939
SecretID *string `json:"secretId,omitempty"` // The ID of Credentials within the Certificate Vault holding the secret id
4040
VaultNameSpace *string `json:"vaultNamespace,omitempty"`
41-
// HashicorpCertificateConfig
41+
42+
// HashicorpCertificateConfig, CyberarkVaultUsernamePassword and CyberarkVaultAllowedLocationConfig
4243
Certificate *string `json:"certificate,omitempty"` // The ID of Credentials within the Certificate Vault holding the certificate
44+
4345
// AzureClientSecret
4446
TenantID *string `json:"tenantId,omitempty"` // Tenant (directory) ID of Azure application in Azure Active Directory which has permission to access secrets in Azure Key Vault
4547
ClientID *string `json:"clientId,omitempty"` // Client (application) ID of Azure application in Azure Active Directory which has permission to access secrets in Azure Key Vault
4648
ClientSecret *string `json:"clientSecret,omitempty"` // Client secret generated for Azure application in Azure Active Directory used for proving identity when requesting a token used later for accessing secrets in Azure Key Vault
49+
50+
//CyberarkVaultUsernamePassword
51+
UsernamePasswordForCPM *string `json:"usernamePasswordForCPM,omitempty"` // No documentation available
52+
53+
// CyberarkVaultAllowedLocationConfig and CyberarkVaultUsernamePassword
54+
ApplicationID *string `json:"applicationId,omitempty"`
55+
SafeName *string `json:"safeName,omitempty"`
56+
FolderName *string `json:"folderName,omitempty"`
57+
AccountName *string `json:"accountName,omitempty"`
4758
}
4859

4960
func (me *Config) Schema() map[string]*schema.Schema {
@@ -114,6 +125,31 @@ func (me *Config) Schema() map[string]*schema.Schema {
114125
Elem: &schema.Schema{Type: schema.TypeString},
115126
Optional: true,
116127
},
128+
"username_password_for_cpm": {
129+
Type: schema.TypeString,
130+
Description: "No documentation available",
131+
Optional: true,
132+
},
133+
"application_id": {
134+
Type: schema.TypeString,
135+
Description: "No documentation available",
136+
Optional: true,
137+
},
138+
"safe_name": {
139+
Type: schema.TypeString,
140+
Description: "No documentation available",
141+
Optional: true,
142+
},
143+
"folder_name": {
144+
Type: schema.TypeString,
145+
Description: "No documentation available",
146+
Optional: true,
147+
},
148+
"account_name": {
149+
Type: schema.TypeString,
150+
Description: "No documentation available",
151+
Optional: true,
152+
},
117153
}
118154
}
119155

@@ -162,6 +198,22 @@ func (me *Config) MarshalHCL(properties hcl.Properties) error {
162198
// return err
163199
// }
164200

201+
if err := properties.Encode("username_password_for_cpm", me.UsernamePasswordForCPM); err != nil {
202+
return err
203+
}
204+
if err := properties.Encode("application_id", me.ApplicationID); err != nil {
205+
return err
206+
}
207+
if err := properties.Encode("safe_name", me.SafeName); err != nil {
208+
return err
209+
}
210+
if err := properties.Encode("folder_name", me.FolderName); err != nil {
211+
return err
212+
}
213+
if err := properties.Encode("account_name", me.AccountName); err != nil {
214+
return err
215+
}
216+
165217
return nil
166218
}
167219

@@ -202,6 +254,23 @@ func (me *Config) UnmarshalHCL(decoder hcl.Decoder) error {
202254
if value, ok := decoder.GetOk("token_secret_name"); ok {
203255
me.TokenSecretName = opt.NewString(value.(string))
204256
}
257+
258+
if value, ok := decoder.GetOk("username_password_for_cpm"); ok {
259+
me.UsernamePasswordForCPM = opt.NewString(value.(string))
260+
}
261+
if value, ok := decoder.GetOk("application_id"); ok {
262+
me.ApplicationID = opt.NewString(value.(string))
263+
}
264+
if value, ok := decoder.GetOk("safe_name"); ok {
265+
me.SafeName = opt.NewString(value.(string))
266+
}
267+
if value, ok := decoder.GetOk("folder_name"); ok {
268+
me.FolderName = opt.NewString(value.(string))
269+
}
270+
if value, ok := decoder.GetOk("account_name"); ok {
271+
me.AccountName = opt.NewString(value.(string))
272+
}
273+
205274
// removed because this seems to get automatically assumed by the REST API
206275
//
207276
// if value, ok := decoder.GetOk("credentials_used_for_external_synchronization"); ok {
@@ -216,6 +285,10 @@ func (me *Config) UnmarshalHCL(decoder hcl.Decoder) error {
216285
me.SourceAuthMethod = SourceAuthMethods.HashicorpVaultAppRole
217286
} else if me.Certificate != nil {
218287
me.SourceAuthMethod = SourceAuthMethods.HashicorpVaultCertificate
288+
} else if me.UsernamePasswordForCPM != nil {
289+
me.SourceAuthMethod = SourceAuthMethods.CyberarkVaultUsernamePassword
290+
} else if me.ApplicationID != nil || me.SafeName != nil || me.FolderName != nil || me.AccountName != nil {
291+
me.SourceAuthMethod = SourceAuthMethods.CyberarkVaultAllowedLocationConfig
219292
}
220293
return nil
221294
}

dynatrace/api/v2/credentials/vault/settings/externalvault/enums.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ package externalvault
2020
type SourceAuthMethod string
2121

2222
var SourceAuthMethods = struct {
23-
AzureKeyVaultClientSecret SourceAuthMethod
24-
HashicorpVaultAppRole SourceAuthMethod
25-
HashicorpVaultCertificate SourceAuthMethod
23+
AzureKeyVaultClientSecret SourceAuthMethod
24+
HashicorpVaultAppRole SourceAuthMethod
25+
HashicorpVaultCertificate SourceAuthMethod
26+
CyberarkVaultUsernamePassword SourceAuthMethod
27+
CyberarkVaultAllowedLocationConfig SourceAuthMethod
2628
}{
2729
SourceAuthMethod("AZURE_KEY_VAULT_CLIENT_SECRET"),
2830
SourceAuthMethod("HASHICORP_VAULT_APPROLE"),
2931
SourceAuthMethod("HASHICORP_VAULT_CERTIFICATE"),
32+
SourceAuthMethod("CYBERARK_VAULT_USERNAME_PASSWORD"),
33+
SourceAuthMethod("CYBERARK_VAULT_ALLOWED_LOCATION_CONFIG"),
3034
}

0 commit comments

Comments
 (0)