Comments (5)
@jaygorrell
I'm reading the documentation for this plugin and it seems like, it doesn't accept an array of header.
Could you please try the following?
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: add-security-headers
config:
add:
headers: "X-Xss-Protection:1; mode=block"
from kubernetes-ingress-controller.
I tried the string formatted values instead of a list but didn't have any luck, but I did get this worked out.
Looking at pluginDeepEqual
here:
It iterates over each k/v in the config map, making sure the KongPlugin
config items are in Kong and with the same value. For most plugins this is straightforward but the transformer plugins have a nested structure that this method doesn't account for that -- so in my case it just compares the add
key as a whole. Using my example above, in Kong, the structure is this:
"add": {
"headers": [
"X-Xss-Protection:1; mode=block"
],
"json": {}
},
"append": {
"headers": {},
"json": {}
},
"remove": {
"headers": {},
"json": {}
},
"replace": {
"headers": {},
"json": {}
}
The value of the add
key also contains the empty json
dict, which causes the check to fail.
Changing my KongPlugin
to this fixes the issue:
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: $((basename))-upside-add-security-headers
config:
add:
headers:
- "X-Xss-Protection:1; mode=block"
json: {}
It's also interesting and worth noting that the empty data structure in Kong is a map, while a populated value is a list. That's a little unintuitive but unrelated to Kong Ingress -- aside from how you need to match the values.
I think there's still an issue to be addressed here in code for a better way to compare the objects but if you think this is acceptable, feel free to close the issue.
from kubernetes-ingress-controller.
I tried rolling out this temporary fix but hit another snag. Basically the order of the headers
and json
keys can vary in how they get persisted in Kong, regardless which order they appear in the KongPlugin
. In my above example, many of the json
keys are coming back before the headers
key.
This means you would need to create the KongPlugin
, query Kong to see the order, then adjust the configuration order to match.
from kubernetes-ingress-controller.
@jaygorrell Thank you for your detailed debugging and sharing the results.
Like you already said, there are two separate issues at play here:
-
An empty JSON array (
"array": []
) showing up as an empty JSON object ("array": {}
). This is an issue with lua-cjson, the serialization library that Kong uses, as reported in Kong/kong#3166 and Ingress Controller can't fix that issue. -
The other issue, which I expected we would run into sooner or later when you first opened this ticket was ordering of elements in an array.
reflect.DeepEqual
from Go's stdlib can compare JSONs so we should use that and fix the bug. We will open up a PR to fix it.
from kubernetes-ingress-controller.
This issue should be fixed now with #106 merged in.
The other issue is with the plugin as noted in Kong/kong#3166.
Closing this, please re-open if needed.
from kubernetes-ingress-controller.
Related Issues (20)
- e2e failure: TestDeployAndUpgradeAllInOnePostgres in nightly tests against unreleased Kong HOT 4
- Test Request: Kong Gateway EE version 3.4.3.1-rc1 HOT 4
- Add flags to reconcile one specific `Gateway` only HOT 1
- Crashloop in `proxy` container HOT 1
- Docs: describe unmanaged `Gateway`s details and make errors about migrating `Gateway` between deployments clearer
- Add CRD KongVault to manage custom vaults in Kong gateway HOT 5
- Implement `KongVault` controller and translator to translate and apply configuration of custom Kong vaults
- Support referencing values from vaults in `configPatches` of `KongPlugin` and `KongClusterPlugin`
- Kong ValidatingWebhook timeouts; Kong breaks cert-manager HOT 1
- Log the detailed error and generate events when failed to fill in defaults of plugins HOT 3
- When Installing Kong JWT Plugin Declaratively, claimsToVerify Parameter Didn't Work
- Plugin attachment to a group of resources from different namespaces
- Bump actions upload-artifact and download-artifact from 3 to 4 HOT 2
- Test Request: Kong Gateway EE version 3.5.0.2-r1 HOT 9
- Test Request: Kong Gateway EE version 3.4.3.2-rc1 HOT 12
- Monitoring and counting the number of messages that pass through a websocket request
- E2E test `TestDeployAllInOneDBLESSGateway` failing to due yet unknown feature flag used HOT 4
- Flaky E2E test: `TestValidationWebhook/should_fail_the_validation_if_the_secret_in_ConfigPatches_of_KongClusterPlugin_generates_invalid_configuration` HOT 1
- KongRawStateToKongState doesn't support ConsumerGroups
- Moves useful consts from `internal` to `pkg`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubernetes-ingress-controller.