Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide context with app transport signer #119

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jamestelfer
Copy link

Adds the SignWithContext interface that allows implementations that use I/O (e.g. calls to a remote KMS) to use the context of the current request, allowing it to participate in cancellation/timeout as appropriate.

Backwards compatibility is preserved by wrapping a Signer implementation in wrapping SignerWithContextAdapter. The existing Signer interface has been marked as deprecated to signal to implementors of the new implementation.

The existing RSASigner now implements both interfaces, with the Sign method marked as deprecated. This preserves backwards compatibility and avoids requiring an adaptor for the default implementation.

Fixes #117

Adds the "SignWithContext" interface that allows
implementations that use I/O (e.g. calls to a
remote KMS) to use the context of the current
request, allowing it to participate in the
cancellation/timeout as appropriate.
@jamestelfer
Copy link
Author

Note: if the approach in #119 is OK, I'd change this implementation to implement the newer options interface.

Copy link
Collaborator

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

This looks good - thanks!

t.Fatalf("error calling RoundTrip: %v", err)
}

if !check.Captured {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: you can omit this - check.Value will be nil if this is not set, and we're always comparing against a populated want value.

Copy link
Author

Choose a reason for hiding this comment

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

That's quite true. I added this so the test failure was more self explanatory even though it's not strictly necessary. Happy to remove it though, LMK what you think.

appsTransport_test.go Outdated Show resolved Hide resolved
The test doesn't require key variability, so using a simpler type makes a lot of sense.
Copy link
Author

@jamestelfer jamestelfer left a comment

Choose a reason for hiding this comment

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

Marking this for re-review, LMK whether you'd like the explicit test failure message or the implicit behaviour.

@jamestelfer
Copy link
Author

@wlynch / @bradleyfalzon do you have any further refinements or comments on how you would like this PR to proceed?

I'm happy to put some more effort into it if that's what it needs.

@jamestelfer
Copy link
Author

@wlynch / @bradleyfalzon following up on this to see whether or not you'd like me to proceed, and to let you know that I'm still monitoring this PR.

This is not meant to add pressure: I realise we are all busy on other things.

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.

RFC: add a SignerWithContext interface for custom sign implementations
2 participants