diff --git a/CHANGELOG.md b/CHANGELOG.md index d0af106..1854df7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [v0.2.1] +- Removed request from logging statements + ## [v0.2.0] - Added checks - Added configurable behavior on a key not found in `enforcer` @@ -21,7 +24,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added constructor, enforcer, and listener alice decorators - Basic code and structure established -[Unreleased]: https://github.com/Comcast/comcast-bascule/compare/v0.2.0...HEAD +[Unreleased]: https://github.com/Comcast/comcast-bascule/compare/v0.2.1...HEAD +[v0.2.1]: https://github.com/Comcast/comcast-bascule/compare/0.2.0...v0.2.1 [v0.2.0]: https://github.com/Comcast/comcast-bascule/compare/0.1.1...v0.2.0 [v0.1.1]: https://github.com/Comcast/comcast-bascule/compare/0.1.0...v0.1.1 [v0.1.0]: https://github.com/Comcast/comcast-bascule/compare/0.0.0...v0.1.0 diff --git a/bascule/basculehttp/constructor.go b/bascule/basculehttp/constructor.go index 1646192..4b5d2c0 100644 --- a/bascule/basculehttp/constructor.go +++ b/bascule/basculehttp/constructor.go @@ -28,7 +28,7 @@ func (c *constructor) decorate(next http.Handler) http.Handler { } authorization := request.Header.Get(c.headerName) if len(authorization) == 0 { - logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, "no authorization header", "request", request) + logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, "no authorization header") response.WriteHeader(http.StatusForbidden) return } @@ -36,7 +36,7 @@ func (c *constructor) decorate(next http.Handler) http.Handler { i := strings.IndexByte(authorization, ' ') if i < 1 { logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, "unexpected authorization header value", - "request", request, "auth", authorization) + "auth", authorization) response.WriteHeader(http.StatusBadRequest) return } @@ -47,8 +47,8 @@ func (c *constructor) decorate(next http.Handler) http.Handler { tf, supported := c.authorizations[key] if !supported { - logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, "key not supported", "request", request, - "key", key, "auth", authorization[i+1:]) + logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, "key not supported", "key", key, + "auth", authorization[i+1:]) response.WriteHeader(http.StatusForbidden) return } @@ -56,8 +56,8 @@ func (c *constructor) decorate(next http.Handler) http.Handler { ctx := request.Context() token, err := tf.ParseAndValidate(ctx, request, key, authorization[i+1:]) if err != nil { - logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, err.Error(), "request", request, - "key", key, "auth", authorization[i+1:]) + logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, err.Error(), "key", key, + "auth", authorization[i+1:]) WriteResponse(response, http.StatusUnauthorized, err) return } @@ -69,7 +69,7 @@ func (c *constructor) decorate(next http.Handler) http.Handler { Token: token, }, ) - logger.Log(level.Key(), level.DebugValue(), "msg", "authentication added to context", "request", request, + logger.Log(level.Key(), level.DebugValue(), "msg", "authentication added to context", "token", token, "key", key) next.ServeHTTP(response, request.WithContext(ctx)) diff --git a/bascule/basculehttp/enforcer.go b/bascule/basculehttp/enforcer.go index e095d25..e841ab2 100644 --- a/bascule/basculehttp/enforcer.go +++ b/bascule/basculehttp/enforcer.go @@ -33,15 +33,15 @@ func (e *enforcer) decorate(next http.Handler) http.Handler { } auth, ok := bascule.FromContext(ctx) if !ok { - logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, "no authentication found", - "request", request) + logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, "no authentication found") response.WriteHeader(http.StatusForbidden) return } rules, ok := e.rules[auth.Authorization] if !ok { logger.Log(level.Key(), level.ErrorValue(), - bascule.ErrorKey, "no rules found for authorization", "request", request) + bascule.ErrorKey, "no rules found for authorization", "rules", rules, + "authorization", auth.Authorization, "behavior", e.notFoundBehavior) switch e.notFoundBehavior { case Forbid: response.WriteHeader(http.StatusForbidden) @@ -61,14 +61,12 @@ func (e *enforcer) decorate(next http.Handler) http.Handler { errs = append(errs, e.Error()) } } - logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, errs, - "request", request) + logger.Log(level.Key(), level.ErrorValue(), bascule.ErrorKey, errs) WriteResponse(response, http.StatusUnauthorized, err) return } } - logger.Log(level.Key(), level.DebugValue(), "msg", "authentication accepted by enforcer", - "request", request) + logger.Log(level.Key(), level.DebugValue(), "msg", "authentication accepted by enforcer") next.ServeHTTP(response, request) }) }