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

Add request headers to remove #196

Merged
merged 4 commits into from
Oct 20, 2020
Merged

Add request headers to remove #196

merged 4 commits into from
Oct 20, 2020

Conversation

andrzejwaw
Copy link
Contributor

Allow sanitize local service request headers

@slonka slonka temporarily deployed to envoy-control-pr-196 October 16, 2020 10:49 Inactive
@andrzejwaw andrzejwaw closed this Oct 16, 2020
@andrzejwaw andrzejwaw reopened this Oct 19, 2020
@slonka slonka temporarily deployed to envoy-control-pr-196 October 19, 2020 09:22 Inactive
@@ -99,6 +101,7 @@ internal class EnvoyIngressRoutesFactoryTest {

// then
routeConfig
.hasRequestHeaderToRemove("x-via-vip")
Copy link
Contributor

Choose a reason for hiding this comment

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

This test looks like a big bag for all the routes features we have. Couldn't we split it somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I've added separated test

@@ -123,6 +123,7 @@ class RoutesProperties {
var admin = AdminRouteProperties()
var status = StatusRouteProperties()
var authorization = AuthorizationProperties()
var headersToRemove: List<String> = emptyList()
Copy link
Contributor

Choose a reason for hiding this comment

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

How does it behave in Spring Boot? Does Spring Boot add headers properly when this list is immutable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works, just for consistency, I've changed it to mutableList

@@ -123,6 +123,7 @@ class RoutesProperties {
var admin = AdminRouteProperties()
var status = StatusRouteProperties()
var authorization = AuthorizationProperties()
var headersToRemove: List<String> = emptyList()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a description to docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I've added

Copy link
Contributor

@MarcinFalkowski MarcinFalkowski left a comment

Choose a reason for hiding this comment

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

LGTM, just one request to change property format.

The biggest risk with this change is that we rely on undocumented Envoy feature, that the headers are removed AFTER all http filters processed the request. If this will change in the future, the RBAC filter will stop working correctly.

Ideally we should create an integration test to be sure that it works correctly with RBAC. But as I see, we don't even have a test for ip-based + header-selector-matching principal, so it would require writing it from scratch.

If you want to write such test then great, but I think we can also accept this risk and merge it as it is.

@@ -123,6 +123,7 @@ class RoutesProperties {
var admin = AdminRouteProperties()
var status = StatusRouteProperties()
var authorization = AuthorizationProperties()
var headersToRemove: List<String> = emptyList()
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO routes properties is not the best place for this property, because we set it only on ingress routes, not egress routes.

Maybe we should create ingress section on the same level as egress section?:

envoy:
  snapshot:
     egress:
         ...
     ingress:
       headersToRemove:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've moved property as you suggested

@slonka slonka temporarily deployed to envoy-control-pr-196 October 19, 2020 13:24 Inactive
@pzmi
Copy link
Contributor

pzmi commented Oct 19, 2020

Ideally we should create an integration test to be sure that it works correctly with RBAC. But as I see, we don't even have a test for ip-based + header-selector-matching principal, so it would require writing it from scratch.

I guess we can proceed with this PR and create a separate issue for suggested tests.

when {
properties.ingress.headersToRemove.isNotEmpty() -> {
builder.addAllRequestHeadersToRemove(properties.ingress.headersToRemove)
}
Copy link
Contributor

@MarcinFalkowski MarcinFalkowski Oct 19, 2020

Choose a reason for hiding this comment

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

Not sure if when is better than if when we have only one branch, but why not :)

@slonka slonka temporarily deployed to envoy-control-pr-196 October 20, 2020 08:34 Inactive
@andrzejwaw andrzejwaw merged commit 7aa7f34 into master Oct 20, 2020
@pzmi pzmi deleted the request-headers-to-remove branch October 30, 2020 09:10
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.

None yet

4 participants