-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make plugin-specific env take precedence over sys env (#25128)
* Make plugin-specific env take precedence over sys env * Expand the existing plugin env integration test --------- Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
- Loading branch information
1 parent
a4caebc
commit dd0b5dc
Showing
9 changed files
with
349 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
```release-note:change | ||
plugins: By default, environment variables provided during plugin registration will now take precedence over system environment variables. | ||
Use the environment variable `VAULT_PLUGIN_USE_LEGACY_ENV_LAYERING=true` to opt out and keep higher preference for system environment | ||
variables. When this flag is set, Vault will check during unseal for conflicts and print warnings for any plugins with environment | ||
variables that conflict with system environment variables. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package mock | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/hashicorp/vault/sdk/framework" | ||
"github.com/hashicorp/vault/sdk/logical" | ||
) | ||
|
||
// pathEnv is used to interrogate plugin env vars. | ||
func pathEnv(b *backend) *framework.Path { | ||
return &framework.Path{ | ||
Pattern: "env/" + framework.GenericNameRegex("key"), | ||
Fields: map[string]*framework.FieldSchema{ | ||
"key": { | ||
Type: framework.TypeString, | ||
Required: true, | ||
Description: "The name of the environment variable to read.", | ||
}, | ||
}, | ||
Callbacks: map[logical.Operation]framework.OperationFunc{ | ||
logical.ReadOperation: b.pathEnvRead, | ||
}, | ||
} | ||
} | ||
|
||
func (b *backend) pathEnvRead(_ context.Context, _ *logical.Request, data *framework.FieldData) (*logical.Response, error) { | ||
// Return the secret | ||
return &logical.Response{ | ||
Data: map[string]interface{}{ | ||
"key": os.Getenv(data.Get("key").(string)), | ||
}, | ||
}, nil | ||
} |
Oops, something went wrong.