使用 OPA 的 Envoy 外部授权 - 大型 JSON 正文评估失败
Envoy External Authorization with OPA - evaluate fail with large JSON body
我有 k8s pod 运行 3 个容器:我的应用、opa、envoy
我所有的设置都遵循这个指南:https://www.openpolicyagent.org/docs/latest/envoy-authorization/
一切顺利,直到我有 15kb JSON 正文。
检查我在 request.http.body 中看到的 OPA 容器日志 - 只有 JSON 的一半。
{
"decision_id": "",
"error": {},
"input": {
"attributes": {
"destination": {
"address": {
"Address": {
"SocketAddress": {
"PortSpecifier": {
"PortValue": 8000
},
"address": "10.244.8.102"
}
}
}
},
"request": {
"http": {
"body": "only half of JSON body come here",
"headers": {
":authority": "api-service.com",
":method": "PUT",
":path": "/api",
"accept": "application/json",
"content-length": "14822",
"content-type": "application/json",
"x-envoy-decorator-operation": "....",
"x-envoy-internal": "true",
"x-forwarded-for": "10.244.6.0",
"x-forwarded-proto": "https",
"x-istio-attributes": "..."
},
"host": "....com",
"id": "12114967460600931537",
"method": "PUT",
"path": "/api",
"size": 14822
}
},
"source": {
"address": {
"Address": {
"SocketAddress": {
"PortSpecifier": {
"PortValue": 34670
},
"address": "10.244.3.164"
}
}
}
}
},
"parsed_path": [
"api"
],
"parsed_query": {}
},
"level": "info",
"msg": "Decision Log",
"query": "data.app.allow",
"type": "openpolicyagent.org/decision_logs"
}
我试过增加 with_request_body。
http_filters:
- name: envoy.ext_authz
config:
with_request_body:
max_request_bytes: 819200
allow_partial_message: true
failure_mode_allow: false
我还有什么遗漏的吗?
非常感谢您的帮助
Envoy 日志中是否有任何错误?
您要发送的数据是什么?它是否需要成为 OPA 的 输入 文档的一部分,或者您可以利用 OPA 的 bundle 功能。
我终于通过增加 max_request_bytes 让它工作了。
name: envoy.ext_authz
config:
with_request_body:
max_request_bytes: 819200
我之前在 configmap 中配置了这个但是忘记重启 pod。只需使用新 max_request_bytes 重新部署所有内容 - 现在可以了
我有 k8s pod 运行 3 个容器:我的应用、opa、envoy
我所有的设置都遵循这个指南:https://www.openpolicyagent.org/docs/latest/envoy-authorization/
一切顺利,直到我有 15kb JSON 正文。
检查我在 request.http.body 中看到的 OPA 容器日志 - 只有 JSON 的一半。
{
"decision_id": "",
"error": {},
"input": {
"attributes": {
"destination": {
"address": {
"Address": {
"SocketAddress": {
"PortSpecifier": {
"PortValue": 8000
},
"address": "10.244.8.102"
}
}
}
},
"request": {
"http": {
"body": "only half of JSON body come here",
"headers": {
":authority": "api-service.com",
":method": "PUT",
":path": "/api",
"accept": "application/json",
"content-length": "14822",
"content-type": "application/json",
"x-envoy-decorator-operation": "....",
"x-envoy-internal": "true",
"x-forwarded-for": "10.244.6.0",
"x-forwarded-proto": "https",
"x-istio-attributes": "..."
},
"host": "....com",
"id": "12114967460600931537",
"method": "PUT",
"path": "/api",
"size": 14822
}
},
"source": {
"address": {
"Address": {
"SocketAddress": {
"PortSpecifier": {
"PortValue": 34670
},
"address": "10.244.3.164"
}
}
}
}
},
"parsed_path": [
"api"
],
"parsed_query": {}
},
"level": "info",
"msg": "Decision Log",
"query": "data.app.allow",
"type": "openpolicyagent.org/decision_logs"
}
我试过增加 with_request_body。
http_filters:
- name: envoy.ext_authz
config:
with_request_body:
max_request_bytes: 819200
allow_partial_message: true
failure_mode_allow: false
我还有什么遗漏的吗?
非常感谢您的帮助
Envoy 日志中是否有任何错误?
您要发送的数据是什么?它是否需要成为 OPA 的 输入 文档的一部分,或者您可以利用 OPA 的 bundle 功能。
我终于通过增加 max_request_bytes 让它工作了。
name: envoy.ext_authz
config:
with_request_body:
max_request_bytes: 819200
我之前在 configmap 中配置了这个但是忘记重启 pod。只需使用新 max_request_bytes 重新部署所有内容 - 现在可以了