Skip to content
Playground(another site)

bynk.http.stream_body_signature

Error A route with a streamed body has a Signature actor, which verifies an HMAC over the whole body first.

A Signature actor checks an HMAC over the whole request body before the handler runs, so the body has to be held in full. A streamed body is read by the handler afterwards, a chunk at a time, and could not have been verified. Take body: Bytes on a signed route (a webhook, say), or sign the head (a header or the path) and verify the content another way.

Example

actor Hook { auth = Signature(secret = "HOOK_SECRET", header = "X-Signature") }
@raw(contentType: "application/octet-stream")
@limit(maxBody: 1_000_000)
on POST("/hook") (body: Stream[Bytes]) -> Effect[HttpResult[()]] by h: Hook { … } // ✗ unverifiable
@raw(contentType: "application/octet-stream")
@limit(maxBody: 1_000_000)
on POST("/hook") (body: Bytes) -> Effect[HttpResult[()]] by h: Hook { … } // ✓

In the Book

See also

  • Every code in its category, HTTP, on the diagnostic index.
  • bynk explain bynk.http.stream_body_signature shows the same from the installed toolchain, without a network.