From 812aabe5da94b92906891c8265830f8864b79ba9 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Tue, 23 Mar 2021 13:13:53 +0000 Subject: [PATCH] Remove old cookie builder functions --- pkg/cookies/cookies.go | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/pkg/cookies/cookies.go b/pkg/cookies/cookies.go index dc1bff76..2375b8c3 100644 --- a/pkg/cookies/cookies.go +++ b/pkg/cookies/cookies.go @@ -5,42 +5,11 @@ import ( "net" "net/http" "strings" - "time" - "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger" requestutil "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/requests/util" ) -// MakeCookieFromOptions constructs a cookie based on the given *options.CookieOptions, -// value and creation time -func MakeCookieFromOptions(req *http.Request, name string, value string, opts *options.Cookie, expiration time.Duration, now time.Time) *http.Cookie { - domain := GetCookieDomain(req, opts.Domains) - // If nothing matches, create the cookie with the shortest domain - if domain == "" && len(opts.Domains) > 0 { - logger.Errorf("Warning: request host %q did not match any of the specific cookie domains of %q", - requestutil.GetRequestHost(req), - strings.Join(opts.Domains, ","), - ) - domain = opts.Domains[len(opts.Domains)-1] - } - - c := &http.Cookie{ - Name: name, - Value: value, - Path: opts.Path, - Domain: domain, - Expires: now.Add(expiration), - HttpOnly: opts.HTTPOnly, - Secure: opts.Secure, - SameSite: ParseSameSite(opts.SameSite), - } - - warnInvalidDomain(c, req) - - return c -} - // GetCookieDomain returns the correct cookie domain given a list of domains // by checking the X-Fowarded-Host and host header of an an http request func GetCookieDomain(req *http.Request, cookieDomains []string) string {