2015-04-02 00:09:11 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
2018-03-09 19:32:28 +00:00
|
|
|
"flag"
|
2015-04-02 00:09:11 +00:00
|
|
|
"fmt"
|
2018-04-09 16:39:32 +00:00
|
|
|
"strconv"
|
2015-04-02 00:09:11 +00:00
|
|
|
"strings"
|
2018-02-22 15:26:29 +00:00
|
|
|
"time"
|
2016-04-01 17:16:05 +00:00
|
|
|
|
2017-02-16 16:37:27 +00:00
|
|
|
"github.com/hashicorp/vault/api"
|
2019-04-12 21:54:35 +00:00
|
|
|
"github.com/hashicorp/vault/sdk/helper/consts"
|
2017-09-05 03:59:39 +00:00
|
|
|
"github.com/mitchellh/cli"
|
2017-08-24 22:23:40 +00:00
|
|
|
"github.com/posener/complete"
|
2015-04-02 00:09:11 +00:00
|
|
|
)
|
|
|
|
|
2021-04-08 16:43:39 +00:00
|
|
|
var (
|
|
|
|
_ cli.Command = (*AuthEnableCommand)(nil)
|
|
|
|
_ cli.CommandAutocomplete = (*AuthEnableCommand)(nil)
|
|
|
|
)
|
2017-09-05 03:59:39 +00:00
|
|
|
|
2015-04-02 00:09:11 +00:00
|
|
|
type AuthEnableCommand struct {
|
2017-09-05 03:59:39 +00:00
|
|
|
*BaseCommand
|
|
|
|
|
2018-03-21 23:56:47 +00:00
|
|
|
flagDescription string
|
|
|
|
flagPath string
|
|
|
|
flagDefaultLeaseTTL time.Duration
|
|
|
|
flagMaxLeaseTTL time.Duration
|
|
|
|
flagAuditNonHMACRequestKeys []string
|
|
|
|
flagAuditNonHMACResponseKeys []string
|
|
|
|
flagListingVisibility string
|
|
|
|
flagPluginName string
|
2019-02-05 21:02:15 +00:00
|
|
|
flagPassthroughRequestHeaders []string
|
|
|
|
flagAllowedResponseHeaders []string
|
2018-03-21 23:56:47 +00:00
|
|
|
flagOptions map[string]string
|
|
|
|
flagLocal bool
|
|
|
|
flagSealWrap bool
|
2019-10-17 17:33:00 +00:00
|
|
|
flagExternalEntropyAccess bool
|
2018-10-15 16:56:24 +00:00
|
|
|
flagTokenType string
|
2018-04-09 16:39:32 +00:00
|
|
|
flagVersion int
|
2017-09-05 03:59:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *AuthEnableCommand) Synopsis() string {
|
2017-09-08 01:56:39 +00:00
|
|
|
return "Enables a new auth method"
|
2017-09-05 03:59:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *AuthEnableCommand) Help() string {
|
|
|
|
helpText := `
|
2017-09-08 01:56:39 +00:00
|
|
|
Usage: vault auth enable [options] TYPE
|
2017-09-05 03:59:39 +00:00
|
|
|
|
2017-09-08 01:56:39 +00:00
|
|
|
Enables a new auth method. An auth method is responsible for authenticating
|
|
|
|
users or machines and assigning them policies with which they can access
|
|
|
|
Vault.
|
2017-09-05 03:59:39 +00:00
|
|
|
|
2017-09-08 01:56:39 +00:00
|
|
|
Enable the userpass auth method at userpass/:
|
2017-09-05 03:59:39 +00:00
|
|
|
|
2017-09-08 01:56:39 +00:00
|
|
|
$ vault auth enable userpass
|
2017-09-05 03:59:39 +00:00
|
|
|
|
2017-09-08 01:56:39 +00:00
|
|
|
Enable the LDAP auth method at auth-prod/:
|
2017-09-05 03:59:39 +00:00
|
|
|
|
2017-09-08 01:56:39 +00:00
|
|
|
$ vault auth enable -path=auth-prod ldap
|
2017-09-05 03:59:39 +00:00
|
|
|
|
2017-09-08 01:56:39 +00:00
|
|
|
Enable a custom auth plugin (after it's registered in the plugin registry):
|
2017-09-05 03:59:39 +00:00
|
|
|
|
2017-09-08 01:56:39 +00:00
|
|
|
$ vault auth enable -path=my-auth -plugin-name=my-auth-plugin plugin
|
2017-09-05 03:59:39 +00:00
|
|
|
|
2018-11-07 01:21:24 +00:00
|
|
|
OR (preferred way):
|
|
|
|
|
|
|
|
$ vault auth enable -path=my-auth my-auth-plugin
|
|
|
|
|
2017-09-05 03:59:39 +00:00
|
|
|
` + c.Flags().Help()
|
|
|
|
|
|
|
|
return strings.TrimSpace(helpText)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *AuthEnableCommand) Flags() *FlagSets {
|
|
|
|
set := c.flagSet(FlagSetHTTP)
|
|
|
|
|
|
|
|
f := set.NewFlagSet("Command Options")
|
|
|
|
|
|
|
|
f.StringVar(&StringVar{
|
|
|
|
Name: "description",
|
|
|
|
Target: &c.flagDescription,
|
|
|
|
Completion: complete.PredictAnything,
|
|
|
|
Usage: "Human-friendly description for the purpose of this " +
|
2017-09-08 01:56:39 +00:00
|
|
|
"auth method.",
|
2017-09-05 03:59:39 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
f.StringVar(&StringVar{
|
|
|
|
Name: "path",
|
|
|
|
Target: &c.flagPath,
|
|
|
|
Default: "", // The default is complex, so we have to manually document
|
|
|
|
Completion: complete.PredictAnything,
|
2017-09-08 01:56:39 +00:00
|
|
|
Usage: "Place where the auth method will be accessible. This must be " +
|
|
|
|
"unique across all auth methods. This defaults to the \"type\" of " +
|
|
|
|
"the auth method. The auth method will be accessible at " +
|
|
|
|
"\"/auth/<path>\".",
|
2017-09-05 03:59:39 +00:00
|
|
|
})
|
|
|
|
|
2018-02-22 15:26:29 +00:00
|
|
|
f.DurationVar(&DurationVar{
|
|
|
|
Name: "default-lease-ttl",
|
|
|
|
Target: &c.flagDefaultLeaseTTL,
|
|
|
|
Completion: complete.PredictAnything,
|
|
|
|
Usage: "The default lease TTL for this auth method. If unspecified, " +
|
|
|
|
"this defaults to the Vault server's globally configured default lease " +
|
|
|
|
"TTL.",
|
|
|
|
})
|
|
|
|
|
|
|
|
f.DurationVar(&DurationVar{
|
|
|
|
Name: "max-lease-ttl",
|
|
|
|
Target: &c.flagMaxLeaseTTL,
|
|
|
|
Completion: complete.PredictAnything,
|
|
|
|
Usage: "The maximum lease TTL for this auth method. If unspecified, " +
|
|
|
|
"this defaults to the Vault server's globally configured maximum lease " +
|
|
|
|
"TTL.",
|
|
|
|
})
|
|
|
|
|
2018-03-09 19:32:28 +00:00
|
|
|
f.StringSliceVar(&StringSliceVar{
|
|
|
|
Name: flagNameAuditNonHMACRequestKeys,
|
|
|
|
Target: &c.flagAuditNonHMACRequestKeys,
|
2019-03-14 20:57:28 +00:00
|
|
|
Usage: "Comma-separated string or list of keys that will not be HMAC'd by audit " +
|
2018-03-09 19:32:28 +00:00
|
|
|
"devices in the request data object.",
|
|
|
|
})
|
|
|
|
|
|
|
|
f.StringSliceVar(&StringSliceVar{
|
|
|
|
Name: flagNameAuditNonHMACResponseKeys,
|
|
|
|
Target: &c.flagAuditNonHMACResponseKeys,
|
2019-03-14 20:57:28 +00:00
|
|
|
Usage: "Comma-separated string or list of keys that will not be HMAC'd by audit " +
|
2018-03-09 19:32:28 +00:00
|
|
|
"devices in the response data object.",
|
|
|
|
})
|
|
|
|
|
2018-03-20 03:16:33 +00:00
|
|
|
f.StringVar(&StringVar{
|
|
|
|
Name: flagNameListingVisibility,
|
|
|
|
Target: &c.flagListingVisibility,
|
|
|
|
Usage: "Determines the visibility of the mount in the UI-specific listing endpoint.",
|
|
|
|
})
|
|
|
|
|
2018-03-21 23:56:47 +00:00
|
|
|
f.StringSliceVar(&StringSliceVar{
|
|
|
|
Name: flagNamePassthroughRequestHeaders,
|
|
|
|
Target: &c.flagPassthroughRequestHeaders,
|
|
|
|
Usage: "Comma-separated string or list of request header values that " +
|
2019-02-05 21:02:15 +00:00
|
|
|
"will be sent to the plugin",
|
|
|
|
})
|
|
|
|
|
|
|
|
f.StringSliceVar(&StringSliceVar{
|
|
|
|
Name: flagNameAllowedResponseHeaders,
|
|
|
|
Target: &c.flagAllowedResponseHeaders,
|
|
|
|
Usage: "Comma-separated string or list of response header values that " +
|
|
|
|
"plugins will be allowed to set",
|
2018-03-21 23:56:47 +00:00
|
|
|
})
|
|
|
|
|
2017-09-05 03:59:39 +00:00
|
|
|
f.StringVar(&StringVar{
|
|
|
|
Name: "plugin-name",
|
|
|
|
Target: &c.flagPluginName,
|
2018-11-07 01:21:24 +00:00
|
|
|
Completion: c.PredictVaultPlugins(consts.PluginTypeCredential),
|
2017-09-08 01:56:39 +00:00
|
|
|
Usage: "Name of the auth method plugin. This plugin name must already " +
|
2017-09-05 03:59:39 +00:00
|
|
|
"exist in the Vault server's plugin catalog.",
|
|
|
|
})
|
|
|
|
|
2018-03-21 19:04:27 +00:00
|
|
|
f.StringMapVar(&StringMapVar{
|
|
|
|
Name: "options",
|
|
|
|
Target: &c.flagOptions,
|
|
|
|
Completion: complete.PredictAnything,
|
|
|
|
Usage: "Key-value pair provided as key=value for the mount options. " +
|
2018-03-22 03:58:16 +00:00
|
|
|
"This can be specified multiple times.",
|
2018-03-21 19:04:27 +00:00
|
|
|
})
|
|
|
|
|
2017-09-05 03:59:39 +00:00
|
|
|
f.BoolVar(&BoolVar{
|
|
|
|
Name: "local",
|
|
|
|
Target: &c.flagLocal,
|
|
|
|
Default: false,
|
2017-09-08 01:56:39 +00:00
|
|
|
Usage: "Mark the auth method as local-only. Local auth methods are " +
|
2017-09-05 03:59:39 +00:00
|
|
|
"not replicated nor removed by replication.",
|
|
|
|
})
|
|
|
|
|
2018-01-03 19:02:31 +00:00
|
|
|
f.BoolVar(&BoolVar{
|
|
|
|
Name: "seal-wrap",
|
|
|
|
Target: &c.flagSealWrap,
|
|
|
|
Default: false,
|
|
|
|
Usage: "Enable seal wrapping of critical values in the secrets engine.",
|
|
|
|
})
|
|
|
|
|
2019-10-17 17:33:00 +00:00
|
|
|
f.BoolVar(&BoolVar{
|
|
|
|
Name: "external-entropy-access",
|
|
|
|
Target: &c.flagExternalEntropyAccess,
|
|
|
|
Default: false,
|
|
|
|
Usage: "Enable auth method to access Vault's external entropy source.",
|
|
|
|
})
|
|
|
|
|
2018-10-15 16:56:24 +00:00
|
|
|
f.StringVar(&StringVar{
|
|
|
|
Name: flagNameTokenType,
|
|
|
|
Target: &c.flagTokenType,
|
|
|
|
Usage: "Sets a forced token type for the mount.",
|
|
|
|
})
|
|
|
|
|
2018-04-09 16:39:32 +00:00
|
|
|
f.IntVar(&IntVar{
|
|
|
|
Name: "version",
|
|
|
|
Target: &c.flagVersion,
|
|
|
|
Default: 0,
|
|
|
|
Usage: "Select the version of the auth method to run. Not supported by all auth methods.",
|
|
|
|
})
|
|
|
|
|
2017-09-05 03:59:39 +00:00
|
|
|
return set
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *AuthEnableCommand) AutocompleteArgs() complete.Predictor {
|
|
|
|
return c.PredictVaultAvailableAuths()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *AuthEnableCommand) AutocompleteFlags() complete.Flags {
|
|
|
|
return c.Flags().Completions()
|
2015-04-02 00:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *AuthEnableCommand) Run(args []string) int {
|
2017-09-05 03:59:39 +00:00
|
|
|
f := c.Flags()
|
|
|
|
|
|
|
|
if err := f.Parse(args); err != nil {
|
|
|
|
c.UI.Error(err.Error())
|
2015-04-02 00:09:11 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2017-09-05 03:59:39 +00:00
|
|
|
args = f.Args()
|
|
|
|
switch {
|
|
|
|
case len(args) < 1:
|
|
|
|
c.UI.Error(fmt.Sprintf("Not enough arguments (expected 1, got %d)", len(args)))
|
|
|
|
return 1
|
|
|
|
case len(args) > 1:
|
|
|
|
c.UI.Error(fmt.Sprintf("Too many arguments (expected 1, got %d)", len(args)))
|
2015-04-02 00:09:11 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2017-09-05 03:59:39 +00:00
|
|
|
client, err := c.Client()
|
|
|
|
if err != nil {
|
|
|
|
c.UI.Error(err.Error())
|
|
|
|
return 2
|
|
|
|
}
|
|
|
|
|
|
|
|
authType := strings.TrimSpace(args[0])
|
2018-11-07 01:21:24 +00:00
|
|
|
if authType == "plugin" {
|
|
|
|
authType = c.flagPluginName
|
|
|
|
}
|
2015-04-02 00:09:11 +00:00
|
|
|
|
|
|
|
// If no path is specified, we default the path to the backend type
|
Backend plugin system (#2874)
* Add backend plugin changes
* Fix totp backend plugin tests
* Fix logical/plugin InvalidateKey test
* Fix plugin catalog CRUD test, fix NoopBackend
* Clean up commented code block
* Fix system backend mount test
* Set plugin_name to omitempty, fix handleMountTable config parsing
* Clean up comments, keep shim connections alive until cleanup
* Include pluginClient, disallow LookupPlugin call from within a plugin
* Add wrapper around backendPluginClient for proper cleanup
* Add logger shim tests
* Add logger, storage, and system shim tests
* Use pointer receivers for system view shim
* Use plugin name if no path is provided on mount
* Enable plugins for auth backends
* Add backend type attribute, move builtin/plugin/package
* Fix merge conflict
* Fix missing plugin name in mount config
* Add integration tests on enabling auth backend plugins
* Remove dependency cycle on mock-plugin
* Add passthrough backend plugin, use logical.BackendType to determine lease generation
* Remove vault package dependency on passthrough package
* Add basic impl test for passthrough plugin
* Incorporate feedback; set b.backend after shims creation on backendPluginServer
* Fix totp plugin test
* Add plugin backends docs
* Fix tests
* Fix builtin/plugin tests
* Remove flatten from PluginRunner fields
* Move mock plugin to logical/plugin, remove totp and passthrough plugins
* Move pluginMap into newPluginClient
* Do not create storage RPC connection on HandleRequest and HandleExistenceCheck
* Change shim logger's Fatal to no-op
* Change BackendType to uint32, match UX backend types
* Change framework.Backend Setup signature
* Add Setup func to logical.Backend interface
* Move OptionallyEnableMlock call into plugin.Serve, update docs and comments
* Remove commented var in plugin package
* RegisterLicense on logical.Backend interface (#3017)
* Add RegisterLicense to logical.Backend interface
* Update RegisterLicense to use callback func on framework.Backend
* Refactor framework.Backend.RegisterLicense
* plugin: Prevent plugin.SystemViewClient.ResponseWrapData from getting JWTs
* plugin: Revert BackendType to remove TypePassthrough and related references
* Fix typo in plugin backends docs
2017-07-20 17:28:40 +00:00
|
|
|
// or use the plugin name if it's a plugin backend
|
2017-09-05 03:59:39 +00:00
|
|
|
authPath := c.flagPath
|
|
|
|
if authPath == "" {
|
Backend plugin system (#2874)
* Add backend plugin changes
* Fix totp backend plugin tests
* Fix logical/plugin InvalidateKey test
* Fix plugin catalog CRUD test, fix NoopBackend
* Clean up commented code block
* Fix system backend mount test
* Set plugin_name to omitempty, fix handleMountTable config parsing
* Clean up comments, keep shim connections alive until cleanup
* Include pluginClient, disallow LookupPlugin call from within a plugin
* Add wrapper around backendPluginClient for proper cleanup
* Add logger shim tests
* Add logger, storage, and system shim tests
* Use pointer receivers for system view shim
* Use plugin name if no path is provided on mount
* Enable plugins for auth backends
* Add backend type attribute, move builtin/plugin/package
* Fix merge conflict
* Fix missing plugin name in mount config
* Add integration tests on enabling auth backend plugins
* Remove dependency cycle on mock-plugin
* Add passthrough backend plugin, use logical.BackendType to determine lease generation
* Remove vault package dependency on passthrough package
* Add basic impl test for passthrough plugin
* Incorporate feedback; set b.backend after shims creation on backendPluginServer
* Fix totp plugin test
* Add plugin backends docs
* Fix tests
* Fix builtin/plugin tests
* Remove flatten from PluginRunner fields
* Move mock plugin to logical/plugin, remove totp and passthrough plugins
* Move pluginMap into newPluginClient
* Do not create storage RPC connection on HandleRequest and HandleExistenceCheck
* Change shim logger's Fatal to no-op
* Change BackendType to uint32, match UX backend types
* Change framework.Backend Setup signature
* Add Setup func to logical.Backend interface
* Move OptionallyEnableMlock call into plugin.Serve, update docs and comments
* Remove commented var in plugin package
* RegisterLicense on logical.Backend interface (#3017)
* Add RegisterLicense to logical.Backend interface
* Update RegisterLicense to use callback func on framework.Backend
* Refactor framework.Backend.RegisterLicense
* plugin: Prevent plugin.SystemViewClient.ResponseWrapData from getting JWTs
* plugin: Revert BackendType to remove TypePassthrough and related references
* Fix typo in plugin backends docs
2017-07-20 17:28:40 +00:00
|
|
|
if authType == "plugin" {
|
2017-09-05 03:59:39 +00:00
|
|
|
authPath = c.flagPluginName
|
Backend plugin system (#2874)
* Add backend plugin changes
* Fix totp backend plugin tests
* Fix logical/plugin InvalidateKey test
* Fix plugin catalog CRUD test, fix NoopBackend
* Clean up commented code block
* Fix system backend mount test
* Set plugin_name to omitempty, fix handleMountTable config parsing
* Clean up comments, keep shim connections alive until cleanup
* Include pluginClient, disallow LookupPlugin call from within a plugin
* Add wrapper around backendPluginClient for proper cleanup
* Add logger shim tests
* Add logger, storage, and system shim tests
* Use pointer receivers for system view shim
* Use plugin name if no path is provided on mount
* Enable plugins for auth backends
* Add backend type attribute, move builtin/plugin/package
* Fix merge conflict
* Fix missing plugin name in mount config
* Add integration tests on enabling auth backend plugins
* Remove dependency cycle on mock-plugin
* Add passthrough backend plugin, use logical.BackendType to determine lease generation
* Remove vault package dependency on passthrough package
* Add basic impl test for passthrough plugin
* Incorporate feedback; set b.backend after shims creation on backendPluginServer
* Fix totp plugin test
* Add plugin backends docs
* Fix tests
* Fix builtin/plugin tests
* Remove flatten from PluginRunner fields
* Move mock plugin to logical/plugin, remove totp and passthrough plugins
* Move pluginMap into newPluginClient
* Do not create storage RPC connection on HandleRequest and HandleExistenceCheck
* Change shim logger's Fatal to no-op
* Change BackendType to uint32, match UX backend types
* Change framework.Backend Setup signature
* Add Setup func to logical.Backend interface
* Move OptionallyEnableMlock call into plugin.Serve, update docs and comments
* Remove commented var in plugin package
* RegisterLicense on logical.Backend interface (#3017)
* Add RegisterLicense to logical.Backend interface
* Update RegisterLicense to use callback func on framework.Backend
* Refactor framework.Backend.RegisterLicense
* plugin: Prevent plugin.SystemViewClient.ResponseWrapData from getting JWTs
* plugin: Revert BackendType to remove TypePassthrough and related references
* Fix typo in plugin backends docs
2017-07-20 17:28:40 +00:00
|
|
|
} else {
|
2017-09-05 03:59:39 +00:00
|
|
|
authPath = authType
|
Backend plugin system (#2874)
* Add backend plugin changes
* Fix totp backend plugin tests
* Fix logical/plugin InvalidateKey test
* Fix plugin catalog CRUD test, fix NoopBackend
* Clean up commented code block
* Fix system backend mount test
* Set plugin_name to omitempty, fix handleMountTable config parsing
* Clean up comments, keep shim connections alive until cleanup
* Include pluginClient, disallow LookupPlugin call from within a plugin
* Add wrapper around backendPluginClient for proper cleanup
* Add logger shim tests
* Add logger, storage, and system shim tests
* Use pointer receivers for system view shim
* Use plugin name if no path is provided on mount
* Enable plugins for auth backends
* Add backend type attribute, move builtin/plugin/package
* Fix merge conflict
* Fix missing plugin name in mount config
* Add integration tests on enabling auth backend plugins
* Remove dependency cycle on mock-plugin
* Add passthrough backend plugin, use logical.BackendType to determine lease generation
* Remove vault package dependency on passthrough package
* Add basic impl test for passthrough plugin
* Incorporate feedback; set b.backend after shims creation on backendPluginServer
* Fix totp plugin test
* Add plugin backends docs
* Fix tests
* Fix builtin/plugin tests
* Remove flatten from PluginRunner fields
* Move mock plugin to logical/plugin, remove totp and passthrough plugins
* Move pluginMap into newPluginClient
* Do not create storage RPC connection on HandleRequest and HandleExistenceCheck
* Change shim logger's Fatal to no-op
* Change BackendType to uint32, match UX backend types
* Change framework.Backend Setup signature
* Add Setup func to logical.Backend interface
* Move OptionallyEnableMlock call into plugin.Serve, update docs and comments
* Remove commented var in plugin package
* RegisterLicense on logical.Backend interface (#3017)
* Add RegisterLicense to logical.Backend interface
* Update RegisterLicense to use callback func on framework.Backend
* Refactor framework.Backend.RegisterLicense
* plugin: Prevent plugin.SystemViewClient.ResponseWrapData from getting JWTs
* plugin: Revert BackendType to remove TypePassthrough and related references
* Fix typo in plugin backends docs
2017-07-20 17:28:40 +00:00
|
|
|
}
|
2015-04-02 00:09:11 +00:00
|
|
|
}
|
|
|
|
|
2017-09-05 03:59:39 +00:00
|
|
|
// Append a trailing slash to indicate it's a path in output
|
|
|
|
authPath = ensureTrailingSlash(authPath)
|
2015-04-02 00:09:11 +00:00
|
|
|
|
2018-04-09 16:39:32 +00:00
|
|
|
if c.flagVersion > 0 {
|
|
|
|
if c.flagOptions == nil {
|
|
|
|
c.flagOptions = make(map[string]string)
|
|
|
|
}
|
|
|
|
c.flagOptions["version"] = strconv.Itoa(c.flagVersion)
|
|
|
|
}
|
|
|
|
|
2018-03-09 19:32:28 +00:00
|
|
|
authOpts := &api.EnableAuthOptions{
|
2019-11-07 16:54:34 +00:00
|
|
|
Type: authType,
|
|
|
|
Description: c.flagDescription,
|
|
|
|
Local: c.flagLocal,
|
|
|
|
SealWrap: c.flagSealWrap,
|
2019-10-17 17:33:00 +00:00
|
|
|
ExternalEntropyAccess: c.flagExternalEntropyAccess,
|
2017-08-31 16:16:59 +00:00
|
|
|
Config: api.AuthConfigInput{
|
2018-02-22 15:26:29 +00:00
|
|
|
DefaultLeaseTTL: c.flagDefaultLeaseTTL.String(),
|
|
|
|
MaxLeaseTTL: c.flagMaxLeaseTTL.String(),
|
2017-08-31 16:16:59 +00:00
|
|
|
},
|
2018-03-21 19:04:27 +00:00
|
|
|
Options: c.flagOptions,
|
2018-03-09 19:32:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set these values only if they are provided in the CLI
|
|
|
|
f.Visit(func(fl *flag.Flag) {
|
|
|
|
if fl.Name == flagNameAuditNonHMACRequestKeys {
|
|
|
|
authOpts.Config.AuditNonHMACRequestKeys = c.flagAuditNonHMACRequestKeys
|
|
|
|
}
|
|
|
|
|
|
|
|
if fl.Name == flagNameAuditNonHMACResponseKeys {
|
2018-03-19 13:56:57 +00:00
|
|
|
authOpts.Config.AuditNonHMACResponseKeys = c.flagAuditNonHMACResponseKeys
|
2018-03-09 19:32:28 +00:00
|
|
|
}
|
2018-03-20 03:16:33 +00:00
|
|
|
|
|
|
|
if fl.Name == flagNameListingVisibility {
|
|
|
|
authOpts.Config.ListingVisibility = c.flagListingVisibility
|
|
|
|
}
|
2018-03-21 23:56:47 +00:00
|
|
|
|
|
|
|
if fl.Name == flagNamePassthroughRequestHeaders {
|
|
|
|
authOpts.Config.PassthroughRequestHeaders = c.flagPassthroughRequestHeaders
|
|
|
|
}
|
2018-10-15 16:56:24 +00:00
|
|
|
|
2019-02-05 21:02:15 +00:00
|
|
|
if fl.Name == flagNameAllowedResponseHeaders {
|
|
|
|
authOpts.Config.AllowedResponseHeaders = c.flagAllowedResponseHeaders
|
|
|
|
}
|
|
|
|
|
2018-10-15 16:56:24 +00:00
|
|
|
if fl.Name == flagNameTokenType {
|
|
|
|
authOpts.Config.TokenType = c.flagTokenType
|
|
|
|
}
|
2018-03-09 19:32:28 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
if err := client.Sys().EnableAuthWithOptions(authPath, authOpts); err != nil {
|
2017-09-05 03:59:39 +00:00
|
|
|
c.UI.Error(fmt.Sprintf("Error enabling %s auth: %s", authType, err))
|
2015-04-02 00:09:11 +00:00
|
|
|
return 2
|
|
|
|
}
|
|
|
|
|
2017-09-08 01:56:39 +00:00
|
|
|
authThing := authType + " auth method"
|
2017-08-16 18:31:16 +00:00
|
|
|
if authType == "plugin" {
|
2017-09-05 03:59:39 +00:00
|
|
|
authThing = c.flagPluginName + " plugin"
|
2017-08-16 18:31:16 +00:00
|
|
|
}
|
2017-09-05 03:59:39 +00:00
|
|
|
c.UI.Output(fmt.Sprintf("Success! Enabled %s at: %s", authThing, authPath))
|
2015-04-02 00:09:11 +00:00
|
|
|
return 0
|
|
|
|
}
|