✨ Add new field `behavior` to model `HttpHeader`
| Netbox Version | Plugin Version |
|---|---|
| v3.6.9 | v0.25.1 |
Actual Behavior
A Reverse Proxy Mapping can have "HTTP Headers" entities attached to it. At RPS squad, we implemented this to mean:
Set the header on the request to upstream or response to client
Desired Behavior
We want to be able to:
- set header, if said header was already present it is not overridden
- replace header, if said header was already present it is overridden
- append to header, if said header was already present, the value is appended to it, otherwise we set it (similar to how the
X-Forwarded-Forheader behave) - remove header, if said header was present it is hidden
Use Case 1: Set header if not present
Settings in Netbox:
| Header Name | Header Value | Behavior | Apply To |
|---|---|---|---|
| Foo | fizzbuzz | Set | Request |
Scenario:
- Client sends a header:
- Client sends request to mapping with header
Foo: bar - Reverse Proxy does nothing, as configured in Netbox
- Upstream receives
Foo: bar
- Client sends request to mapping with header
- Client does not send a header:
- Client sends request to mapping with no header
- Reverse Proxy sets the header to
fizzbuzz, as configured in Netbox - Upstream receives
Foo: fizzbuzz
Use case 2: Replace header
Settings in Netbox:
| Header Name | Header Value | Behavior | Apply To |
|---|---|---|---|
| Foo | fizzbuzz | Replace | Request |
Scenario:
- Client sends request to mapping (optionally) with header
Foo: bar - Reverse Proxy replaces the header to
fizzbuzz, as configured in Netbox - Upstream receives
Foo: fizzbuzz
Use case 3: Append to header
Settings in Netbox:
| Header Name | Header Value | Behavior | Apply To |
|---|---|---|---|
| Foo | baz | Append | Request |
Scenario:
- Client sends a header:
- Client sends request to mapping with header
Foo: bar - Reverse Proxy appends
bazto the header, as configured in Netbox - Upstream receives
Foo: bar,baz
- Client sends request to mapping with header
- Client does not send a header:
- Client sends request to mapping with no header
- Reverse proxy appends
bazto the header, as configured in Netbox - Upstream receives
Foo: baz
Use case 4: Remove header
Settings in Netbox:
| Header Name | Header Value | Behavior | Apply To |
|---|---|---|---|
| Foo | - | Remove | Request |
Scenario:
- Malicious client sends request to mapping with header
Remote-User: admin - Reverse Proxy removes the
Remote-Userheader, as configured in Netbox - Upstream does not receive
Remote-Userheader
Proposal: add new field behavior to HttpHeader model
The HttpHeader model should have a new field behavior, which is a VARCHAR that can be set to one of the following values:
setreplaceappendremove
The field should defaults to replace (for backward compatibility).