Redact database URL passwords from logs
- Add SanitizeDatabaseURL() function to config package that redacts passwords from database connection URLs - Handles various URL formats: postgresql, mysql, etc. - Correctly handles passwords containing special characters including @ symbols by using LastIndex - Update startup logging in cmd/server/main.go to use sanitized database URL - Add comprehensive tests covering various URL formats and edge cases This ensures sensitive database credentials are not exposed in application logs.
This commit is contained in:
+1
-1
@@ -103,7 +103,7 @@ func main() {
|
||||
if err != nil {
|
||||
logger.Fatalf("Failed to create database key store: %v", err)
|
||||
}
|
||||
logger.Infof("Connected to authentication database: %s", cfg.Auth.Database.URL)
|
||||
logger.Infof("Connected to authentication database: %s", config.SanitizeDatabaseURL(cfg.Auth.Database.URL))
|
||||
} else {
|
||||
logger.Warn("No database configured for authentication - API keys will only be stored in memory")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user