Skip to content

xds: Add ext_authz response handling - #12896

Open
sauravzg wants to merge 1 commit into
dev/sauravzg/request-builderfrom
dev/sauravzg/response-handling
Open

xds: Add ext_authz response handling#12896
sauravzg wants to merge 1 commit into
dev/sauravzg/request-builderfrom
dev/sauravzg/response-handling

Conversation

@sauravzg

@sauravzg sauravzg commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Part 2 of the client-side ext_authz filter. Sits on top of #12493.

Adds CheckResponseHandler, which interprets the CheckResponse from the authorization service. It evaluates OkHttpResponse vs DeniedHttpResponse, maps HTTP status codes to gRPC statuses, applies failure_mode_allow semantics when the authz server is unreachable, and validates decoder header mutations against the configured HeaderMutationRulesConfig.

AuthzResponse is the resulting value object carrying the allow/deny decision, the gRPC status for denied calls, and any header/trailer mutations to apply.

Part 2 of the client-side ext_authz filter. Sits on top of #12493.

Adds CheckResponseHandler, which interprets the CheckResponse from
the authorization service. It evaluates OkHttpResponse vs
DeniedHttpResponse, maps HTTP status codes to gRPC statuses, applies
failure_mode_allow semantics when the authz server is unreachable, and
validates decoder header mutations against the configured
HeaderMutationRulesConfig.

AuthzResponse is the resulting value object carrying the allow/deny
decision, the gRPC status for denied calls, and any header/trailer
mutations to apply.
@sauravzg
sauravzg requested a review from kannanjgithub July 7, 2026 13:02
Comment on lines +39 to +42
public class CheckResponseHandler {
private final HeaderMutationFilter headerMutationFilter;

public CheckResponseHandler(HeaderMutationFilter headerMutationFilter) {

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.

Make the class and the constructor package-private.

return AuthzResponse.allow(
HeaderMutations.create(ImmutableList.of(), ImmutableList.of())).build();
}
OkHttpResponse okResponse = response.getOkResponse();

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: Can just inline the expression without using a local variable.

Comment on lines +67 to +68
return AuthzResponse.allow(allowedMutations.requestMutations())
.setResponseHeaderMutations(allowedMutations.responseMutations()).build();

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.

Looking at this usage, the response mutations can also be an argument to AuthzResponse.allow instead of making it set EMPTY_MUTATIONS for response.

}
DeniedHttpResponse deniedResponse = response.getDeniedResponse();
CheckResponseMutations allowedMutations =
buildHeaderMutationsFromDeniedResponse(deniedResponse);

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.

Since only response mutations is used for the denied case, can we either avoid calling this method that creates mutations for both request and response, or add a boolean argument to indicate skipping request mutations?

}

@Test
public void handleResponse_ok_edgeCaseHeaders() {

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: Can we use a more indicative name that tells what edge case it is?


@Test
public void handleResponse_okWithMutations() {
HeaderValueOption option =

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.

Can we also add envoy HeaderValueOptions for ADD_IF_ABSENT, OVERWRITE_IF_EXISTS_OR_ADD and OVERWRITE_IF_EXISTS and verify their translation in the same test?

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.

2 participants