Skip to content
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
1 change: 1 addition & 0 deletions databaseConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ type DatabaseConfig struct {
DatabaseUser string
DatabasePass string
DatabaseName string
DisableSSL bool
}
6 changes: 5 additions & 1 deletion getDatabaseConnectionString.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ import "fmt"
// GetDatabaseConnectionString constructs and returns a PostgreSQL connection string
// based on the current active database configuration.
func GetDatabaseConnectionString() string {
return fmt.Sprintf("postgres://%s:%s@%s:%d/%s", activeConfig.DatabaseUser, activeConfig.DatabasePass, activeConfig.DatabaseHost, activeConfig.DatabasePort, activeConfig.DatabaseName)
dbString := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", activeConfig.DatabaseUser, activeConfig.DatabasePass, activeConfig.DatabaseHost, activeConfig.DatabasePort, activeConfig.DatabaseName)
if activeConfig.DisableSSL {
dbString += "?sslmode=disable"
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When DisableSSL is false, no sslmode parameter is added to the connection string. This means the default behavior depends on the PostgreSQL driver's default, which may vary. Consider explicitly setting sslmode=require (or another appropriate mode like sslmode=verify-full) when SSL is enabled to ensure consistent and secure behavior across different environments.

Suggested change
dbString += "?sslmode=disable"
dbString += "?sslmode=disable"
} else {
dbString += "?sslmode=require"

Copilot uses AI. Check for mistakes.
}
return dbString
}
1 change: 1 addition & 0 deletions loadConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func LoadConfig() error {
loadedConfig.DatabaseUser = os.Getenv("DATABASE_CONFIG_DB_USER")
loadedConfig.DatabasePass = os.Getenv("DATABASE_CONFIG_DB_PASS")
loadedConfig.DatabaseName = os.Getenv("DATABASE_CONFIG_DB_NAME")
loadedConfig.DisableSSL = os.Getenv("DATABASE_CONFIG_DISABLE_SSL") == "true"

if loadedConfig.DatabasePort == 0 {
loadedConfig.DatabasePort = 5432 // default port
Expand Down
Loading