@@ -36,6 +36,7 @@ import (
3636 "github.com/getsops/sops/v3/gcpkms"
3737 "github.com/getsops/sops/v3/hckms"
3838 "github.com/getsops/sops/v3/hcvault"
39+ "github.com/getsops/sops/v3/stackitkms"
3940 "github.com/getsops/sops/v3/keys"
4041 "github.com/getsops/sops/v3/keyservice"
4142 "github.com/getsops/sops/v3/kms"
@@ -91,14 +92,14 @@ func main() {
9192 },
9293 }
9394 app .Name = "sops"
94- app .Usage = "sops - encrypted file editor with AWS KMS, GCP KMS, HuaweiCloud KMS, Azure Key Vault, age, and GPG support"
95+ app .Usage = "sops - encrypted file editor with AWS KMS, GCP KMS, HuaweiCloud KMS, STACKIT KMS, Azure Key Vault, age, and GPG support"
9596 app .ArgsUsage = "sops [options] file"
9697 app .Version = version .Version
9798 app .Authors = []cli.Author {
9899 {Name : "CNCF Maintainers" },
99100 }
100- app .UsageText = `sops is an editor of encrypted files that supports AWS KMS, GCP, HuaweiCloud KMS, AZKV ,
101- PGP, and Age
101+ app .UsageText = `sops is an editor of encrypted files that supports AWS KMS, GCP, HuaweiCloud KMS, STACKIT KMS ,
102+ AZKV, PGP, and Age
102103
103104 To encrypt or decrypt a document with AWS KMS, specify the KMS ARN
104105 in the -k flag or in the SOPS_KMS_ARN environment variable.
@@ -117,6 +118,12 @@ func main() {
117118 HUAWEICLOUD_SDK_AK, HUAWEICLOUD_SDK_SK, HUAWEICLOUD_SDK_PROJECT_ID, or
118119 use credentials file at ~/.huaweicloud/credentials)
119120
121+ To encrypt or decrypt a document with STACKIT KMS, specify the
122+ STACKIT KMS resource ID in the --stackit-kms flag or in the
123+ SOPS_STACKIT_KMS_IDS environment variable.
124+ (Authentication is handled by the STACKIT SDK via environment variables,
125+ service account key files, or credentials file at ~/.stackit/credentials.json)
126+
120127 To encrypt or decrypt a document with HashiCorp Vault's Transit Secret
121128 Engine, specify the Vault key URI name in the --hc-vault-transit flag
122129 or in the SOPS_VAULT_URIS environment variable (for example
@@ -142,12 +149,12 @@ func main() {
142149 To use multiple KMS or PGP keys, separate them by commas. For example:
143150 $ sops -p "10F2...0A, 85D...B3F21" file.yaml
144151
145- The -p, -k, --gcp-kms, --hckms, --hc-vault-transit, and --azure-kv flags are only
152+ The -p, -k, --gcp-kms, --hckms, --stackit-kms, -- hc-vault-transit, and --azure-kv flags are only
146153 used to encrypt new documents. Editing or decrypting existing documents
147154 can be done with "sops file" or "sops decrypt file" respectively. The KMS and
148155 PGP keys listed in the encrypted documents are used then. To manage master
149- keys in existing documents, use the "add-{kms,pgp,gcp-kms,hckms,azure-kv,hc-vault-transit}"
150- and "rm-{kms,pgp,gcp-kms,hckms,azure-kv,hc-vault-transit}" flags with --rotate
156+ keys in existing documents, use the "add-{kms,pgp,gcp-kms,hckms,stackit-kms, azure-kv,hc-vault-transit}"
157+ and "rm-{kms,pgp,gcp-kms,hckms,stackit-kms, azure-kv,hc-vault-transit}" flags with --rotate
151158 or the updatekeys command.
152159
153160 To use a different GPG binary than the one in your PATH, set SOPS_GPG_EXEC.
@@ -582,6 +589,10 @@ func main() {
582589 Name : "hckms" ,
583590 Usage : "the HuaweiCloud KMS key ID (format: region:key-uuid) the new group should contain. Can be specified more than once" ,
584591 },
592+ cli.StringSliceFlag {
593+ Name : "stackit-kms" ,
594+ Usage : "the STACKIT KMS resource ID the new group should contain. Can be specified more than once" ,
595+ },
585596 cli.StringSliceFlag {
586597 Name : "azure-kv" ,
587598 Usage : "the Azure Key Vault key URL the new group should contain. Can be specified more than once" ,
@@ -635,6 +646,15 @@ func main() {
635646 }
636647 group = append (group , k )
637648 }
649+ stackitKmsIds := c .StringSlice ("stackit-kms" )
650+ for _ , resID := range stackitKmsIds {
651+ k , err := stackitkms .NewMasterKey (resID )
652+ if err != nil {
653+ log .WithError (err ).Error ("Failed to add key" )
654+ continue
655+ }
656+ group = append (group , k )
657+ }
638658 for _ , url := range azkvs {
639659 k , err := azkv .NewMasterKeyFromURL (url )
640660 if err != nil {
@@ -950,6 +970,11 @@ func main() {
950970 Usage : "comma separated list of HuaweiCloud KMS key IDs (format: region:key-uuid)" ,
951971 EnvVar : "SOPS_HUAWEICLOUD_KMS_IDS" ,
952972 },
973+ cli.StringFlag {
974+ Name : "stackit-kms" ,
975+ Usage : "comma separated list of STACKIT KMS resource IDs" ,
976+ EnvVar : "SOPS_STACKIT_KMS_IDS" ,
977+ },
953978 cli.StringFlag {
954979 Name : "azure-kv" ,
955980 Usage : "comma separated list of Azure Key Vault URLs" ,
@@ -1143,6 +1168,14 @@ func main() {
11431168 Name : "rm-hckms" ,
11441169 Usage : "remove the provided comma-separated list of HuaweiCloud KMS key IDs (format: region:key-uuid) from the list of master keys on the given file" ,
11451170 },
1171+ cli.StringFlag {
1172+ Name : "add-stackit-kms" ,
1173+ Usage : "add the provided comma-separated list of STACKIT KMS resource IDs to the list of master keys on the given file" ,
1174+ },
1175+ cli.StringFlag {
1176+ Name : "rm-stackit-kms" ,
1177+ Usage : "remove the provided comma-separated list of STACKIT KMS resource IDs from the list of master keys on the given file" ,
1178+ },
11461179 cli.StringFlag {
11471180 Name : "add-azure-kv" ,
11481181 Usage : "add the provided comma-separated list of Azure Key Vault key URLs to the list of master keys on the given file" ,
@@ -1209,8 +1242,8 @@ func main() {
12091242 return toExitError (err )
12101243 }
12111244 if _ , err := os .Stat (fileName ); os .IsNotExist (err ) {
1212- if c .String ("add-kms" ) != "" || c .String ("add-pgp" ) != "" || c .String ("add-gcp-kms" ) != "" || c .String ("add-hckms" ) != "" || c .String ("add-hc-vault-transit" ) != "" || c .String ("add-azure-kv" ) != "" || c .String ("add-age" ) != "" ||
1213- c .String ("rm-kms" ) != "" || c .String ("rm-pgp" ) != "" || c .String ("rm-gcp-kms" ) != "" || c .String ("rm-hckms" ) != "" || c .String ("rm-hc-vault-transit" ) != "" || c .String ("rm-azure-kv" ) != "" || c .String ("rm-age" ) != "" {
1245+ if c .String ("add-kms" ) != "" || c .String ("add-pgp" ) != "" || c .String ("add-gcp-kms" ) != "" || c .String ("add-hckms" ) != "" || c .String ("add-stackit-kms" ) != "" || c . String ( "add- hc-vault-transit" ) != "" || c .String ("add-azure-kv" ) != "" || c .String ("add-age" ) != "" ||
1246+ c .String ("rm-kms" ) != "" || c .String ("rm-pgp" ) != "" || c .String ("rm-gcp-kms" ) != "" || c .String ("rm-hckms" ) != "" || c .String ("rm-stackit-kms" ) != "" || c . String ( "rm- hc-vault-transit" ) != "" || c .String ("rm-azure-kv" ) != "" || c .String ("rm-age" ) != "" {
12141247 return common .NewExitError (fmt .Sprintf ("Error: cannot add or remove keys on non-existent file %q, use the `edit` subcommand instead." , fileName ), codes .CannotChangeKeysFromNonExistentFile )
12151248 }
12161249 }
@@ -1301,6 +1334,11 @@ func main() {
13011334 Usage : "comma separated list of HuaweiCloud KMS key IDs (format: region:key-uuid)" ,
13021335 EnvVar : "SOPS_HUAWEICLOUD_KMS_IDS" ,
13031336 },
1337+ cli.StringFlag {
1338+ Name : "stackit-kms" ,
1339+ Usage : "comma separated list of STACKIT KMS resource IDs" ,
1340+ EnvVar : "SOPS_STACKIT_KMS_IDS" ,
1341+ },
13041342 cli.StringFlag {
13051343 Name : "azure-kv" ,
13061344 Usage : "comma separated list of Azure Key Vault URLs" ,
@@ -1714,6 +1752,11 @@ func main() {
17141752 Usage : "comma separated list of HuaweiCloud KMS key IDs (format: region:key-uuid)" ,
17151753 EnvVar : "SOPS_HUAWEICLOUD_KMS_IDS" ,
17161754 },
1755+ cli.StringFlag {
1756+ Name : "stackit-kms" ,
1757+ Usage : "comma separated list of STACKIT KMS resource IDs" ,
1758+ EnvVar : "SOPS_STACKIT_KMS_IDS" ,
1759+ },
17171760 cli.StringFlag {
17181761 Name : "azure-kv" ,
17191762 Usage : "comma separated list of Azure Key Vault URLs" ,
@@ -1770,6 +1813,14 @@ func main() {
17701813 Name : "rm-hckms" ,
17711814 Usage : "remove the provided comma-separated list of HuaweiCloud KMS key IDs (format: region:key-uuid) from the list of master keys on the given file" ,
17721815 },
1816+ cli.StringFlag {
1817+ Name : "add-stackit-kms" ,
1818+ Usage : "add the provided comma-separated list of STACKIT KMS resource IDs to the list of master keys on the given file" ,
1819+ },
1820+ cli.StringFlag {
1821+ Name : "rm-stackit-kms" ,
1822+ Usage : "remove the provided comma-separated list of STACKIT KMS resource IDs from the list of master keys on the given file" ,
1823+ },
17731824 cli.StringFlag {
17741825 Name : "add-azure-kv" ,
17751826 Usage : "add the provided comma-separated list of Azure Key Vault key URLs to the list of master keys on the given file" ,
@@ -2235,7 +2286,7 @@ func getEncryptConfig(c *cli.Context, fileName string, inputStore common.Store,
22352286 }, nil
22362287}
22372288
2238- func getMasterKeys (c * cli.Context , kmsEncryptionContext map [string ]* string , kmsOptionName string , pgpOptionName string , gcpKmsOptionName string , hckmsOptionName string , azureKvOptionName string , hcVaultTransitOptionName string , ageOptionName string ) ([]keys.MasterKey , error ) {
2289+ func getMasterKeys (c * cli.Context , kmsEncryptionContext map [string ]* string , kmsOptionName string , pgpOptionName string , gcpKmsOptionName string , hckmsOptionName string , stackitKmsOptionName string , azureKvOptionName string , hcVaultTransitOptionName string , ageOptionName string ) ([]keys.MasterKey , error ) {
22392290 var masterKeys []keys.MasterKey
22402291 for _ , k := range kms .MasterKeysFromArnString (c .String (kmsOptionName ), kmsEncryptionContext , c .String ("aws-profile" )) {
22412292 masterKeys = append (masterKeys , k )
@@ -2253,6 +2304,13 @@ func getMasterKeys(c *cli.Context, kmsEncryptionContext map[string]*string, kmsO
22532304 for _ , k := range hckmsKeys {
22542305 masterKeys = append (masterKeys , k )
22552306 }
2307+ stackitKmsKeys , err := stackitkms .NewMasterKeyFromResourceIDString (c .String (stackitKmsOptionName ))
2308+ if err != nil {
2309+ return nil , err
2310+ }
2311+ for _ , k := range stackitKmsKeys {
2312+ masterKeys = append (masterKeys , k )
2313+ }
22562314 azureKeys , err := azkv .MasterKeysFromURLs (c .String (azureKvOptionName ))
22572315 if err != nil {
22582316 return nil , err
@@ -2279,11 +2337,11 @@ func getMasterKeys(c *cli.Context, kmsEncryptionContext map[string]*string, kmsO
22792337
22802338func getRotateOpts (c * cli.Context , fileName string , inputStore common.Store , outputStore common.Store , svcs []keyservice.KeyServiceClient , decryptionOrder []string ) (rotateOpts , error ) {
22812339 kmsEncryptionContext := kms .ParseKMSContext (c .String ("encryption-context" ))
2282- addMasterKeys , err := getMasterKeys (c , kmsEncryptionContext , "add-kms" , "add-pgp" , "add-gcp-kms" , "add-hckms" , "add-azure-kv" , "add-hc-vault-transit" , "add-age" )
2340+ addMasterKeys , err := getMasterKeys (c , kmsEncryptionContext , "add-kms" , "add-pgp" , "add-gcp-kms" , "add-hckms" , "add-stackit-kms" , "add- azure-kv" , "add-hc-vault-transit" , "add-age" )
22832341 if err != nil {
22842342 return rotateOpts {}, err
22852343 }
2286- rmMasterKeys , err := getMasterKeys (c , kmsEncryptionContext , "rm-kms" , "rm-pgp" , "rm-gcp-kms" , "rm-hckms" , "rm-azure-kv" , "rm-hc-vault-transit" , "rm-age" )
2344+ rmMasterKeys , err := getMasterKeys (c , kmsEncryptionContext , "rm-kms" , "rm-pgp" , "rm-gcp-kms" , "rm-hckms" , "rm-stackit-kms" , "rm- azure-kv" , "rm-hc-vault-transit" , "rm-age" )
22872345 if err != nil {
22882346 return rotateOpts {}, err
22892347 }
@@ -2432,6 +2490,7 @@ func keyGroups(c *cli.Context, file string, optionalConfig *config.Config) ([]so
24322490 var azkvKeys []keys.MasterKey
24332491 var hcVaultMkKeys []keys.MasterKey
24342492 var hckmsMkKeys []keys.MasterKey
2493+ var stackitKmsMkKeys []keys.MasterKey
24352494 var ageMasterKeys []keys.MasterKey
24362495 kmsEncryptionContext := kms .ParseKMSContext (c .String ("encryption-context" ))
24372496 if c .String ("encryption-context" ) != "" && kmsEncryptionContext == nil {
@@ -2456,6 +2515,15 @@ func keyGroups(c *cli.Context, file string, optionalConfig *config.Config) ([]so
24562515 hckmsMkKeys = append (hckmsMkKeys , k )
24572516 }
24582517 }
2518+ if c .String ("stackit-kms" ) != "" {
2519+ stackitKmsKeys , err := stackitkms .NewMasterKeyFromResourceIDString (c .String ("stackit-kms" ))
2520+ if err != nil {
2521+ return nil , err
2522+ }
2523+ for _ , k := range stackitKmsKeys {
2524+ stackitKmsMkKeys = append (stackitKmsMkKeys , k )
2525+ }
2526+ }
24592527 if c .String ("azure-kv" ) != "" {
24602528 azureKeys , err := azkv .MasterKeysFromURLs (c .String ("azure-kv" ))
24612529 if err != nil {
@@ -2488,7 +2556,7 @@ func keyGroups(c *cli.Context, file string, optionalConfig *config.Config) ([]so
24882556 ageMasterKeys = append (ageMasterKeys , k )
24892557 }
24902558 }
2491- if c .String ("kms" ) == "" && c .String ("pgp" ) == "" && c .String ("gcp-kms" ) == "" && c .String ("hckms" ) == "" && c .String ("azure-kv" ) == "" && c .String ("hc-vault-transit" ) == "" && c .String ("age" ) == "" {
2559+ if c .String ("kms" ) == "" && c .String ("pgp" ) == "" && c .String ("gcp-kms" ) == "" && c .String ("hckms" ) == "" && c .String ("stackit-kms" ) == "" && c . String ( " azure-kv" ) == "" && c .String ("hc-vault-transit" ) == "" && c .String ("age" ) == "" {
24922560 conf := optionalConfig
24932561 var err error
24942562 if conf == nil {
@@ -2508,6 +2576,7 @@ func keyGroups(c *cli.Context, file string, optionalConfig *config.Config) ([]so
25082576 group = append (group , kmsKeys ... )
25092577 group = append (group , cloudKmsKeys ... )
25102578 group = append (group , hckmsMkKeys ... )
2579+ group = append (group , stackitKmsMkKeys ... )
25112580 group = append (group , azkvKeys ... )
25122581 group = append (group , pgpKeys ... )
25132582 group = append (group , hcVaultMkKeys ... )
0 commit comments