Skip to content

Commit e1ad684

Browse files
authored
Merge pull request #3 from checkpt/SM/fix-csrf-cookie-build-up
remove all csrf tokens before creating a new one
2 parents 3fa6c6b + 817523a commit e1ad684

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

internal/server.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tfa
33
import (
44
"net/http"
55
"net/url"
6+
"strings"
67

78
"github.com/containous/traefik/v2/pkg/rules"
89
"github.com/sirupsen/logrus"
@@ -83,7 +84,6 @@ func (s *Server) AuthHandler(providerName, rule string) http.HandlerFunc {
8384
return func(w http.ResponseWriter, r *http.Request) {
8485
// Logging setup
8586
logger := s.logger(r, "Auth", rule, "Authenticating request")
86-
8787
// Get auth cookie
8888
c, err := r.Cookie(config.CookieName)
8989
if err != nil {
@@ -238,6 +238,12 @@ func (s *Server) authRedirect(logger *logrus.Entry, w http.ResponseWriter, r *ht
238238
return
239239
}
240240

241+
for _, v := range r.Cookies() {
242+
if strings.Contains(v.Name, config.CSRFCookieName) {
243+
http.SetCookie(w, ClearCSRFCookie(r, v))
244+
}
245+
}
246+
241247
// Set the CSRF cookie
242248
csrf := MakeCSRFCookie(r, nonce)
243249
http.SetCookie(w, csrf)

0 commit comments

Comments
 (0)