Skip to content

Commit

Permalink
Merge pull request #127 from Comcast/fix-signature-for-wrp-msgs
Browse files Browse the repository at this point in the history
Fix signature for wrp msgs
  • Loading branch information
schmidtw authored Feb 27, 2019
2 parents bd4baa0 + f015489 commit b95dd8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
-

## [0.1.3] - 2019-02-27
### Changed
- Fix for [issue 126](https://github.com/Comcast/caduceus/issues/126)

## [0.1.2] - 2019-02-21
### Added
- Fix for delivering events as json or msgpack based events [issue 113](https://github.com/Comcast/caduceus/issues/113)
Expand Down Expand Up @@ -38,7 +42,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Initial creation

[Unreleased]: https://github.com/Comcast/caduceus/compare/0.1.2...HEAD
[Unreleased]: https://github.com/Comcast/caduceus/compare/0.1.3...HEAD
[0.1.3]: https://github.com/Comcast/caduceus/compare/0.1.2...0.1.3
[0.1.2]: https://github.com/Comcast/caduceus/compare/0.1.1...0.1.2
[0.1.1]: https://github.com/Comcast/caduceus/compare/0.0.1...0.1.1
[0.0.1]: https://github.com/Comcast/caduceus/compare/0.0.0...0.0.1
8 changes: 4 additions & 4 deletions src/caduceus/outboundSender.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ func (obs *CaduceusOutboundSender) send(secret, acceptType string, msg *wrp.Mess
defer obs.workers.Release()

payload := msg.Payload
body := payload
var payloadReader *bytes.Reader

// Use the internal content type unless the accept type is wrp
Expand All @@ -473,10 +474,9 @@ func (obs *CaduceusOutboundSender) send(secret, acceptType string, msg *wrp.Mess
buffer := bytes.NewBuffer([]byte{})
encoder := wrp.NewEncoder(buffer, wrp.Msgpack)
encoder.Encode(msg)
payloadReader = bytes.NewReader(buffer.Bytes())
default:
payloadReader = bytes.NewReader(payload)
body = buffer.Bytes()
}
payloadReader = bytes.NewReader(body)

req, err := http.NewRequest("POST", obs.id, payloadReader)
if nil != err {
Expand Down Expand Up @@ -505,7 +505,7 @@ func (obs *CaduceusOutboundSender) send(secret, acceptType string, msg *wrp.Mess

if "" != secret {
s := hmac.New(sha1.New, []byte(secret))
s.Write(payload)
s.Write(body)
sig := fmt.Sprintf("sha1=%s", hex.EncodeToString(s.Sum(nil)))
req.Header.Set("X-Webpa-Signature", sig)
}
Expand Down

0 comments on commit b95dd8c

Please sign in to comment.