Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Bug Fixes
---------
*Changes expected to improve the state of the world and are unlikely to have negative effects*

* ext_authz: fix the ext_authz network filter to correctly set response flag to ``UAEX`` when a connection is denied.
* listener: fixed the crash when updating listeners that do not bind to port.
* thrift_proxy: fix the thrift_proxy connection manager to correctly report success/error response metrics when performing :ref:`payload passthrough <envoy_v3_api_field_extensions.filters.network.thrift_proxy.v3.ThriftProxy.payload_passthrough>`.

Expand Down
8 changes: 8 additions & 0 deletions source/extensions/filters/network/ext_authz/ext_authz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,34 @@ void Filter::onComplete(Filters::Common::ExtAuthz::ResponsePtr&& response) {
NetworkFilterNames::get().ExtAuthorization, response->dynamic_metadata);
}

bool denied = false;
// Fail open only if configured to do so and if the check status was a error.
if (response->status == Filters::Common::ExtAuthz::CheckStatus::Denied ||
(response->status == Filters::Common::ExtAuthz::CheckStatus::Error &&
!config_->failureModeAllow())) {
config_->stats().cx_closed_.inc();
filter_callbacks_->connection().close(Network::ConnectionCloseType::NoFlush);
denied = true;
} else {
// Let the filter chain continue.
filter_return_ = FilterReturn::Continue;
if (config_->failureModeAllow() &&
response->status == Filters::Common::ExtAuthz::CheckStatus::Error) {
// Status is Error and yet we are configured to allow traffic. Click a counter.
config_->stats().failure_mode_allowed_.inc();
denied = true;
}

// We can get completion inline, so only call continue if that isn't happening.
if (!calling_check_) {
filter_callbacks_->continueReading();
}
}

if (denied) {
filter_callbacks_->connection().streamInfo().setResponseFlag(
StreamInfo::ResponseFlag::UnauthorizedExternalService);
}
}

} // namespace ExtAuthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ TEST_F(ExtAuthzFilterTest, DeniedWithOnData) {
stats_store_.gauge("ext_authz.name.active", Stats::Gauge::ImportMode::Accumulate).value());

EXPECT_CALL(filter_callbacks_.connection_, close(Network::ConnectionCloseType::NoFlush));
EXPECT_CALL(filter_callbacks_.connection_.stream_info_,
setResponseFlag(StreamInfo::ResponseFlag::UnauthorizedExternalService));
EXPECT_CALL(*client_, cancel()).Times(0);
request_callbacks_->onComplete(makeAuthzResponse(Filters::Common::ExtAuthz::CheckStatus::Denied));

Expand Down Expand Up @@ -429,7 +431,8 @@ TEST_F(ExtAuthzFilterTest, ImmediateNOK) {
EXPECT_EQ(ns, NetworkFilterNames::get().ExtAuthorization);
EXPECT_TRUE(TestUtility::protoEqual(returned_dynamic_metadata, dynamic_metadata));
}));

EXPECT_CALL(filter_callbacks_.connection_.stream_info_,
setResponseFlag(StreamInfo::ResponseFlag::UnauthorizedExternalService));
EXPECT_EQ(Network::FilterStatus::Continue, filter_->onNewConnection());
Buffer::OwnedImpl data("hello");
EXPECT_EQ(Network::FilterStatus::StopIteration, filter_->onData(data, false));
Expand Down