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

Signing does not work when using variables in URL #13

Open
ludwigm opened this issue Aug 1, 2018 · 8 comments
Open

Signing does not work when using variables in URL #13

ludwigm opened this issue Aug 1, 2018 · 8 comments

Comments

@ludwigm
Copy link

ludwigm commented Aug 1, 2018

Hi,

I found out that the signing of the API calls does not work when using variables in your URL. I get 403 from the API Gateway that the Signature is wrong. More details can be found if the debug mode is switched on with setting DEBUG=* in front of your artillery run.

The API Gateway responses are the following:

The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.

When debugging it can be seen that requestParams only contains the original URL with the placeholder variable:

addAmazonSignatureV4: function(serviceName, requestParams, context, ee, callback) {
            var requetUrl = requestParams.uri || requestParams.url;

It seems that the templating and filling of variables is not done and the originally specified URL is used for signing which leads to a wrong signature.

Example config:

  config:
    plugins:
      aws-sigv4:
        serviceName: "execute-api"
    target: 'https://api.p.example.com/v1'
    defaults:
      headers: 
        x-api-key: 'sample'
    payload:
      path: "recentcontent.csv"
      fields:
        - contentId
    phases:
        - duration: 30
          arrivalRate: 1
  scenarios:
    - name: "Default test"
      beforeRequest: "addAmazonSignatureV4"
      flow:
      - log: "Current contentId is set to: {{ contentId }}"
      - get:
          url: "/example?configId=example&contentId={{ contentId }}"
@erikerikson
Copy link
Contributor

Thank you for reporting this @ludwigm

Hassy changed this behavior in May: artilleryio/artillery-core@405b78e#diff-08c61297a57965f46e6bf18087f2066b

I am following up there.

erikerikson referenced this issue in artilleryio/artillery-core Aug 1, 2018
This change allows beforeRequest hooks to create context vars,
which will then be used in the templates of the current request
as expected.
@erikerikson
Copy link
Contributor

I have escalated this to artilleryio/artillery#544.

@erikerikson
Copy link
Contributor

For anyone impacted by this issue, @galvinhsiu has offered a workaround on #14

@kvaibhawa
Copy link

@erikerikson I run into similar issue signature getting messed up due to later variable substitution than request validation.

@gwsii
Copy link
Member

gwsii commented Nov 18, 2020

This issue ought to be resolved with release version 0.0.5

@kvaibhawa
Copy link

kvaibhawa commented Nov 18, 2020

@gwsii I currently on "artillery-plugin-aws-sigv4": "0.0.5". Still facing this issue. Any suggestions?

@mstoyanovv
Copy link

mstoyanovv commented Aug 4, 2021

This issue ought to be resolved with release version 0.0.5

Workaround is to use the changes from this pr - https://github.com/Nordstrom/artillery-plugin-aws-sigv4/pull/17/files
I don't know why it was closed and not merged but it solves the issue for me.

@npopov-d3
Copy link

I second mstoyanovv, please merge the fix above, it was very confusing navigating various open pull requests and comments to finally arrive here finding this unmerged fix.

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 a pull request may close this issue.

6 participants