Skip to content

Commit

Permalink
duplicates some constants defined in pluginutil to avoid depending on…
Browse files Browse the repository at this point in the history
… x/net/trace
  • Loading branch information
Lexman42 committed May 8, 2019
1 parent 94de051 commit 31495c5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions api/plugin_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ import (
squarejwt "gopkg.in/square/go-jose.v2/jwt"

"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
Expand Down Expand Up @@ -61,12 +70,12 @@ func (f *PluginAPIClientMeta) GetTLSConfig() *TLSConfig {
// VaultPluginTLSProvider is run inside a plugin and retrieves the response
// wrapped TLS certificate from vault. It returns a configured TLS Config.
func VaultPluginTLSProvider(apiTLSConfig *TLSConfig) func() (*tls.Config, error) {
if os.Getenv(pluginutil.PluginMetadataModeEnv) == "true" {
if os.Getenv(PluginMetadataModeEnv) == "true" {
return nil
}

return func() (*tls.Config, error) {
unwrapToken := os.Getenv(pluginutil.PluginUnwrapTokenEnv)
unwrapToken := os.Getenv(PluginUnwrapTokenEnv)

parsedJWT, err := squarejwt.ParseSigned(unwrapToken)
if err != nil {
Expand Down

0 comments on commit 31495c5

Please sign in to comment.