mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-12 09:37:02 +02:00
* Port awskms autoseal * Rename files * WIP autoseal * Fix protobuf conflict * Expose some structs to properly allow encrypting stored keys * Update awskms with the latest changes * Add KeyGuard implementation to abstract encryption/decryption of keys * Fully decouple seal.Access implementations from sealwrap structs * Add extra line to proto files, comment update * Update seal_access_entry.go * govendor sync * Add endpoint info to configureAWSKMSSeal * Update comment * Refactor structs * Update make proto * Remove remove KeyGuard, move encrypt/decrypt to autoSeal * Add rest of seals, update VerifyRecoveryKeys, add deps * Fix some merge conflicts via govendor updates * Rename SealWrapEntry to EncryptedBlobInfo * Remove barrier type upgrade check in oss * Add key to EncryptedBlobInfo proto * Update barrierTypeUpgradeCheck signature
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package seal
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
log "github.com/hashicorp/go-hclog"
|
|
"github.com/hashicorp/vault/command/server"
|
|
"github.com/hashicorp/vault/vault"
|
|
)
|
|
|
|
var (
|
|
ConfigureSeal func(*server.Config, *[]string, *map[string]string, log.Logger, vault.Seal) (vault.Seal, error) = configureSeal
|
|
)
|
|
|
|
func configureSeal(config *server.Config, infoKeys *[]string, info *map[string]string, logger log.Logger, inseal vault.Seal) (seal vault.Seal, err error) {
|
|
if config.Seal != nil || os.Getenv("VAULT_SEAL_TYPE") != "" {
|
|
if config.Seal == nil {
|
|
config.Seal = &server.Seal{
|
|
Type: os.Getenv("VAULT_SEAL_TYPE"),
|
|
}
|
|
}
|
|
switch config.Seal.Type {
|
|
case "alicloudkms":
|
|
return configureAliCloudKMSSeal(config, infoKeys, info, logger, inseal)
|
|
|
|
case "awskms":
|
|
return configureAWSKMSSeal(config, infoKeys, info, logger, inseal)
|
|
|
|
case "gcpckms":
|
|
return configureGCPCKMSSeal(config, infoKeys, info, logger, inseal)
|
|
|
|
case "azurekeyvault":
|
|
return configureAzureKeyVaultSeal(config, infoKeys, info, logger, inseal)
|
|
|
|
case "pkcs11":
|
|
return nil, fmt.Errorf("Seal type 'pkcs11' requires the Vault Enterprise HSM binary")
|
|
|
|
default:
|
|
return nil, fmt.Errorf("Unknown seal type %q", config.Seal.Type)
|
|
}
|
|
}
|
|
|
|
return inseal, nil
|
|
}
|