duplicates some constants defined in pluginutil to avoid depending on x/net/trace (#6703)

This commit is contained in:
Lexman
2019-05-08 16:21:23 -07:00
committed by Brian Kassouf
parent 94de051e28
commit 794ac15540

View File

@@ -12,7 +12,16 @@ import (
squarejwt "gopkg.in/square/go-jose.v2/jwt" squarejwt "gopkg.in/square/go-jose.v2/jwt"
"github.com/hashicorp/errwrap" "github.com/hashicorp/errwrap"
"github.com/hashicorp/vault/sdk/helper/pluginutil" )
var (
// PluginMetadataModeEnv is an ENV name used to disable TLS communication
// to bootstrap mounting plugins.
PluginMetadataModeEnv = "VAULT_PLUGIN_METADATA_MODE"
// PluginUnwrapTokenEnv is the ENV name used to pass unwrap tokens to the
// plugin.
PluginUnwrapTokenEnv = "VAULT_UNWRAP_TOKEN"
) )
// PluginAPIClientMeta is a helper that plugins can use to configure TLS connections // PluginAPIClientMeta is a helper that plugins can use to configure TLS connections
@@ -61,12 +70,12 @@ func (f *PluginAPIClientMeta) GetTLSConfig() *TLSConfig {
// VaultPluginTLSProvider is run inside a plugin and retrieves the response // VaultPluginTLSProvider is run inside a plugin and retrieves the response
// wrapped TLS certificate from vault. It returns a configured TLS Config. // wrapped TLS certificate from vault. It returns a configured TLS Config.
func VaultPluginTLSProvider(apiTLSConfig *TLSConfig) func() (*tls.Config, error) { func VaultPluginTLSProvider(apiTLSConfig *TLSConfig) func() (*tls.Config, error) {
if os.Getenv(pluginutil.PluginMetadataModeEnv) == "true" { if os.Getenv(PluginMetadataModeEnv) == "true" {
return nil return nil
} }
return func() (*tls.Config, error) { return func() (*tls.Config, error) {
unwrapToken := os.Getenv(pluginutil.PluginUnwrapTokenEnv) unwrapToken := os.Getenv(PluginUnwrapTokenEnv)
parsedJWT, err := squarejwt.ParseSigned(unwrapToken) parsedJWT, err := squarejwt.ParseSigned(unwrapToken)
if err != nil { if err != nil {