mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	feat(auth/ldap): allow passing the LDAP password via an env var (#18225)
* feat(auth/ldap): allow passing the LDAP password via an environment variable when authenticating via the CLI * chore(auth/ldap): add changelog entry for PR 18225
This commit is contained in:
		| @@ -26,6 +26,8 @@ func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, erro | |||||||
| 	} | 	} | ||||||
| 	password, ok := m["password"] | 	password, ok := m["password"] | ||||||
| 	if !ok { | 	if !ok { | ||||||
|  | 		password = passwordFromEnv() | ||||||
|  | 		if password == "" { | ||||||
| 			fmt.Fprintf(os.Stderr, "Password (will be hidden): ") | 			fmt.Fprintf(os.Stderr, "Password (will be hidden): ") | ||||||
| 			var err error | 			var err error | ||||||
| 			password, err = pwd.Read(os.Stdin) | 			password, err = pwd.Read(os.Stdin) | ||||||
| @@ -34,6 +36,7 @@ func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, erro | |||||||
| 				return nil, err | 				return nil, err | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	data := map[string]interface{}{ | 	data := map[string]interface{}{ | ||||||
| 		"password": password, | 		"password": password, | ||||||
| @@ -70,8 +73,9 @@ Usage: vault login -method=ldap [CONFIG K=V...] | |||||||
| Configuration: | Configuration: | ||||||
|  |  | ||||||
|   password=<string> |   password=<string> | ||||||
|       LDAP password to use for authentication. If not provided, the CLI will |       LDAP password to use for authentication. If not provided, it will use | ||||||
|       prompt for this on stdin. | 			the VAULT_LDAP_PASSWORD environment variable. If this is not set, the | ||||||
|  | 			CLI will prompt for this on stdin. | ||||||
|  |  | ||||||
|   username=<string> |   username=<string> | ||||||
|       LDAP username to use for authentication. |       LDAP username to use for authentication. | ||||||
| @@ -89,3 +93,7 @@ func usernameFromEnv() string { | |||||||
| 	} | 	} | ||||||
| 	return "" | 	return "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func passwordFromEnv() string { | ||||||
|  | 	return os.Getenv("VAULT_LDAP_PASSWORD") | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								changelog/18225.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								changelog/18225.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | ```release-note:improvement | ||||||
|  | auth/ldap: allow providing the LDAP password via an env var when authenticating via the CLI | ||||||
|  | ``` | ||||||
		Reference in New Issue
	
	Block a user
	 Jakob Beckmann
					Jakob Beckmann