Skip to content

Conversation

@nateprewitt
Copy link
Contributor

@nateprewitt nateprewitt commented Mar 13, 2025

This PR is a draft implementation of Event signing in aws-sdk-signers and some temporary scaffolding changes to enable their usage. We have a few spots right now where our implementations don't align nicely. I've added some shims to help test while we discuss a longer term solution.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@nateprewitt nateprewitt force-pushed the sign_event branch 3 times, most recently from 1bb083a to fb46168 Compare March 14, 2025 19:09
@nateprewitt nateprewitt force-pushed the sign_event branch 4 times, most recently from 15240f3 to 0ae0af4 Compare March 19, 2025 01:50
Comment on lines 563 to 564
context.properties["identity"] = identity
context.properties["signer_properties"] = auth_option.signer_properties
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: These should probably use the typed properties.

These are generic and I think something reasonable to always have after auth resolution, so I think we can leave them here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we're entirely refactoring this with Jordon's upcoming work. Ideally we're not doing this at all going forward.

return result

def encode_headers(self, headers: HEADERS_DICT):
def encode_headers(self, headers: HEADERS_DICT) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand why this method builds an internal buffer - but the interface does seem weird. It seems like we could either:

  1. have this as a class method which would construct an instance, call _encode_headers and then return the result. or
  2. Have a private class that handles the build/state, _EventHeaderEncoder which encode_headers would instantiate and return the result from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'd generally agree with this, the encode workflow here is a bit odd. I think we can look at a refactor as follow up, this PR is just fixing the typing issue from the original.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this was intended for streaming out without an intermediary. Then we switched to have an intermediary

@nateprewitt nateprewitt marked this pull request as ready for review March 19, 2025 19:31
@nateprewitt nateprewitt requested a review from a team as a code owner March 19, 2025 19:31
class EventSigner(Protocol):
"""A signer to manage credentials and EventMessages for an Event Stream lifecyle."""

def sign_event(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to move this to the regular signer. We can create a central event dataclass or protocol to give it. That should solve the double initialization problem. That can be later though.

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to track signing state (previous signature) between events so theres some state management. But we could also add previous signature as an input to sign_event and store it in the publisher.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah my original plan had been for this context to be in the Publisher rather than the signer. What we have implemented currently makes that a bit harder. I think raising it a level to let the publisher do the orchestration makes more sense long term though.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can do that without muddying up the interface too much. Just make an event_signer method on the auth scheme class or whatever that's given the entire transport request and returns the signer to use. A stateless signer could just return itself.

nateprewitt and others added 3 commits March 19, 2025 17:51
Co-authored-by: Nate Prewitt <nate.prewitt@gmail.com>
@nateprewitt nateprewitt changed the title [Draft] Event Signing Event Signing Mar 20, 2025
@nateprewitt nateprewitt merged commit 81a7327 into develop Mar 20, 2025
2 checks passed
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.

3 participants