Skip to content

Commit

Permalink
rpc/signing: don't set Content-Length header (#60)
Browse files Browse the repository at this point in the history
* etc: update dev config to use deterministic mailer role name

* rpc/signing: avoid setting Content-Length header
  • Loading branch information
patrislav authored Jul 23, 2024
1 parent 08c8237 commit c71f555
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion etc/waas-auth.dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ QwIDAQAB
region = "ca-central-1"
source = "[email protected]"
source_arn = "arn:aws:ses:ca-central-1:471112647196:identity/sequence.app"
access_role_arn = "arn:aws:iam::471112647196:role/dev-mailer-c797a23"
access_role_arn = "arn:aws:iam::471112647196:role/dev-mailer"

[builder]
base_url = "https://dev-api.sequence.build"
Expand Down
17 changes: 9 additions & 8 deletions rpc/signing/http_signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ type httpSignatureBuilder struct {
status int
req *http.Request

label string
fields []string
nonce string
alg Algorithm
label string
fields []string
contentLength int
nonce string
alg Algorithm
}

func generateHTTPSignature(ctx context.Context, signer Signer, body []byte, req *http.Request, resHeader http.Header, status int) error {
Expand Down Expand Up @@ -131,10 +132,8 @@ func (b *httpSignatureBuilder) generate(ctx context.Context) error {
if h.Get("Date") == "" {
h.Add("Date", time.Now().UTC().Format(http.TimeFormat))
}
if h.Get("Content-Length") == "" {
h.Add("Content-Length", strconv.Itoa(contentLen))
}
h.Add("Content-Digest", digest)
b.contentLength = contentLen

sigBytes, err := b.generateSignature(ctx, sigInput)
if err != nil {
Expand Down Expand Up @@ -209,7 +208,7 @@ func (b *httpSignatureBuilder) generateSignature(ctx context.Context, sigParams
}

func (b *httpSignatureBuilder) getFieldValue(key string) string {
switch key {
switch strings.ToLower(key) {
case "@method":
return b.req.Method
case "@path":
Expand All @@ -222,6 +221,8 @@ func (b *httpSignatureBuilder) getFieldValue(key string) string {
return b.req.Host
case "@status":
return strconv.Itoa(b.status)
case "content-length":
return strconv.Itoa(b.contentLength)
default:
return b.header.Get(key)
}
Expand Down

0 comments on commit c71f555

Please sign in to comment.