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

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 [email protected]

@azihsoyn
azihsoyn requested a review from mattklein123 as a code owner July 10, 2020 05:00

@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.

Signed-off-by: azihsoyn <[email protected]>
@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 <[email protected]>
Signed-off-by: azihsoyn <[email protected]>
Signed-off-by: azihsoyn <[email protected]>
}

// 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 <[email protected]>
@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:

ghost Jul 10, 2020

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?

ghost Jul 10, 2020

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

ghost Jul 10, 2020

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

ghost Jul 10, 2020

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

ghost Jul 10, 2020

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".

ghost Jul 10, 2020

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

ghost commented Jul 10, 2020

Copy link
Copy Markdown
Member

/assign @marcomagdy
/assign @rgs1

Signed-off-by: azihsoyn <[email protected]>
@azihsoyn
azihsoyn requested a review from dio July 13, 2020 02:39

ghost 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") {

ghost Jul 13, 2020

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.

ghost Jul 13, 2020

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

ghost Jul 13, 2020

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

ghost Jul 13, 2020

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

ghost Jul 13, 2020

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
@dio

ghost 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

ghost commented Jul 13, 2020

Copy link
Copy Markdown
Member

/azp run envoy-presubmit

@azure-pipelines

ghost commented Jul 13, 2020

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

@dio

ghost commented Jul 13, 2020

Copy link
Copy Markdown
Member

/retest

@repokitteh-read-only

ghost commented Jul 13, 2020

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

ghost 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"};

ghost Jul 13, 2020

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.

ghost Jul 14, 2020

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>();

ghost Jul 13, 2020

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>>();

ghost Jul 14, 2020

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

ghost Jul 13, 2020

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?

ghost Jul 13, 2020

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 <[email protected]>

ghost 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

ghost commented Jul 15, 2020

Copy link
Copy Markdown
Contributor Author

Thank you for the review!

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