hexagontk / hexagon

Hexagon is a microservices toolkit written in Kotlin. Its purpose is to ease the building of services (Web applications or APIs) that run inside a cloud platform.
https://hexagontk.com
Other
577 stars 98 forks source link

Add AWS request signing callback #408

Open jaguililla opened 3 years ago

jaguililla commented 3 years ago

Create an HTTP callback to sign HTTP requests using the AWS signing request algorithm.

Callbacks already developed in the http/http_server module (on the com/hexagonkt/http/server/callbacks package) can be used as reference for development and testing of such components.

There is also an example of a callback used in the HTTP client as opposed to the callbacks used in the server (the class name is com.hexagonkt.rest.SerializeRequestCallback).

Note that the callback should be of before type and to pass the modified request, the request method should be used instead send.

The callback should be added to the http/rest_tools module on the com.hexagonkt.rest.tools.aws package.

A previous Java implementation can be checked at: https://github.com/jaguililla/sabina/blob/master/bali/src/main/java/co/there4/bali/Aws.java

The callback must pass the most of the AWS signing V4 Test Suite cases, and at least implement the tests included here: https://github.com/jaguililla/sabina/tree/master/bali/src/test/resources/aws-sig-v4-test-suite

Previous Java implementation tests can be found at: https://github.com/jaguililla/sabina/blob/master/bali/src/test/groovy/co/there4/bali/AwsTest.groovy

For information on how to build the project and pass the tests please refer to the contributing guide.

If you have any question or suggestion, please feel free to use this issue's comments to discuss them 🙂

manuelkour commented 6 months ago

Hi! I'd like to work on this issue if it's still up to grab.

jaguililla commented 6 months ago

Absolutely, it's all yours. I'll update the task's status.

Thanks for your cooperation and if you need anything, just write me :)

manuelkour commented 6 months ago

I have a question regarding some of the parameters required to sign an AWS request. (This is the reference from the AWS documentation I've been following so far.) To calculate the signing key, the AWS (secret) access key, region and service are required. Are we expecting the HttpContext passed to the callback to contain these or in what other way could this be done? If there's a misunderstanding on how the callback is supposed to work, could you please show me to the correct part in the documentation to read up on this? Thanks in advance!

jaguililla commented 6 months ago

Ok, as the callback is a class. Could you pass those values as parameters in the constructor?

The user then will be forced to supply values for those parameters at callback instantiation time (at the application start up or routing definition).

The user could fetch those values from environment, configuration files, etc. before passing them to the callback (decoupling the AWS signing from the configuration/environment).

What do you think? does this make sense to you?

manuelkour commented 6 months ago

Passing it to the constructor makes it easy then, thanks!

jaguililla commented 6 months ago

Hello, the Hexagon GitHub organization has been renamed to https://github.com/hexagontk. You will need to change your local clone remotes to reflect this change. Thanks and sorry for the inconvenience.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 3 weeks ago

This issue was closed because it has been stalled for 7 days with no activity.