sessions

package
v0.0.0-...-5e73615 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package sessions implements proxy-side user session tracking for reverse proxies.

This is done by intercepting cookies set by the backend servers, storing them inside of "sessions" maintained by the proxy, and then replacing them by a single cookie used to track the user's proxy-side session.

Encapsulating all cookies into a single session cookie allows the proxy administrator to enforce cookie policies such as maximum cookie lifetimes or requiring cookies to be sent over SSL.

Note: This is designed for use in reverse proxies (where the same administrator controls both the proxy and the backing server). It would not be appropriate for traditional proxies (where the proxy and backend server are unrelated), as traditional proxies should just act as dumb pipes rather than components of an app that integrates the proxy with the backend server(s).

Example usage:

wrappedHandler := ...
...
sessionCookieName := "proxy-session-cookie-name"
sessionLifetime := 24*time.Hour
sessionCacheLimit := 100
c, err := sessions.NewCache(sessionCookieName, sessionLifetime, sessionCacheLimit, false)
h := c.SessionHandler(wrappedHandler)
...
h.ServeHTTP(w, r)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache represents a LRU cache to store sessions

func NewCache

func NewCache(sessionCookieName string, sessionCookieTimeout time.Duration, cookieCacheLimit int, disableSSLForTest bool) *Cache

NewCache initializes an LRU session cache

func (*Cache) SessionHandler

func (c *Cache) SessionHandler(wrapped http.Handler, metricHandler *metrics.MetricHandler) http.Handler

SessionHandler returns an instance of `http.Handler` that wraps the given handler and adds proxy-side session tracking.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL