Skip to content

aws-signing: add es and glacier for payloads special treatment#12020

Merged
mattklein123 merged 11 commits into
envoyproxy:masterfrom
azihsoyn:aws-request-signing-for-ess
Jul 15, 2020
Merged

aws-signing: add es and glacier for payloads special treatment#12020
mattklein123 merged 11 commits into
envoyproxy:masterfrom
azihsoyn:aws-request-signing-for-ess

Conversation

@azihsoyn

@azihsoyn azihsoyn commented Jul 10, 2020

Copy link
Copy Markdown
Contributor

Commit Message: aws-signing: add elasticsearch and glacier for payloads special treatment
Additional Description:

I found aws_request_signing for elasticsearch service failed in POST.
ESS too needs x-amz-content-sha256 like s3, so I added service_name es ( and gracier too ).

https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-request-signing.html
https://docs.aws.amazon.com/amazonglacier/latest/dev/amazon-glacier-signing-requests.html

Risk Level: Low
Testing: yes
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: azihsoyn azihsoyn@gmail.com

@azihsoyn azihsoyn requested a review from mattklein123 as a code owner July 10, 2020 05:00
Signed-off-by: azihsoyn <azihsoyn@gmail.com>

@dio dio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A request for pasting the link to the doc inline. Plus, could you add test for those cases, here: test/extensions/common/aws/signer_impl_test.cc? Probably very similar with SignHeadersS3.

Comment thread source/extensions/common/aws/signer_impl.cc Outdated
Signed-off-by: azihsoyn <azihsoyn@gmail.com>
@azihsoyn azihsoyn requested a review from dio July 10, 2020 05:54
azihsoyn added 4 commits July 10, 2020 14:55
Signed-off-by: azihsoyn <azihsoyn@gmail.com>
Signed-off-by: azihsoyn <azihsoyn@gmail.com>
Signed-off-by: azihsoyn <azihsoyn@gmail.com>
Signed-off-by: azihsoyn <azihsoyn@gmail.com>
}

// Verify signing headers for es
TEST_F(SignerImplTest, SignHeadersES) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think having a helper here will be helpful? For example: SignerImplTest::expectSignHeaders(absl::string_view service_name, absl::string_view signature) with the service name and the expected signature as params.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added expectSignHeaders. 😄

Signed-off-by: azihsoyn <azihsoyn@gmail.com>
@dio dio changed the title aws-signing: add es and gracier for payloads special treatment aws-signing: add es and glacier for payloads special treatment Jul 10, 2020

@dio dio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A couple of super nits!

// https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
// ES:
// https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-request-signing.html
// Gracier:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. Glacier?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱
fixed it.
thx.

if (service_name_ == "s3") {
// S3, Gracier, ES payloads require special treatment.
// S3:
// https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ends with ".".

headers.get(Http::CustomHeaders::get().Authorization)->value().getStringView());
EXPECT_EQ(SignatureConstants::get().HashedEmptyString,
headers.get(SignatureHeaders::get().ContentSha256)->value().getStringView());
// Verify signing headers for services

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a period at the end of the sentence. Thanks!

Comment thread tools/spelling/spelling_dictionary.txt Outdated
GETting
GLB
GOAWAY
Gracier

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need to add "Glacier".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops...
Sorry, I fix soon.

@dio

dio commented Jul 10, 2020

Copy link
Copy Markdown
Member

/assign @marcomagdy
/assign @rgs1

Signed-off-by: azihsoyn <azihsoyn@gmail.com>
@azihsoyn azihsoyn requested a review from dio July 13, 2020 02:39

@dio dio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing.

// https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-request-signing.html.
// Glacier:
// https://docs.aws.amazon.com/amazonglacier/latest/dev/amazon-glacier-signing-requests.html.
if (service_name_ == "s3" || service_name_ == "glacier" || service_name_ == "es") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I think we can have this decision at initialization. Let's have a const bool member variable (not sure about the name, e.g. require_special_treatment_). We can initialize that bool with require_special_treatment_(service_name_ == "s3" || service_name_ == "glacier" || service_name_ == "es") and use that here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this as you intended?
@dio

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline here, then I think we're good.

azihsoyn added 2 commits July 13, 2020 14:44
Signed-off-by: azihsoyn <azihsoyn@gmail.com>
Signed-off-by: azihsoyn <azihsoyn@gmail.com>
@dio

dio commented Jul 13, 2020

Copy link
Copy Markdown
Member

GitHub is experiencing problems, I think mostly on serving archives. So let's wait until it is resolved then I'll restart the build. https://www.githubstatus.com/incidents/j597fw8kv04c

@dio

dio commented Jul 13, 2020

Copy link
Copy Markdown
Member

/azp run envoy-presubmit

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@dio

dio commented Jul 13, 2020

Copy link
Copy Markdown
Member

/retest

@repokitteh-read-only

Copy link
Copy Markdown

🔨 rebuilding ci/circleci: api (failed build)
🔨 rebuilding ci/circleci: go_control_plane_mirror (failed build)

🐱

Caused by: a #12020 (comment) was created by @dio.

see: more, trace.

dio
dio previously approved these changes Jul 13, 2020

@dio dio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +85 to +86
const bool require_content_hash_{service_name_ == "s3" || service_name_ == "glacier" ||
service_name_ == "es"};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if the initialization has logic, then it's better to put it in the ctor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


void expectSignHeaders(absl::string_view service_name, absl::string_view signature,
absl::string_view payload) {
auto* credentials_provider = new NiceMock<MockCredentialsProvider>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why use new and then create a shared_ptr later?
This should should be:
CredentialsProviderSharedPtr credentials_provider = std::make_shared<NiceMock<MockCredentialsProvider>>();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe no member named 'gmock_getCredentials' in 'Envoy::Extensions::Common::Aws::CredentialsProvider'

Comment thread tools/spelling/spelling_dictionary.txt Outdated
GETting
GLB
GOAWAY
Glacier

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Glacier' shouldn't need to be in this file. You had to add it probably because it was misspelled earlier?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was.

Signed-off-by: azihsoyn <azihsoyn@gmail.com>

@dio dio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mattklein123 mattklein123 merged commit 0e6cff3 into envoyproxy:master Jul 15, 2020
@azihsoyn azihsoyn deleted the aws-request-signing-for-ess branch July 15, 2020 23:42
@azihsoyn

Copy link
Copy Markdown
Contributor Author

Thank you for the review!

KBaichoo pushed a commit to KBaichoo/envoy that referenced this pull request Jul 30, 2020
…proxy#12020)

Signed-off-by: azihsoyn <azihsoyn@gmail.com>
Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
…proxy#12020)

Signed-off-by: azihsoyn <azihsoyn@gmail.com>
Signed-off-by: scheler <santosh.cheler@appdynamics.com>
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 this pull request may close these issues.

5 participants