envoyproxy/envoy

Cannot extract response cookie value from Set-Cookie in Header-To-Metadata Filter

Open

#22,654 创建于 2022年8月11日

在 GitHub 查看
 (7 评论) (0 反应) (0 负责人)C++ (5,373 fork)batch import
area/http_filterhelp wanted

仓库指标

Star
 (27,997 star)
PR 合并指标
 (平均合并 8天) (30 天内合并 378 个 PR)

描述

Title: Cannot extract response cookie value from Set-Cookie in Header-To-Metadata Filter

Description: I'm trying to put one of cookie values to the log using a filter 'header_to_metadata' and '%DYNAMIC_METADATA(NAMESPACE:KEY*):Z%' It works fine for the request part, but doesn't work for response. Maybe the problem is the following: As I can see from the code, when we extract request cookie value, 'parseCookieValue' function is used, which searches for the 'cookie' key. But response cookie uses 'Set-Cookie' as header key. And for it there is a 'parseSetCookieValue' function, but it is not used in the filter 'header_to_metadata'. Is there a bug or is there any other way to extract cookie value from Set-Cookie? Configuration snippets below:

- name: envoy.filters.http.header_to_metadata
   typed_config:
       "@type": type.googleapis.com/envoy.extensions.filters.http.header_to_metadata.v3.Config
        request_rules:
        - cookie: SESSIONID
           on_header_present:
               metadata_namespace: envoy.sessionid.req
               key: id
        response_rules:
        - cookie: SESSIONID
           on_header_present:
               metadata_namespace: envoy.sessionid.resp
               key: id

and

- name: envoy.access_loggers.file
   typed_config:
       "@type": "type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog"
       path: /dev/stdout
       log_format:
               text_format_source:
                   inline_string: "... %DYNAMIC_METADATA(envoy.sessionid.req:id)% %DYNAMIC_METADATA(envoy.sessionid.resp:id)% ..."

[optional Relevant Links:]

https://github.com/envoyproxy/envoy/blob/0986bb6d49fbd35e20e567aec0e7d614c9d24663/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc#L36 https://github.com/envoyproxy/envoy/blob/a06001ce26a3ebbcb4c861d4fd94fe7267a2ac07/source/common/http/utility.cc#L487-L494

贡献者指南