feat: Support MD5 and SCRAM-SHA-256 password encryption for PostgreSQL connection#111
Merged
Conversation
…L connection - Add PasswordEncryption field to PostgreSQLConfig (internal/config/config.go) - Modify NewConnection to support password_encryption parameter (internal/postgres/connection.go) - Update config.example.yml with password_encryption example - Support three modes: md5, scram-sha-256, auto (default) - Improve compatibility with different PostgreSQL server configurations Related to issue #110 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds support for different PostgreSQL password encryption methods (MD5 and SCRAM-SHA-256) to improve compatibility with different PostgreSQL server configurations.
Changes
1. Configuration (
internal/config/config.go)PasswordEncryptionfield toPostgreSQLConfigstructmd5,scram-sha-256,auto(default)2. Connection Manager (
internal/postgres/connection.go)NewConnectionfunction to appendpassword_encryptionparameter to connection string3. Example Configuration (
config.example.yml)password_encryption: autoconfiguration exampleMotivation
PostgreSQL 10+ uses SCRAM-SHA-256 as the default password encryption method, which is more secure than the traditional MD5 method. However, some environments may still use MD5 for compatibility reasons. This change allows users to explicitly specify which encryption method to use, preventing authentication failures due to encryption method mismatches.
Usage Example
Testing
go build -o mysql2pg ./cmd/)go vetpasses without warningsRelated Issue
Closes #110
References