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

ext_authz: support response headers on OK authorization checks #14514

Merged
merged 26 commits into from
Feb 11, 2021

Conversation

esmet
Copy link
Contributor

@esmet esmet commented Dec 23, 2020

Support adding response headers on OK authorization checks from ext_authz

Commit Message: ext_authz: support response headers on OK authorization checks
Additional Description:
Risk Level: low (opt-in feature, does nothing by default)
Testing: Added code to existing unit tests
Docs Changes: API protos documented
Release Notes: ext_authz: added :ref:response_headers_to_add <envoy_v3_api_field_service.auth.v3.OkHttpResponse.response_headers_to_add> to support sending response headers to downstream clients on OK external authorization checks.
Platform Specific Features:
Fixes #7986

Signed-off-by: John Esmet <john.esmet@gmail.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
API shepherd assignee is @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #14514 was opened by esmet.

see: more, trace.

Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
@esmet
Copy link
Contributor Author

esmet commented Jan 6, 2021

I'm pulling this out of draft to start getting feedback. I still need to take a pass at the docs and see if/how we can document this feature.

@esmet esmet marked this pull request as ready for review January 6, 2021 02:30
@esmet esmet requested a review from dio as a code owner January 6, 2021 02:30
Signed-off-by: John Esmet <john.esmet@gmail.com>
@markdroth
Copy link
Contributor

/lgtm api

@repokitteh-read-only repokitteh-read-only bot removed the api label Jan 6, 2021
@esmet
Copy link
Contributor Author

esmet commented Jan 11, 2021

@dio CI is green and this is now ready for your critical review, if you don't mind :)

Copy link
Member

@dio dio left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Some notes and requesting integration test if possible.

source/extensions/filters/http/ext_authz/ext_authz.h Outdated Show resolved Hide resolved
source/extensions/filters/http/ext_authz/ext_authz.h Outdated Show resolved Hide resolved
api/envoy/service/auth/v3/external_auth.proto Outdated Show resolved Hide resolved
@@ -70,6 +70,7 @@ New Features
* config: added ability to flush stats when the admin's :ref:`/stats endpoint <operations_admin_interface_stats>` is hit instead of on a timer via :ref:`stats_flush_on_admin <envoy_v3_api_field_config.bootstrap.v3.Bootstrap.stats_flush_on_admin>`.
* config: added new runtime feature `envoy.features.enable_all_deprecated_features` that allows the use of all deprecated features.
* crash support: added the ability to dump L4 connection data on crash.
* ext_authz: added :ref:`response_headers_to_add <envoy_v3_api_field_service.auth.v3.OkHttpResponse.response_headers_to_add>` to support sending response headers to downstream clients on OK external authorization checks.
Copy link
Member

@dio dio Jan 20, 2021

Choose a reason for hiding this comment

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

While it is in the same spirit, seems like we have two changes here, for gRPC and HTTP implementation. I'm OK to have this in the same PR. For completeness, we need integration tests, since it involves response from the "external service". WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add another changelog line to capture both the HTTP and gRPC service changes.

I'll look into what it'll take to add an integration test 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took a look and there seems to be an established precedent that other similar features (e.g. allowed_client_headers for HTTP, request_headers_to_add for gRPC, and others) are tested using unit tests and appropriate mocks. I think that if unit tests are OK for those features, they should be good for this one as well. Do you agree?

Having said that, I don't think there are any integration tests for ext_authz (or if there are, I can't find them) so maybe I should look into following up with some work to add those tests down the road. Maybe I'll look at the coverage report to decide if that's worth it.

Copy link
Member

@dio dio Jan 28, 2021

Choose a reason for hiding this comment

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

I think we need to have an integration test to make sure that, for gRPC implementation, when we do sendExtAuthzResponse (this is done by the authorization service) with this response_headers_to_add set, the downstream client receives it.

The same applies to the HTTP one, waitForExtAuthzRequest should provide response header entries that are allowed to be forwarded, and are inserted to response_->headers().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I'll give that a try

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I now see the integration test for ext_authz - don't know how I missed that before.

…n-success

Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
…n-success

Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
…success

Signed-off-by: John Esmet <john.esmet@gmail.com>
…n-success

Signed-off-by: John Esmet <john.esmet@gmail.com>
…success

Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
@dio dio self-assigned this Feb 7, 2021
Signed-off-by: John Esmet <john.esmet@gmail.com>
@esmet
Copy link
Contributor Author

esmet commented Feb 8, 2021

Overall LGTM. Some notes and requesting integration test if possible.

I added an integration test. Please take a look and let me know what you think.

dio
dio previously approved these changes Feb 9, 2021
Copy link
Member

@dio dio left a comment

Choose a reason for hiding this comment

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

Awesome. Thank you!

@@ -626,6 +640,38 @@ TEST_P(ExtAuthzGrpcIntegrationTest, DenyAtDisableWithMetadata) {
expectFilterDisableCheck(/*deny_at_disable=*/true, /*disable_with_metadata=*/true, "403");
}

TEST_P(ExtAuthzGrpcIntegrationTest, DownstreamHeadersOnSuccess) {
XDS_DEPRECATED_FEATURE_TEST_SKIP;
// Set up ext_authz filter
Copy link
Member

Choose a reason for hiding this comment

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

Super nit: Some comment lines missing "." at the end.

const auto expected_headers = TestCommon::makeHeaderValueOption(
{{":status", "200", false}, {"x-downstream-ok", "1", false}, {"x-upstream-ok", "1", false}});
const auto authz_response = TestCommon::makeAuthzResponse(
CheckStatus::OK, Http::Code::OK, "", TestCommon::makeHeaderValueOption({}),
Copy link
Member

Choose a reason for hiding this comment

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

Nit. EMPTY_STRING

@dio
Copy link
Member

dio commented Feb 9, 2021

Asking for @envoyproxy/senior-maintainers review. Probably, @lizan or @htuch. Thank you!

Signed-off-by: John Esmet <john.esmet@gmail.com>
…n-success

Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
@esmet
Copy link
Contributor Author

esmet commented Feb 10, 2021

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #14514 (comment) was created by @esmet.

see: more, trace.

@esmet
Copy link
Contributor Author

esmet commented Feb 11, 2021

@lizan / @htuch friendly poke. CI is 💚 - let me know if you think this is in an OK state to land 👍

@lizan lizan merged commit ac9a263 into envoyproxy:main Feb 11, 2021
@esmet esmet deleted the ext-authz-headers-on-success branch February 24, 2021 21:04
esmet added a commit to datawire/envoy that referenced this pull request Mar 29, 2021
…proxy#14514)

Support adding response headers on OK authorization checks from ext_authz

Commit Message: ext_authz: support response headers on OK authorization checks
Additional Description:
Risk Level: low (opt-in feature, does nothing by default)
Testing: Added code to existing unit tests
Docs Changes: API protos documented
Release Notes: ext_authz: added :ref:`response_headers_to_add <envoy_v3_api_field_service.auth.v3.OkHttpResponse.response_headers_to_add>` to support sending response headers to downstream clients on OK external authorization checks.
Platform Specific Features:
Fixes envoyproxy#7986

Signed-off-by: John Esmet <john.esmet@gmail.com>
esmet added a commit to datawire/envoy that referenced this pull request Apr 16, 2021
…proxy#14514)

Support adding response headers on OK authorization checks from ext_authz

Commit Message: ext_authz: support response headers on OK authorization checks
Additional Description:
Risk Level: low (opt-in feature, does nothing by default)
Testing: Added code to existing unit tests
Docs Changes: API protos documented
Release Notes: ext_authz: added :ref:`response_headers_to_add <envoy_v3_api_field_service.auth.v3.OkHttpResponse.response_headers_to_add>` to support sending response headers to downstream clients on OK external authorization checks.
Platform Specific Features:
Fixes envoyproxy#7986

Signed-off-by: John Esmet <john.esmet@gmail.com>
esmet added a commit to datawire/envoy that referenced this pull request Jun 10, 2021
…proxy#14514)

Support adding response headers on OK authorization checks from ext_authz

Commit Message: ext_authz: support response headers on OK authorization checks
Additional Description:
Risk Level: low (opt-in feature, does nothing by default)
Testing: Added code to existing unit tests
Docs Changes: API protos documented
Release Notes: ext_authz: added :ref:`response_headers_to_add <envoy_v3_api_field_service.auth.v3.OkHttpResponse.response_headers_to_add>` to support sending response headers to downstream clients on OK external authorization checks.
Platform Specific Features:
Fixes envoyproxy#7986

Signed-off-by: John Esmet <john.esmet@gmail.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.

Question: set-cookie on client response in successful ExtAuthz response
4 participants