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

Add a possibility to send API requests using AWS credentials with AWS signature calculation #3944

Open
MarynaBelskayaA opened this issue May 16, 2023 · 0 comments
Labels
feature New feature or request

Comments

@MarynaBelskayaA
Copy link

MarynaBelskayaA commented May 16, 2023

I need a possibility to send Amazon Web Services requests.
For this purpose there should be an option to create an authentication header for AWS request with proper calculated AWS Signature

As an option,
A new step can be implemented to generate authentication header and calculate AWS signature
like

When I generate authentication header for AWS request and save it to $scopes variable `$variableName`:$parameters

Authentication header, created as a result of this step

  1. should be in format:
    AWS4-HMAC-SHA256 Credential={AWSKEY}/20230515/{region}/{aws_service}/aws4_request, SignedHeaders=host;x-amz-date, Signature={signature}
  2. and can be used in as a usual header in the
    When I set request headers:$headers step

Also a variable with timestamp value should be implicitly saved on STORY level to use it further in the requests, e.g.
${timestampRequest} with value 20230516T091931Z

Example:

When I generate authentication header for AWS request and save it to SCENARIO variable `awsAuth`:
|AWSAccessKey| AKABIAXENAAGRAATEST|
|SecretKey| JKTdymTaduEDZtiGTest|
|AWSRegion|us-east-1|
|Service Name|execute-api|

--Result of the previous step will be a variable ${awsAuth} with the value AWS4-HMAC-SHA256 Credential=AKABIAXENAAGRAATEST/20230516/us-east-1/execute-api/aws4_request, SignedHeaders=host;x-amz-date, Signature={signature}
-- Also implicitly a variable with timestamp value should be saved on STORY level to use it further in the requests, e.g.
${timestampRequest} with value 20230516T091931Z

When I set request headers:
|x-api-key| {x_api_key}|
|X-Amz-Date| ${timestampRequest}|
|Authorization| ${awsAuth} |
|X-Amz-Security-Token|only for temporary security credentials |

When I execute HTTP GET request for resource with URL `https://{restapi_id}.{aws_service}.{region}.amazonaws.com/{stage_name}`

Example of curl:
Note: today's date is 20230516

curl --location 'https://{restapi_id}.execute-api.{region}.amazonaws.com/{stage_name}' \
--header 'x-api-key: {x_api_key}' \
--header 'X-Amz-Date: 20230516T091931Z' \
--header 'Authorization: AWS4-HMAC-SHA256 Credential={AWSKEY}/20230516/{region}/execute-api/aws4_request, SignedHeaders=host;x-amz-date, Signature={signature}'

AWS uses a custom HTTP scheme based on a keyed-HMAC (Hash Message Authentication Code) for authentication.
The official AWS Signature documentation provides more details:

Useful links:
https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html

https://github.com/aws/aws-sdk-java-v2/blob/master/core/auth/src/main/java/software/amazon/awssdk/auth/signer/internal/BaseAws4Signer.java

 https://github.com/Biruntha/AmazonEC2_Examples/blob/master/AWS_EC2_Example2/src/main/java/com/aws/ec2/AWSSignatureV4Generator.java

https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-examples-using-sdks.html

https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html

https://github.com/postmanlabs/postman-docs/blob/e4b6d9ee860a529e2532b26674e795de52c49c2c/src/pages/docs/sending-requests/authorization.md?plain=1#L420

https://docs.aws.amazon.com/AmazonS3/latest/userguide/RESTAuthentication.html

https://github.com/postmanlabs/postman-collection/blob/1bc172eea982f9aa78035ff757036d189fbe7ea4/test/unit/request-auth.test.js

https://github.com/postmanlabs/postman-collection/blob/1bc172eea982f9aa78035ff757036d189fbe7ea4/lib/collection/request-auth/awsv4.js

https://stackoverflow.com/questions/35985931/how-to-generate-signature-in-aws-from-java

@MarynaBelskayaA MarynaBelskayaA added the feature New feature or request label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant