v0.27.19
Changes
feat: add encodeBase64RequestHeader and encodeBase64ResponseHeader filters (#4101)
Description
Add encodeBase64RequestHeader and encodeBase64ResponseHeader filters for
base64-encoding header values, mirroring the
decodeBase64RequestHeader/decodeBase64ResponseHeader filters from #4100.
Both filters take the same arguments:
- First argument: header name (required)
- Second argument: part index (optional, 0-based)
Without the part index, the entire header value is base64-encoded. With
the part index, the value is split by whitespace and only that field is
encoded.
Usage
# Encode full request header value:
r: * -> encodeBase64RequestHeader("X-Custom-Header") -> "https://example.org";
# Encode only the second field (index 1):
r: * -> encodeBase64RequestHeader("Authorization", 1) -> "https://example.org";
# Same for response headers:
r: * -> encodeBase64ResponseHeader("X-Custom-Header") -> "https://example.org";
Changes
- filters/filters.go: added EncodeBase64RequestHeaderName and
EncodeBase64ResponseHeaderName constants - filters/builtin/header_base64.go: filter implementation (Spec + Filter
for req/resp pair) - filters/builtin/builtin.go: registered NewEncodeRequestHeaderBase64()
and NewEncodeResponseHeaderBase64() - docs/reference/filters.md: documented both filters
Testing
- 25 tests across 7 test functions covering:
- CreateFilter validation (missing args, wrong types, too many args)
- Request header full-value encoding, empty header, special characters
- Request header with part index (index 0, 1, out-of-range, negative)
- Response header full-value encoding and part encoding
- Unit tests for the encodeBase64Value helper
- Filter name verification for both variants
Related Issues
Fixes #4099
Checklist
- Code follows the project style guidelines (gofmt)
- Self-reviewed the code
- Tests added / updated
- All tests pass locally
- No new warnings introduced
- User documentation added in docs/reference/filters.md
- DCO sign-off included
Multiarch Docker image
Multiarch Docker image is available in GitHub's docker registry:
docker run -it ghcr.io/zalando/skipper:v0.27.19 skipper --help