Skip to content

Commit ff03323

Browse files
Fix request tracker cookie delete (crewjam#549)
Currently when stopping tracking a request the SP tried to delete the relevant cookie by setting it again with an empty value and and expired time. This doesn't work since the path doesn't match the one of the original cookie. Fixed by setting the delete cookie path using the same ACS path.
1 parent 73942bd commit ff03323

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

samlsp/middleware_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ func TestMiddlewareCanParseResponse(t *testing.T) {
409409

410410
assert.Check(t, is.Equal("/frob", resp.Header().Get("Location")))
411411
assert.Check(t, is.DeepEqual([]string{
412-
"saml_KCosLjAyNDY4Ojw-QEJERkhKTE5QUlRWWFpcXmBiZGZoamxucHJ0dnh6=; Domain=15661444.ngrok.io; Expires=Thu, 01 Jan 1970 00:00:01 GMT",
412+
"saml_KCosLjAyNDY4Ojw-QEJERkhKTE5QUlRWWFpcXmBiZGZoamxucHJ0dnh6=; Path=/saml2/acs; Domain=15661444.ngrok.io; Expires=Thu, 01 Jan 1970 00:00:01 GMT",
413413
"ttt=" + test.expectedSessionCookie + "; " +
414414
"Path=/; Domain=15661444.ngrok.io; Max-Age=7200; HttpOnly; Secure"},
415415
resp.Header()["Set-Cookie"]))

samlsp/request_tracker_cookie.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func (t CookieRequestTracker) StopTrackingRequest(w http.ResponseWriter, r *http
6767
cookie.Value = ""
6868
cookie.Domain = t.ServiceProvider.AcsURL.Hostname()
6969
cookie.Expires = time.Unix(1, 0) // past time as close to epoch as possible, but not zero time.Time{}
70+
cookie.Path = t.ServiceProvider.AcsURL.Path
7071
http.SetCookie(w, cookie)
7172
return nil
7273
}

0 commit comments

Comments
 (0)