Skip to content

ext_authz: Use 403 as default for denied response#18010

Merged
mattklein123 merged 6 commits intoenvoyproxy:mainfrom
dio:fix-ext_authz-unknown-denied-response-status
Sep 13, 2021
Merged

ext_authz: Use 403 as default for denied response#18010
mattklein123 merged 6 commits intoenvoyproxy:mainfrom
dio:fix-ext_authz-unknown-denied-response-status

Conversation

@dio
Copy link
Copy Markdown
Member

@dio dio commented Sep 7, 2021

Commit Message: Before this, when a gRPC server sends out DeniedResponse as a check response for a request but without setting the HttpResponse.DeniedResponse.Status, HTTP ext_authz filter translates that as 0 (empty/unknown HTTP status code). This patch makes sure we reply with a valid 403 Forbidden HTTP status code (the current default status code for denied response).

Additional Description: When building a minimal gRPC auth server I found that it is a bit confusing for CheckResponse_DeniedResponse when you have already set CheckResponse.Status with code.Code_PERMISSION_DENIED but then you added CheckResponse.HttpResponse. In the current code, it is required to set CheckResponse.HttpResponse.Status, if not it will be sending Unknown (0) status code.

// This field allows the authorization service to send a HTTP response status
// code to the downstream client other than 403 (Forbidden).
type.v3.HttpStatus status = 1 [(validate.rules).message = {required: true}];

The above docs excerpt suggests that if we skip on specifying it, it will be 403.

Risk Level: Low
Testing: Added
Docs Changes: N/A
Release Notes: Added
Platform Specific Features: N/A

Signed-off-by: Dhi Aurrahman dio@rockybars.com

Before this, when a gRPC server sends out DeniedResponse as a check
response for a request but without setting the
HttpResponse.DeniedResponse.Status, HTTP ext_authz filter translates
that as "0" (empty/unknown HTTP status code). This patch makes sure we
reply with a valid 403 Forbidden HTTP status code (the current default
status code for denied response).

Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@dio
Copy link
Copy Markdown
Member Author

dio commented Sep 7, 2021

/assign @esmet

Copy link
Copy Markdown
Contributor

@yanavlasov yanavlasov left a comment

Choose a reason for hiding this comment

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

Should we make the status to not be required with this change?

/wait

@yanavlasov yanavlasov self-assigned this Sep 7, 2021
@esmet
Copy link
Copy Markdown
Contributor

esmet commented Sep 7, 2021

Lets update the comment on status to make it extra clear that the default is 403. The language only sort of suggests this.

Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@repokitteh-read-only
Copy link
Copy Markdown

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

🐱

Caused by: #18010 was synchronize by dio.

see: more, trace.

dio added 2 commits September 8, 2021 03:32
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@markdroth
Copy link
Copy Markdown
Contributor

/lgtm api

@repokitteh-read-only repokitteh-read-only bot removed the api label Sep 8, 2021
yanavlasov
yanavlasov previously approved these changes Sep 8, 2021
@dio
Copy link
Copy Markdown
Member Author

dio commented Sep 8, 2021

Thanks, @yanavlasov, @esmet, and @markdroth for the review!

@esmet
Copy link
Copy Markdown
Contributor

esmet commented Sep 9, 2021

Looks good, and I think it needs main merged in to fix the linux_x64 api_compat job.

@dio
Copy link
Copy Markdown
Member Author

dio commented Sep 10, 2021

cc. @envoyproxy/senior-maintainers if you want to take a look. Thanks!

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM with small doc nit, thanks.

/wait

* dynamic forward proxy: fixing a validation bug where san and sni checks were not applied setting :ref:`http_protocol_options <envoy_v3_api_msg_extensions.upstreams.http.v3.HttpProtocolOptions>` via :ref:`typed_extension_protocol_options <envoy_v3_api_field_config.cluster.v3.Cluster.typed_extension_protocol_options>`.
* ext_authz: fix the ext_authz filter to correctly merge multiple same headers using the ',' as separator in the check request to the external authorization service.
* ext_authz: the network ext_authz filter now correctly sets dynamic metdata returned by the authorization service for non-OK responses. This behavior now matches the http ext_authz filter.
* ext_authz: fix the HTTP ext_authz filter to response with ``403 Forbidden`` when a gRPC auth server sends a denied check respond with empty HTTP status code.
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.

Suggested change
* ext_authz: fix the HTTP ext_authz filter to response with ``403 Forbidden`` when a gRPC auth server sends a denied check respond with empty HTTP status code.
* ext_authz: fix the HTTP ext_authz filter to respond with ``403 Forbidden`` when a gRPC auth server sends a denied check response with an empty HTTP status code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, @mattklein123. Updated.

Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@mattklein123 mattklein123 merged commit e3af094 into envoyproxy:main Sep 13, 2021
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