Skip to content

Commit

Permalink
Merge pull request #66 from reubenmiller/fix-skip-basic-auth-if-empty
Browse files Browse the repository at this point in the history
fix: don't set basic auth header if username or password is empty
  • Loading branch information
reubenmiller authored Jun 15, 2024
2 parents 756e2d8 + a65c45b commit 91b53e9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/c8y/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,13 @@ func (c *Client) SetBasicAuthorization(req *http.Request) {
} else {
headerUsername = c.Username
}
Logger.Infof("Current username: %s", c.HideSensitiveInformationIfActive(headerUsername))
req.SetBasicAuth(headerUsername, c.Password)

if headerUsername != "" && c.Password != "" {
Logger.Infof("Current username: %s", c.HideSensitiveInformationIfActive(headerUsername))
req.SetBasicAuth(headerUsername, c.Password)
} else {
Logger.Debug("Ignoring basic authorization header as either username or password is empty")
}
}

// SetAuthorization sets the configured authorization to the given request. By default it will set the Basic Authorization header
Expand Down

0 comments on commit 91b53e9

Please sign in to comment.