From 7672d694952f8e7d6e2c4eaaa621637e8cac8d62 Mon Sep 17 00:00:00 2001 From: vishalnayak Date: Wed, 15 Jun 2016 16:45:07 -0400 Subject: [PATCH] Added '-path' option to 'vault auth' command --- command/auth.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/command/auth.go b/command/auth.go index 9b1ae4baf9..beaea7c45f 100644 --- a/command/auth.go +++ b/command/auth.go @@ -35,13 +35,14 @@ type AuthCommand struct { } func (c *AuthCommand) Run(args []string) int { - var method string + var method, authPath string var methods, methodHelp, noVerify bool flags := c.Meta.FlagSet("auth", meta.FlagSetDefault) flags.BoolVar(&methods, "methods", false, "") flags.BoolVar(&methodHelp, "method-help", false, "") flags.BoolVar(&noVerify, "no-verify", false, "") flags.StringVar(&method, "method", "", "method") + flags.StringVar(&authPath, "path", "", "") flags.Usage = func() { c.Ui.Error(c.Help()) } if err := flags.Parse(args); err != nil { return 1 @@ -148,6 +149,10 @@ func (c *AuthCommand) Run(args []string) int { return 1 } + if authPath != "" { + vars["mount"] = authPath + } + // Authenticate token, err := handler.Auth(client, vars) if err != nil { @@ -298,10 +303,14 @@ Usage: vault auth [options] [token or config...] "vault write". Specify the "-method-help" flag to get help for a specific method. - If you've mounted a credential backend to a different path, such - as mounting "github" to "github-private", the "method" flag should - still be "github." Most credential providers support the "mount" option - to specify the mount point. See the "-method-help" for more info. + If an auth backend is enabled at a different path, such as enabling + "github" at "github-private", the "method" flag should still be "github". + The flag "-path" should be used to specify the path at which the auth + backend is enabled. For example: + "vault auth -method=github -path=github-private token=" + The value of the "path" flag will be supplied to auth providers + as the "mount" option in the payload to specify the mount point. + See the "-method-help" for more info. General Options: