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

Error some headers are not signed with version 0.7.0 #28

Closed
immavalls opened this issue Jan 2, 2023 · 1 comment · Fixed by #29
Closed

Error some headers are not signed with version 0.7.0 #28

immavalls opened this issue Jan 2, 2023 · 1 comment · Fixed by #29
Assignees
Labels
bug Something isn't working

Comments

@immavalls
Copy link
Contributor

As reported in https://community.k6.io/t/s3serviceerror-using-s3client/5586, version 0.7.0 seems to have introduced an error.

    ERRO[0000] S3ServiceError: There were headers present in the request which were not signed
    running at value (webpack://k6-jslib-aws/./src/internal/s3.ts:289:16(55))
    default at value (webpack://k6-jslib-aws/./src/internal/s3.ts:62:27(40))
        at file:///Users/immavalls/Documents/grafana/github/k6-jslib-aws/examples/s3.js:23:20(3)
        at native  executor=per-vu-iterations scenario=default source=stacktrace

When following the s3 example, with the right credentials, it fails with the previous error.

The same example importing version 0.6.0 (before refactoring to support AWS signature v4 procedure, sign and pre-sign) works:

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.6.0/s3.js';

After some digging, it seems that we need to add the host header in https://github.com/grafana/k6-jslib-aws/blob/main/src/internal/signature.ts#L102.

And we need to fix the test https://github.com/grafana/k6-jslib-aws/blob/main/tests/internal/new_signature.js#L82 adding delete request.hostname. Otherwise, the request is adding the host in the headers.

I've also spotted that we have accessKeyId: this.awsConfig.accessKeyID in https://github.com/grafana/k6-jslib-aws/blob/main/src/internal/s3.ts#L27, and it should be accessKeyId: this.awsConfig.accessKeyId. Otherwise, the AWS4-HMAC-SHA256 Credential is missing the accessKeyId.

@immavalls immavalls added the bug Something isn't working label Jan 2, 2023
@immavalls immavalls self-assigned this Jan 2, 2023
@oleiade
Copy link
Member

oleiade commented Jan 3, 2023

Thanks a lot for reporting this @immavalls 🤝 It concurs with something pointed out by #27.

The change was initially made to align with the official node sdk's test suite, but it seems I must have missed something indeed and would have been better off trusting the docs instead🤦🏻

We need to bring back https://github.com/grafana/k6-jslib-aws/blob/main/src/internal/signature.ts#L102 and adjust the tests, indeed.

Regarding the accessKeyID, good catch! I'll put a fix together, and see what I can do to help Typescript catch this earlier in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants