Skip to content

Commit

Permalink
fix too many forward_auth cookies (#3)
Browse files Browse the repository at this point in the history
* fix too many forward_auth cookies

* fix missing csrf cookie

Co-authored-by: orvice <orvice@gmail.com>
  • Loading branch information
jordemort and orvice authored Nov 5, 2022
1 parent f66cb9a commit 0b3b8f8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"net/url"
"strings"

"github.com/containous/traefik/v2/pkg/rules"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -225,6 +226,12 @@ func (s *Server) authRedirect(logger *logrus.Entry, w http.ResponseWriter, r *ht
return
}

// clean existing CSRF cookie
for _, v := range r.Cookies() {
if strings.Contains(v.Name, config.CSRFCookieName) {
http.SetCookie(w, ClearCSRFCookie(r, v))
}
}
// Set the CSRF cookie
csrf := MakeCSRFCookie(r, nonce)
http.SetCookie(w, csrf)
Expand Down

0 comments on commit 0b3b8f8

Please sign in to comment.