2018-03-01 01:09:21 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/vault/command/token"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DefaultTokenHelper returns the token helper that is configured for Vault.
|
2022-08-16 20:48:24 +00:00
|
|
|
// This helper should only be used for non-server CLI commands.
|
2018-03-01 01:09:21 +00:00
|
|
|
func DefaultTokenHelper() (token.TokenHelper, error) {
|
|
|
|
config, err := LoadConfig("")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
path := config.TokenHelper
|
|
|
|
if path == "" {
|
2020-04-27 23:55:13 +00:00
|
|
|
return token.NewInternalTokenHelper()
|
2018-03-01 01:09:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
path, err = token.ExternalTokenHelperPath(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &token.ExternalTokenHelper{BinaryPath: path}, nil
|
|
|
|
}
|