-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Incorrect behavior with Routing based on JWT Token Dynamic Metadata #19910
Comments
CC @qiwzhang |
Test at local, it does not work when remove lua filter. |
the jwt filter is configured to populate metadata per config THe lua filter trigger the fresh new route because lua filter after any header operation. We should add a new config in the jwt_authn that clear the snapped route entry |
Is it a bug as jwt filter do not guide a right route? |
It was not a bug before route filter can route upon filter state. In short term, we'd better leave the clear/re-resolve route decision to the user of jwt filter |
The result looks like the jwt filter chooses the wrong route, I try to read codes to understand the flow between filters and routes but still not clear, could you tell more details about it, like regular flow and correct jwt filter flow? |
+1, the jwt filter currently does not clear the route which is needed by the |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions. |
not stale |
I got the same problem but using an external auth-server, which adds the This Lua is reading and logging the user-id from the dynamic metadata.
Output: And this is the snippet of the
I believe it's the same problem, and it is related to the |
I'm seeing the same thing when just using Lua to set the metadata string_match value. |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions. |
not stale |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions. |
I also hit this issue. I am using ext_auth filter to set dynamic metadata and envoy fails to match route using the dynamic metadata unless I add the lua filter that sets a dummy header. I've tested with envoy 1.20 and 1.21 and both showed the issue |
In my case, it happened because clear_route_cache is not triggered when there is no additional header set by the filter(see https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/ext_authz/v3/ext_authz.proto.html), but I only set metadata from ext_authz filter. Route matching works as expected after I set a header from ext_authz filter. I believe this issue happens because envoy finds route before applying filters, and does not re-match route unless route is cleared(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/http/http_filters#filter-route-mutation). The workaround using lua filter works because it clears routes if header is modifed (https://github.com/envoyproxy/envoy/blob/main/source/extensions/filters/http/lua/lua_filter.h#L509) |
Title: Incorrect behavior with Routing based on JWT Token Dynamic Metadata
Description:
When using the
payload_in_metadata
flag of the JWT Authentication filter, dynamic metadata is attached to the stream and visible in logging. However, this dynamic metadata cannot normally be used for HTTP routing.If I set an unrelated header in lua, the dynamic metadata can be used for routing, see the repro steps below.
Repro steps:
Run envoy (
version: a9d72603c68da3a10a1c0d021d01c7877e6f2a30/1.21.0/Clean/RELEASE/BoringSSL
) with the config provided pointing to the providedkeys.json
. Send an example request with a valid JWT andshard_id
in the payload of either1
or2
. Example requests that are valid with the providedkeys.json
are below.(if you use the config as shown below)
(if you uncomment the single lua line
request_handle:headers():add("a-header-that-doesnt-matter", "nop-value")
)I expect to get
this is cluster 2
each time, asshard_id
is set to2
in the payload, but the routing based on dynamic metadata only works if the lua line is uncommented.Config:
keys.json:
Logs:
(no relevant logs in output)
The text was updated successfully, but these errors were encountered: