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: Allow to emit dynamic metadata #11820

Merged
merged 18 commits into from
Jul 16, 2020
Merged

ext_authz: Allow to emit dynamic metadata #11820

merged 18 commits into from
Jul 16, 2020

Conversation

dio
Copy link
Member

@dio dio commented Jun 30, 2020

Commit Message:

This patch enables ext_authz backed with gRPC service to emit metadata. The gRPC authorization server can set the dynamic metadata (an opaque google.protobuf.Struct) as part of the CheckResponse when it is successful (i.e. when http_response is OkHttpResponse).

Risk Level: Low
Testing: Unit.
Docs Changes: Added.
Release Notes: Added.
Fixes #9049

Signed-off-by: Dhi Aurrahman [email protected]

This patch enables ext_authz backed with gRPC service to emit metadata.
The authorization can set the dynamic metadata (an opaque
google.protobuf.Struct) as part of the `CheckResponse` when it is
successful (i.e. when `http_response` is `OkHttpResponse`).

Signed-off-by: Dhi Aurrahman <[email protected]>
@repokitteh-read-only
Copy link

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

🐱

Caused by: #11820 was opened by dio.

see: more, trace.

@dio
Copy link
Member Author

dio commented Jun 30, 2020

cc. @erikbos

@dio
Copy link
Member Author

dio commented Jun 30, 2020

/azp run envoy-presubmit

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -69,6 +70,9 @@ message OkHttpResponse {
// by Leaving `append` as false, the filter will either add a new header, or override an existing
// one if there is a match.
repeated config.core.v3.HeaderValueOption headers = 2;

// Optional response metadata that will be emitted as dynamic metadata.
Copy link
Member

Choose a reason for hiding this comment

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

Which part of the dynamic metadata keyspace does this live?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I catch your question correctly: for HTTP filter, HttpFilterNames::get().ExtAuthorization (envoy.filters.http.ext_authz) while for the network one: NetworkFilterNames::get().ExtAuthorization (envoy.filters.network.ext_authz)

Copy link
Member

Choose a reason for hiding this comment

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

I think we should document these namespaces in the proto where the emit_dynamic_metadata can be enabled. And perhaps refer to those configs here?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, can we spell this out explicitly in the docs? Thanks. Otherwise LGTM for API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure!

zuercher
zuercher previously approved these changes Jul 7, 2020
Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

This looks good to me, from the dynamic metadata perspective.

cc/ @envoyproxy/api-shepherds for API review.


// A set of metadata returned by the authorization server, that will be emitted as filter's
// dynamic metadata that other filters can leverage.
ProtobufWkt::Struct dynamic_metadata{};
Copy link
Member

Choose a reason for hiding this comment

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

nit: no need of {}

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I was lazy to explicitly initialize some Response objects in source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@@ -51,4 +51,7 @@ message ExtAuthz {
// version of Check{Request,Response} used on the wire.
config.core.v3.ApiVersion transport_api_version = 5
[(validate.rules).enum = {defined_only: true}];

// Flag to specify whether dynamic metadata should be emitted. Defaults to false.
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this flag? What is the use case that you want configure this to false when an ext_authz server is returning metadata?

Copy link
Member Author

Choose a reason for hiding this comment

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

When there is no subsequent filter to actually consume the metadata (i.e. when ext_authz is the sole gatekeeper).

Copy link
Member

@lizan lizan Jul 10, 2020

Choose a reason for hiding this comment

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

Then shouldn't the ext_authz server just be configured to not return metadata? (which also avoid the metadata on the wire for efficiency)

Copy link
Member Author

@dio dio Jul 10, 2020

Choose a reason for hiding this comment

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

That’s a fair observation. I will remove this field and update the docs then. Thanks for the input!

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

dio added 2 commits July 9, 2020 06:16
Signed-off-by: Dhi Aurrahman <[email protected]>
Signed-off-by: Dhi Aurrahman <[email protected]>
@dio
Copy link
Member Author

dio commented Jul 9, 2020

/azp run envoy-presubmit

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dio
Copy link
Member Author

dio commented Jul 9, 2020

/azp run envoy-presubmit

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dio
Copy link
Member Author

dio commented Jul 10, 2020

/azp run envoy-presubmit

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dio
Copy link
Member Author

dio commented Jul 14, 2020

@lizan, sorry, do I still need to introduce more fixes in this PR? Thanks!

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

LGTM, defer to @zuercher for non-tetrate final review/merge.

@mattklein123 mattklein123 merged commit ff44d73 into envoyproxy:master Jul 16, 2020
KBaichoo pushed a commit to KBaichoo/envoy that referenced this pull request Jul 30, 2020
This patch enables ext_authz backed with gRPC service to emit metadata.
The authorization can set the dynamic metadata (an opaque
google.protobuf.Struct) as part of the `CheckResponse` when it is
successful (i.e. when `http_response` is `OkHttpResponse`).

Signed-off-by: Dhi Aurrahman <[email protected]>
Signed-off-by: Kevin Baichoo <[email protected]>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
This patch enables ext_authz backed with gRPC service to emit metadata.
The authorization can set the dynamic metadata (an opaque
google.protobuf.Struct) as part of the `CheckResponse` when it is
successful (i.e. when `http_response` is `OkHttpResponse`).

Signed-off-by: Dhi Aurrahman <[email protected]>
Signed-off-by: scheler <[email protected]>
@mailofapideveloper
Copy link

@dio : Thanks for adding Dynamic Metadata in ext_auth response , but its still not available in
https://pkg.go.dev/github.com/envoyproxy/go-control-plane/envoy/service/auth/v3?tab=doc#OkHttpResponse
when I try building the container , its failing with
unknown field 'DynamicMetadata' in struct literal of type envoy_service_auth_v3.OkHttpResponse
can you please help in pushing the changes to pkg.go.dev
Thanks

@erikbos
Copy link
Contributor

erikbos commented Aug 18, 2020

The current latest release of go-control-plane, 0.9.6, does not yet include the proto & structs definitions for this. You'll will have to use go-control-plane master. See #12615 for a code snippet with go-control-plane v0.9.7-0.20200811182123-112a4904c4b0 Don't forget to run envoy > 1.15.0 to run a version which actually supports this.

@mailofapideveloper
Copy link

Thanks much @erikbos , It worked .

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.

ext_authz: allow receiving dynamic metadata from gRPC authorization server
7 participants