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

operator/ingress: Add Forwarded header policy #688

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented Jul 12, 2020

This commit implements NE-317.

  • operator/v1/types_ingress.go (IngressControllerSpec): Add HTTPHeaders field with the new IngressControllerHTTPHeaders type.
    (IngressControllerHTTPHeaderPolicy): New type.
    (AppendHTTPHeaderPolicy, ReplaceHTTPHeaderPolicy, IfNoneHTTPHeaderPolicy, NeverHTTPHeaderPolicy): New constants.
    (IngressControllerHTTPHeaders): New type. Describe policy for handling HTTP headers. For now, the only field is ForwardedHeaderPolicy, with the new IngressControllerHTTPHeaderPolicy type, for specifying how the HTTP Forwarded header and related headers should be handled.
  • operator/v1/0000_50_ingress-operator_00-ingresscontroller.crd.yaml:
  • operator/v1/zz_generated.deepcopy.go:
  • operator/v1/zz_generated.swagger_doc_generated.go: Regenerate.

Corresponding enhancement proposal: openshift/enhancements#371

@Miciah Miciah force-pushed the operator-slash-ingress-add-Forwarded-header-policy branch from f2a9697 to 06870a2 Compare July 12, 2020 18:49
// IngressControllerHTTPHeaderPolicy is a policy for setting HTTP headers.
//
// +kubebuilder:validation:Enum=Append;Replace;IfNone;Never
type IngressControllerHTTPHeaderPolicy string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deviating from the enhancement proposal, I changed the allowed values here from lower-case (append;replace;if-none;never) to the above value for consistency with other API values.

@Miciah Miciah force-pushed the operator-slash-ingress-add-Forwarded-header-policy branch 2 times, most recently from 7ad0c18 to c902cce Compare July 12, 2020 19:33
// If this field is empty, the default values are used.
//
// +optional
Forwarded *IngressControllerHTTPForwardedHeaderPolicy `json:"forwarded,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

pointers to strings are a no-no in our configuration. Empty has a defined meaning and valid, and should mean the same as nil, so nil shouldn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IngressControllerHTTPForwardedHeaderPolicy (the type for spec.httpHeaders.forwarded) is not a string type. Are you referring to the fact that IngressControllerHTTPHeaderPolicy (the type for spec.httpHeaders.forwarded.policy) is a string type? I think we can make it required but allow empty to avoid breaking upgrades.

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 changed Forwarded to a non-pointer value. I assume the +optional still belongs. Everything look all right?

@Miciah Miciah force-pushed the operator-slash-ingress-add-Forwarded-header-policy branch 2 times, most recently from da3e607 to ecb90f3 Compare July 14, 2020 19:13
// forwarded describes how the Forwarded HTTP header and related headers
// are handled.
//
// +optional
Copy link
Contributor

Choose a reason for hiding this comment

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

optional fields need to describe what happens on empty. Empty is a straight pass through or pass through while handling auth headers or what?


// IngressControllerHTTPHeaders specifies how the IngressController handles
// certain HTTP headers.
type IngressControllerHTTPHeaders struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

What else would theoretically go into this struct as compared to what would theoretically get added to IngressControllerHTTPForwardedHeaderPolicy. Are these truly distinct structs? Maybe the next two most likely fields for each struct would help me see it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next field we'd add is uniqueId, for injecting a custom, unique header into every request for tracing: 43ad0aa#diff-85d84174432a6d2df99d107129e012f8R601-R611

Beyond that, we have an RFE to allow setting arbitrary headers, such as Strict-Transport-Security and X-XSS-Protection, with static values. To implement that, I expect we'll add a field with a slice type for specifying arbitrary name-value pairs.

Copy link
Contributor

Choose a reason for hiding this comment

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

miciah also came up with "Maybe an OmitNonStandard (the X-Forwarded-*" for the ForwardedHeaderPolicy.

@Miciah if nothing gets added to this in the next year, we should remember that in the future.

@deads2k
Copy link
Contributor

deads2k commented Jul 16, 2020

the doc is good, the validation wellformed. I just don't quite understand the need for two layers. I'd like to understand before approving.

@Miciah Miciah force-pushed the operator-slash-ingress-add-Forwarded-header-policy branch from ecb90f3 to d69157b Compare July 16, 2020 13:07
@deads2k
Copy link
Contributor

deads2k commented Jul 16, 2020

/lgtm
/hold

hold is just in case @Miciah has second thoughts about depth. If you like the depth, remove the hold at your discretion.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 16, 2020
@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 16, 2020
@Miciah Miciah force-pushed the operator-slash-ingress-add-Forwarded-header-policy branch from d69157b to 79edba8 Compare July 16, 2020 13:41
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 16, 2020
This commit implements NE-317.

https://issues.redhat.com/browse/NE-317

* operator/v1/types_ingress.go (IngressControllerSpec): Add HTTPHeaders
field with the new IngressControllerHTTPHeaders type.
(IngressControllerHTTPHeaderPolicy): New type.
(AppendHTTPHeaderPolicy, ReplaceHTTPHeaderPolicy, IfNoneHTTPHeaderPolicy)
(NeverHTTPHeaderPolicy): New constants.
(IngressControllerHTTPHeaders): New type.  Describe policy for handling
HTTP headers.  For now, the only field is ForwardedHeaderPolicy, with the
new IngressControllerHTTPHeaderPolicy type, for specifying how the HTTP
Forwarded header and related headers should be handled.
* operator/v1/0000_50_ingress-operator_00-ingresscontroller.crd.yaml:
* operator/v1/zz_generated.deepcopy.go:
* operator/v1/zz_generated.swagger_doc_generated.go: Regenerate.
@Miciah Miciah force-pushed the operator-slash-ingress-add-Forwarded-header-policy branch from 79edba8 to 03d62b9 Compare July 16, 2020 13:43
@Miciah
Copy link
Contributor Author

Miciah commented Jul 16, 2020

/hold cancel
I reduced depth, so the new field is spec.httpHeaders.forwardedHeaderPolicy: Append|Replace|IfNone|Never.

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 16, 2020
@deads2k
Copy link
Contributor

deads2k commented Jul 16, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 16, 2020
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, Miciah

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants