Skip to content

Add S3-style streaming validation#17

Merged
dacut merged 10 commits intomainfrom
streaming-sig2
Feb 11, 2026
Merged

Add S3-style streaming validation#17
dacut merged 10 commits intomainfrom
streaming-sig2

Conversation

@dacut
Copy link
Copy Markdown
Owner

@dacut dacut commented Feb 11, 2026

This adds a new function, sigv4_validate_streaming_headers, that is used to validate the headers of a streaming request. This is intended to be called after the headers have been read but before the body has been read, allowing for short-circuiting Expect: 100-Continue style requests when the headers are either malformed or incorrectly signed.

sigv4_validate_streaming_headers returns a new type, StreamingSignatureState, that has its own method, sigv4_validate_streaming_chunk, used to validate each chunk of an amz-chunked body. This must be called for each chunk, including the final, empty, terminating chunk.

I have not yet considered how this works with trailers.

dacut added 3 commits February 3, 2026 11:27
This adds an intermediate type, StreamingSignatureState, used to hold
the ongoing state of the signature validation across multiple chunks.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for validating SigV4 “amz-chunked” streaming requests by splitting validation into an initial header check (before reading the body) and per-chunk signature verification.

Changes:

  • Introduces sigv4_validate_streaming_headers and StreamingSignatureState::sigv4_validate_streaming_chunk for S3-style streaming signature validation.
  • Refactors IntoRequestBytes into a new body module and exposes it at the crate root.
  • Extends SignatureOptions with allowed_mismatch and adds/renames several SigV4/S3-related constants and error variants.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/signature.rs Adds streaming header + chunk validation APIs; adds allowed_mismatch; adds new streaming tests.
src/canonical.rs Adds from_request_and_body_hash to canonicalize without reading the body.
src/auth.rs Adds validate_signature_with_key helper and exposes some internal fields for streaming state construction.
src/body.rs New module containing IntoRequestBytes and basic implementations.
src/lib.rs Wires in body module and re-exports it.
src/signing_key.rs Adjusts doc link formatting and makes signing_key field pub(crate) for internal moves.
src/error.rs Adds new SignatureError variants and mappings.
src/constants.rs Adds new error codes/messages and S3 streaming-related constants; renames unsigned payload constant.
Cargo.toml Adds streaming feature, http-body dependency, and optional tokio.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Cargo.toml Outdated
Comment thread Cargo.toml Outdated
Comment thread src/canonical.rs Outdated
Comment thread src/signature.rs
Comment thread src/signature.rs
Comment thread src/signature.rs
Comment thread src/signature.rs Outdated
Comment thread src/signature.rs Outdated
@dacut dacut merged commit cff44d9 into main Feb 11, 2026
1 check passed
@dacut dacut deleted the streaming-sig2 branch February 11, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants