Remove basic auth headers from logs (#1974)
This commit is contained in:
parent
a45e240253
commit
5735ab6515
5 changed files with 15 additions and 4 deletions
|
|
@ -84,6 +84,7 @@ func NewShelly(uri, user, password string, channel int, standbypower float64) (*
|
|||
// https://shelly-api-docs.shelly.cloud/gen1/#shelly-family-overview
|
||||
c.uri = util.DefaultScheme(uri, "http")
|
||||
if user != "" {
|
||||
log.Redact(transport.BasicAuthHeader(user, password))
|
||||
c.Client.Transport = transport.BasicAuth(user, password, c.Client.Transport)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ func NewDiscovergyFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
log := util.NewLogger("discgy").Redact(cc.User, cc.Password, cc.Meter)
|
||||
basicAuth := transport.BasicAuthHeader(cc.User, cc.Password)
|
||||
|
||||
log := util.NewLogger("discgy").Redact(cc.User, cc.Password, cc.Meter, basicAuth)
|
||||
|
||||
client := request.NewHelper(log)
|
||||
client.Transport = transport.BasicAuth(cc.User, cc.Password, client.Transport)
|
||||
|
|
|
|||
|
|
@ -201,6 +201,9 @@ func (p *HTTP) WithScript(vm, script string) (*HTTP, error) {
|
|||
func (p *HTTP) WithAuth(typ, user, password string) (*HTTP, error) {
|
||||
switch strings.ToLower(typ) {
|
||||
case "basic":
|
||||
basicAuth := transport.BasicAuthHeader(user, password)
|
||||
log.Redact(basicAuth)
|
||||
|
||||
p.Client.Transport = transport.BasicAuth(user, password, p.Client.Transport)
|
||||
case "digest":
|
||||
p.Client.Transport = digest.NewTransport(user, password, p.Client.Transport)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,10 @@ func NewSocketProviderFromConfig(other map[string]interface{}) (IntProvider, err
|
|||
|
||||
// handle basic auth
|
||||
if cc.Auth.Type != "" {
|
||||
p.headers["Authorization"] = transport.BasicAuthHeader(cc.Auth.User, cc.Auth.Password)
|
||||
basicAuth := transport.BasicAuthHeader(cc.Auth.User, cc.Auth.Password)
|
||||
log.Redact(basicAuth)
|
||||
|
||||
p.headers["Authorization"] = basicAuth
|
||||
}
|
||||
|
||||
// ignore the self signed certificate
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ func NewVolvoFromConfig(other map[string]interface{}) (api.Vehicle, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
log := util.NewLogger("volvo").Redact(cc.User, cc.Password, cc.VIN)
|
||||
basicAuth := transport.BasicAuthHeader(cc.User, cc.Password)
|
||||
|
||||
log := util.NewLogger("volvo").Redact(cc.User, cc.Password, cc.VIN, basicAuth)
|
||||
|
||||
v := &Volvo{
|
||||
embed: &cc.embed,
|
||||
|
|
@ -49,7 +51,7 @@ func NewVolvoFromConfig(other map[string]interface{}) (api.Vehicle, error) {
|
|||
v.Client.Transport = &transport.Decorator{
|
||||
Base: v.Client.Transport,
|
||||
Decorator: transport.DecorateHeaders(map[string]string{
|
||||
"Authorization": transport.BasicAuthHeader(cc.User, cc.Password),
|
||||
"Authorization": basicAuth,
|
||||
"Content-Type": "application/json",
|
||||
"X-Device-Id": "Device",
|
||||
"X-OS-Type": "Android",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue