1
0
mirror of https://github.com/drakkan/sftpgo.git synced 2025-12-05 22:17:20 +02:00

redact credentials within hooks

go-retryablehttp does not redact credentials, so we still log them
when we use it

https://github.com/hashicorp/go-retryablehttp/pull/133
This commit is contained in:
Nicola Murino
2021-05-12 22:44:17 +02:00
parent fa45c9c138
commit 0540b8780e
7 changed files with 56 additions and 34 deletions

View File

@@ -20,6 +20,7 @@ import (
"io"
"net"
"net/http"
"net/url"
"os"
"path"
"path/filepath"
@@ -566,3 +567,12 @@ func ParseAllowedIPAndRanges(allowed []string) ([]func(net.IP) bool, error) {
return res, nil
}
// GetRedactedURL returns the url redacting the password if any
func GetRedactedURL(rawurl string) string {
u, err := url.Parse(rawurl)
if err != nil {
return rawurl
}
return u.Redacted()
}