Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -dev-no-store-token to vault server command #7104

Merged
merged 2 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ type ServerCommand struct {
reloadedCh chan (struct{}) // for tests

// new stuff
flagConfigs []string
flagLogLevel string
flagDev bool
flagDevRootTokenID string
flagDevListenAddr string
flagConfigs []string
flagLogLevel string
flagDev bool
flagDevRootTokenID string
flagDevListenAddr string
flagDevNoStoreToken bool

flagDevPluginDir string
flagDevPluginInit bool
Expand Down Expand Up @@ -201,6 +202,14 @@ func (c *ServerCommand) Flags() *FlagSets {
EnvVar: "VAULT_DEV_LISTEN_ADDRESS",
Usage: "Address to bind to in \"dev\" mode.",
})
f.BoolVar(&BoolVar{
Name: "dev-no-store-token",
Target: &c.flagDevNoStoreToken,
Default: false,
Usage: "Do not persist the dev root token to the token helper " +
"(usually the local filesystem) for use in future requests. " +
"The token will only be displayed in the command output.",
})

// Internal-only flags to follow.
//
Expand Down Expand Up @@ -1474,12 +1483,14 @@ func (c *ServerCommand) enableDev(core *vault.Core, coreConfig *vault.CoreConfig
}

// Set the token
tokenHelper, err := c.TokenHelper()
if err != nil {
return nil, err
}
if err := tokenHelper.Store(init.RootToken); err != nil {
return nil, err
if !c.flagDevNoStoreToken {
tokenHelper, err := c.TokenHelper()
if err != nil {
return nil, err
}
if err := tokenHelper.Store(init.RootToken); err != nil {
return nil, err
}
}

kvVer := "2"
Expand Down
4 changes: 4 additions & 0 deletions website/source/docs/commands/server.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ flags](/docs/commands/index.html) included on all commands.
when running in "dev" mode. This can also be specified via the
`VAULT_DEV_ROOT_TOKEN_ID` environment variable.

- `-dev-no-store-token` `(string: "")` - Do not persist the dev root token to
the token helper (usually the local filesystem) for use in future requests.
The token will only be displayed in the command output.

- `-dev-plugin-dir` `(string: "")` - Directory from which plugins are allowed to be loaded. Only applies in "dev" mode, it will automatically register all the plugins in the provided directory.