diff --git a/CHANGELOG.md b/CHANGELOG.md index 878782a..602e5df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added + +- Added file template helper function. [#25](https://github.com/elastic/stream/pull/25) + +### Fixed + +- Ensure basic auth and body are only tested if explicitly set. [#28](https://github.com/elastic/stream/pull/28) + ## [0.5.0] - Added option to set up custom buffer size for the log reader. [#22](https://github.com/elastic/stream/pull/22) diff --git a/pkg/httpserver/httpserver.go b/pkg/httpserver/httpserver.go index fd99b87..646e03c 100644 --- a/pkg/httpserver/httpserver.go +++ b/pkg/httpserver/httpserver.go @@ -173,10 +173,19 @@ func newHandlerFromConfig(config *config, logger *zap.SugaredLogger) (http.Handl route.MatcherFunc(func(r *http.Request, rm *mux.RouteMatch) bool { user, password, _ := r.BasicAuth() - return rule.User == user && rule.Password == password + if rule.User != "" && user != rule.User { + return false + } + if rule.Password != "" && password != rule.Password { + return false + } + return true }) route.MatcherFunc(func(r *http.Request, rm *mux.RouteMatch) bool { + if rule.RequestBody == "" { + return true + } body, err := ioutil.ReadAll(r.Body) if err != nil { return false