Skip to content

Support for header based stateful session #22475

Closed

Description

@ramaraochavali

Currently stateful session supports cookie based session management.

It would be useful to extend this to header based session management as cookies have some assumed default behaviour with browsers and not work well with tabs.

The proposal is to add header based stateful session support in the following ways.

  1. Similar to cookie, Envoy can generate the header and encode the host ip:port where caller is expected to pass it on every request. This works similar to cookies except that it is not a special header and hence no default behaviour assumed.
  2. Implement an in memory cache (backed by external cache like redis) that Envoy can lookup.

#2 needs more thought on what key should be used and how to provide integration with external cache etc. But #1 is simpler to implement and people who are willing to build client side solution to keep track of the header and pass on every request can benefit from this (This is actually our main use case as we have client specific code that can send the header on every request).

Activity

  1. added
    enhancement
    triage
    on Aug 1, 2022
  2. ramaraochavali commented on Aug 1, 2022

    @ramaraochavali
    ContributorAuthor

    discussed offline with @wbpcode and he is generally OK with this.

  3. removed
    triage
    on Aug 1, 2022
  4. alyssawilk commented on Aug 1, 2022

    @alyssawilk
    Contributor

    cc @cpakulski as the other co-owner

  5. wbpcode commented on Aug 2, 2022

    @wbpcode
    Member

    #1 is easy to implemented and useful for some cases. But is there a standard way to notify the client to send a special header like set-cookie?

    Or there will be two configurable header names (one name will be used by the envoy to set response header at first request, one name will be used in the requests) ?

  6. added
    design proposal
    on Aug 2, 2022
  7. ramaraochavali commented on Aug 2, 2022

    @ramaraochavali
    ContributorAuthor

    But is there a standard way to notify the client to send a special header like set-cookie?

    I am not aware of any

    or there will be two configurable header names (one name will be used by the envoy to set response header at first request, one name will be used in the requests) ?

    I was thinking one header where envoy will set if it is not present and client will use the same header name in subsequent requests. Would it complicate things?

  8. wbpcode commented on Aug 2, 2022

    @wbpcode
    Member

    I was thinking one header where envoy will set if it is not present and client will use the same header name in subsequent requests. Would it complicate things?

    IMO, I think a pair of headers would be more clear.


    But the key point is if there is no way to notify the client, then only some custom clients that aware the configured special headers can get helps from this header based session. Then may be we shouldn't add it to the core envoy but just keep it as a private extension for yourself?

    cc @alyssawilk @cpakulski

  9. ramaraochavali commented on Aug 2, 2022

    @ramaraochavali
    ContributorAuthor

    But the key point is if there is no way to notify the client, then only some custom clients that aware the configured special headers can get helps from this header based session.

    I think as long as the header name (pair of headers as you described) are configurable, I think it is generic enough. It is exactly similar to cookie, but the header names change.

  10. wbpcode commented on Aug 2, 2022

    @wbpcode
    Member

    I think as long as the header name (pair of headers as you described) are configurable, I think it is generic enough. It is exactly similar to cookie, but the header names change.

    May be as you said, it's does helpful for some users.

  11. ramaraochavali commented on Aug 29, 2022

    @ramaraochavali
    ContributorAuthor

    @wbpcode Can you please assign this to @Pawan-Bishnoi ?

  12. wbpcode commented on Aug 29, 2022

    @wbpcode
    Member
  13. repokitteh-read-only commented on Aug 29, 2022

    @repokitteh-read-only

    @Pawan-Bishnoi cannot be assigned to this issue.

    🐱

    Caused by: a #22475 (comment) was created by @wbpcode.

    see: more, trace.

  14. wbpcode commented on Aug 29, 2022

    @wbpcode
    Member

    Sorry, seems that @Pawan-Bishnoi is not member of this org. So i cannot assign this issue to him.

  15. ramaraochavali commented on Aug 29, 2022

    @ramaraochavali
    ContributorAuthor

    Ah. I remember. Only few people can add members to the org. @mattklein123 Can you please add @Pawan-Bishnoi to the org and assign this issue?

  16. Pawan-Bishnoi commented on Aug 30, 2022

    @Pawan-Bishnoi
    Contributor

    @mattklein123 I want to work on this. Please assign this to me.
    Thank you! 😄

  17. cpakulski commented on Sep 7, 2022

    @cpakulski
    Contributor

    I think that stateful_session filter could be easily extended for this use case.

    If I understood the idea correctly, the difference comparing to the current stateful_session is to automatically generate a new name instead of using a hardcoded one coming from the config (https://www.envoyproxy.io/docs/envoy/latest/api-v3/type/http/v3/cookie.proto#envoy-v3-api-msg-type-http-v3-cookie) for each new connection and pass it back to the client via response headers.

  18. Pawan-Bishnoi commented on Sep 8, 2022

    @Pawan-Bishnoi
    Contributor

    @cpakulski The header name should come from config (similar to cookie name). For example:

    http_filters:
     - name: envoy.filters.http.stateful_session
       typed_config:
         "@type": type.googleapis.com/envoy.extensions.filters.http.stateful_session.v3.StatefulSession
         session_state:
           name: envoy.http.stateful_session.header
           typed_config:
             "@type": type.googleapis.com/envoy.extensions.http.stateful_session.header.v3.HeaderBasedSessionState
              header:
                name: x-sticky-session-custom-header
                path: /session/v1/
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    design proposalenhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions