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

feat(auth/ldap): allow passing the LDAP password via an env var #18225

Merged
merged 2 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 16 additions & 8 deletions builtin/credential/ldap/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, erro
}
password, ok := m["password"]
if !ok {
fmt.Fprintf(os.Stderr, "Password (will be hidden): ")
var err error
password, err = pwd.Read(os.Stdin)
fmt.Fprintf(os.Stderr, "\n")
if err != nil {
return nil, err
password = passwordFromEnv()
if password == "" {
fmt.Fprintf(os.Stderr, "Password (will be hidden): ")
var err error
password, err = pwd.Read(os.Stdin)
fmt.Fprintf(os.Stderr, "\n")
if err != nil {
return nil, err
}
}
}

Expand Down Expand Up @@ -70,8 +73,9 @@ Usage: vault login -method=ldap [CONFIG K=V...]
Configuration:

password=<string>
LDAP password to use for authentication. If not provided, the CLI will
prompt for this on stdin.
LDAP password to use for authentication. If not provided, it will use
the VAULT_LDAP_PASSWORD environment variable. If this is not set, the
CLI will prompt for this on stdin.

username=<string>
LDAP username to use for authentication.
Expand All @@ -89,3 +93,7 @@ func usernameFromEnv() string {
}
return ""
}

func passwordFromEnv() string {
return os.Getenv("VAULT_LDAP_PASSWORD")
}
3 changes: 3 additions & 0 deletions changelog/18225.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
auth/ldap: allow providing the LDAP password via an env var when authenticating via the CLI
```