mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 10:37:56 +00:00 
			
		
		
		
	VAULT-13614 Support SCRAM-SHA-256 encrypted passwords for PostgreSQL (#19616)
This commit is contained in:
		
							
								
								
									
										25
									
								
								plugins/database/postgresql/passwordauthentication.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								plugins/database/postgresql/passwordauthentication.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| package postgresql | ||||
|  | ||||
| import "fmt" | ||||
|  | ||||
| // passwordAuthentication determines whether to send passwords in plaintext (password) or hashed (scram-sha-256). | ||||
| type passwordAuthentication string | ||||
|  | ||||
| var ( | ||||
| 	// passwordAuthenticationPassword is the default. If set, passwords will be sent to PostgreSQL in plain text. | ||||
| 	passwordAuthenticationPassword    passwordAuthentication = "password" | ||||
| 	passwordAuthenticationSCRAMSHA256 passwordAuthentication = "scram-sha-256" | ||||
| ) | ||||
|  | ||||
| var passwordAuthentications = map[passwordAuthentication]struct{}{ | ||||
| 	passwordAuthenticationSCRAMSHA256: {}, | ||||
| 	passwordAuthenticationPassword:    {}, | ||||
| } | ||||
|  | ||||
| func parsePasswordAuthentication(s string) (passwordAuthentication, error) { | ||||
| 	if _, ok := passwordAuthentications[passwordAuthentication(s)]; !ok { | ||||
| 		return "", fmt.Errorf("'%s' is not a valid password authentication type", s) | ||||
| 	} | ||||
|  | ||||
| 	return passwordAuthentication(s), nil | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Raymond Ho
					Raymond Ho