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(signature-v4): add support to override the set of unsignableHeaders #420

Merged
merged 3 commits into from
Oct 29, 2019
Merged

feat(signature-v4): add support to override the set of unsignableHeaders #420

merged 3 commits into from
Oct 29, 2019

Conversation

ronak2121
Copy link
Contributor

Issue #, if available:
Add support to override the set of unsignableHeaders; in cases where signing those headers (such as user-agent) would be desirable.

Description of changes:
Added a new set of signableHeaders, which is checked for inclusion before the specified header is removed for being an unsignable one.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aws-sdk-js-automation

This comment has been minimized.

@aws-sdk-js-automation

This comment has been minimized.

@trivikr
Copy link
Member

trivikr commented Oct 28, 2019

Relevant discussions from internal issue tracker below.

Findings:

  • signature-v4-node extends from signature-v4 (code)
  • presignRequest function is defined in SignatureV4.ts (code)
  • The header "X-Amz-SignedHeaders" is set in SignatureV4.ts (code)
  • The method getCanonicalHeaderList sorts the headers and joins them with ; (code)
  • The method getCanonicalHeaders returns sign-able headers which are not proxy/sec headers (code)
  • The header user-agent is excluded as it's in ALWAYS_UNSIGNABLE_HEADERS (code)

Proposed accepted solution:

  • Pass "user-agent" as a new option in RequestSigningArguments (code)
  • It can be a set, with a new parameter signableHeaders in SigningArguments.
interface RequestSigningArguments extends SigningArguments {
  /**
   * A set of strings whose members represents headers that cannot be signed.
   * All headers in the provided request will have their names converted to
   * lower case and then checked for existence in the unsignableHeaders set.
   */
  unsignableHeaders?: Set<string>;

  /**
   * A set of strings whose members represents headers that should be signed.
   * All headers in the provided request will have their names converted to
   * lower case before signing.
   */
  signableHeaders?: Set<string>;
}

@trivikr
Copy link
Member

trivikr commented Oct 28, 2019

Other findings:

  • user-agent is skipped by default because of RFC 2616
  • it's legal for a proxy to modify the user agent header, so default signing it is risky

This PR provides a way for customers to explicitly opt-in to signing the user agent header

Co-Authored-By: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
@aws-sdk-js-automation

This comment has been minimized.

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@trivikr trivikr merged commit 8d6b27a into aws:master Oct 29, 2019
@lock
Copy link

lock bot commented Nov 5, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants