envoyproxy/envoy

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

Open

#22 654 ouverte le 11 août 2022

Voir sur GitHub
 (7 commentaires) (0 réactions) (0 assignés)C++ (5 373 forks)batch import
area/http_filterhelp wanted

Métriques du dépôt

Stars
 (27 997 stars)
Métriques de merge PR
 (Merge moyen 8j) (378 PRs mergées en 30 j)

Description

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

Guide contributeur