Skip to content

Commit

Permalink
Merge pull request #143 from Kuadrant/fix-auth-headers
Browse files Browse the repository at this point in the history
Correctly add auth headers that should be sent to the upstream
  • Loading branch information
adam-cattermole authored Nov 12, 2024
2 parents 6cc5dd4 + 8ded8c6 commit a32f1dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
42 changes: 20 additions & 22 deletions src/service/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,26 @@ impl AuthService {
match check_response.http_response {
Some(CheckResponse_oneof_http_response::ok_response(ok_response)) => {
debug!("process_auth_grpc_response: received OkHttpResponse");
ok_response
.get_headers_to_remove()
.iter()
.for_each(|header| {
hostcalls::set_map_value(
MapType::HttpResponseHeaders,
header.as_str(),
None,
)
.unwrap()
});
ok_response
.get_response_headers_to_add()
.iter()
.for_each(|header| {
hostcalls::add_map_value(
MapType::HttpResponseHeaders,
header.get_header().get_key(),
header.get_header().get_value(),
)
.unwrap()
});
if !ok_response.get_response_headers_to_add().is_empty() {
panic!("process_auth_grpc_response: response contained response_headers_to_add which is unsupported!")
}
if !ok_response.get_headers_to_remove().is_empty() {
panic!("process_auth_grpc_response: response contained headers_to_remove which is unsupported!")
}
if !ok_response.get_query_parameters_to_set().is_empty() {
panic!("process_auth_grpc_response: response contained query_parameters_to_set which is unsupported!")
}
if !ok_response.get_query_parameters_to_remove().is_empty() {
panic!("process_auth_grpc_response: response contained query_parameters_to_remove which is unsupported!")
}
ok_response.get_headers().iter().for_each(|header| {
hostcalls::add_map_value(
MapType::HttpRequestHeaders,
header.get_header().get_key(),
header.get_header().get_value(),
)
.unwrap()
});
Ok(())
}
Some(CheckResponse_oneof_http_response::denied_response(denied_response)) => {
Expand Down
1 change: 1 addition & 0 deletions src/service/rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl RateLimitService {
response_headers_to_add: additional_headers,
..
}) => {
// TODO: This should not be sent to the upstream!
additional_headers.iter().for_each(|header| {
hostcalls::add_map_value(
MapType::HttpResponseHeaders,
Expand Down

0 comments on commit a32f1dd

Please sign in to comment.