From a1306ac1063e3afa62047250be7bec046fdfb5cb Mon Sep 17 00:00:00 2001 From: Kristina Spring Date: Mon, 15 Apr 2019 10:50:58 -0700 Subject: [PATCH 1/3] Changed multi error to print all errors --- bascule/error.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bascule/error.go b/bascule/error.go index 82ccfa6..7f1457d 100644 --- a/bascule/error.go +++ b/bascule/error.go @@ -1,5 +1,7 @@ package bascule +import "fmt" + // Error is an optional interface to be implemented by security related errors type Error interface { Cause() error @@ -13,7 +15,11 @@ type MultiError interface { type Errors []error func (e Errors) Error() string { - return "multiple errors" + var errors string + for _, err := range e { + errors = errors + ", " + err.Error() + } + return fmt.Sprintf("multiple errors: [%v]", errors) } func (e Errors) Errors() []error { From 51e51e63790b230ce679e1e2693e9aadb1528a93 Mon Sep 17 00:00:00 2001 From: Kristina Spring Date: Mon, 15 Apr 2019 10:51:16 -0700 Subject: [PATCH 2/3] Added request URL and method to context --- bascule/basculehttp/constructor.go | 4 ++++ bascule/context.go | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bascule/basculehttp/constructor.go b/bascule/basculehttp/constructor.go index 4b5d2c0..a30b64e 100644 --- a/bascule/basculehttp/constructor.go +++ b/bascule/basculehttp/constructor.go @@ -67,6 +67,10 @@ func (c *constructor) decorate(next http.Handler) http.Handler { bascule.Authentication{ Authorization: key, Token: token, + Request: bascule.Request{ + URL: request.URL.EscapedPath(), + Method: request.Method, + }, }, ) logger.Log(level.Key(), level.DebugValue(), "msg", "authentication added to context", diff --git a/bascule/context.go b/bascule/context.go index 87ae3c0..18a9e97 100644 --- a/bascule/context.go +++ b/bascule/context.go @@ -1,6 +1,8 @@ package bascule -import "context" +import ( + "context" +) // Authorization represents the authorization mechanism performed on the token, // e.g. "Basic", "Bearer", etc for HTTP security environments. @@ -10,6 +12,12 @@ type Authorization string type Authentication struct { Authorization Authorization Token Token + Request Request +} + +type Request struct { + URL string + Method string } type authenticationKey struct{} From bc7b5dc856cda64a81652e65adf8874338e2c1a2 Mon Sep 17 00:00:00 2001 From: Kristina Spring Date: Mon, 15 Apr 2019 13:58:43 -0700 Subject: [PATCH 3/3] [skip ci] updated changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1854df7..c7c2412 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [v0.2.2] +- Updated Errors `Error()` function +- Added request URL and method to context + ## [v0.2.1] - Removed request from logging statements @@ -24,7 +28,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.1...HEAD +[Unreleased]: https://github.com/Comcast/comcast-bascule/compare/v0.2.2...HEAD +[v0.2.2]: https://github.com/Comcast/comcast-bascule/compare/0.2.1...v0.2.2 [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