Streaming signature validation - #11
Conversation
…ince we do not need the body etc
|
I’m traveling today, but will hopefully have a chance to look at this while I’m in the air (airplane WiFi willing). |
|
No need for a rush, I kind of went on some side-quests, apologies |
|
FYI, I am working on this. Exploring how a few things might integrate with it, which is what's taking so long. |
|
I love the spooled tempfile/bufferedbody work! However, I'm not sure that having separate I'm thinking of keeping the Just for my own reference, the cases we need to handle are:
|
|
In my codebase I've got a check for streaming bodies: // Check if this is a streaming/chunked request
let is_streaming = if let Some(content_sha256) = parts.headers.get(X_AMZ_CONTENT_SHA256) {
if let Ok(sha_str) = content_sha256.to_str() {
sha_str.starts_with("STREAMING-") || sha_str == "UNSIGNED-PAYLOAD"
} else {
false
}
} else {
false
};which then goes off to handle verification for streaming/non streaming bodies |
|
@yaleman Would it be useful to move this logic into scratchstack-aws-signature, or would you expect others writing similar services to want to handle it themselves? (I can make arguments in my head either way...) |
|
It seems totally fine to move it in, but still leave the options open to use the downstream calls for testing/other uses 😄 Making things easier for folks makes sense, it's a pretty messy thing to implement! |
|
For what it's worth my is_streaming_request got pulled out into its own function because it got bigger than the original: |
|
I've been traveling a lot, but have been working on validating that the error codes/messages here match AWS' behavior (similar to the existing documentation I have. My previous code for this was a bit of a mess, so I've begun reorganizing it here: https://github.com/dacut/aws-auth-flow-tester I've discovered that AWS has changed what they report back for certain cases, so the existing diagram and code is no longer correct. It looks like AWS has taken a renewed interest in formalizing some implicit SigV4 behaviors (e.g. https://github.com/aws-samples/sigv4-signing-examples), possibly as part of publicly documenting SigV4a. |
|
That's great that they're finally documenting some of their things for better interoperability 😄 |
|
This ends up being a lot more involved than I had expected once you start accounting for other S3 APIs that also have PUT request bodies. Trying to account for some of the particular S3 behaviors (when to return errors, for example) starts bringing a lot of S3 behavior into this crate that ... well, probably belongs in the S3-like service itself. In particular, some of this requires un-chunking the I'm going to take a different approach and provide the primitives necessary for an S3-like service to perform validation. This will have two separate functions:
|
|
Makes sense, it's a very messy thing to support 😄 |
Ref #10 this is an initial run on doing validation.
It looks pretty horrible but you know the internals of your lib better than I do, and I didn't know how far I should chase optimising things... it's behind the feature "streaming" for now. I'm not precious about feedback so am happy to do whatever 😄