Skip to content

Commit

Permalink
Merge pull request #203 from iRay/fix-logout-empty-header
Browse files Browse the repository at this point in the history
Set proper "content-type" while calling JwtService.Reset()
  • Loading branch information
umputun authored Jun 18, 2024
2 parents e0ea38d + baf4355 commit 733697d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func TestLogout(t *testing.T) {
resp, err = client.Get("http://127.0.0.1:8089/auth/logout")
require.Nil(t, err)
assert.Equal(t, 200, resp.StatusCode)
assert.Equal(t, "application/json; charset=utf-8", resp.Header.Get("Content-Type"))
defer resp.Body.Close()

resp, err = client.Get("http://127.0.0.1:8089/private")
Expand Down
2 changes: 2 additions & 0 deletions token/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ func (j *Service) Reset(w http.ResponseWriter) {
xsrfCookie := http.Cookie{Name: j.XSRFCookieName, Value: "", HttpOnly: false, Path: "/", Domain: j.JWTCookieDomain,
MaxAge: -1, Expires: time.Unix(0, 0), Secure: j.SecureCookies, SameSite: j.SameSite}
http.SetCookie(w, &xsrfCookie)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
}

// checkAuds verifies if claims.Audience in the list of allowed by audReader
Expand Down
1 change: 1 addition & 0 deletions v2/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func TestLogout(t *testing.T) {
resp, err = client.Get("http://127.0.0.1:8089/auth/logout")
require.Nil(t, err)
assert.Equal(t, 200, resp.StatusCode)
assert.Equal(t, "application/json; charset=utf-8", resp.Header.Get("Content-Type"))
defer resp.Body.Close()

resp, err = client.Get("http://127.0.0.1:8089/private")
Expand Down
2 changes: 2 additions & 0 deletions v2/token/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ func (j *Service) Reset(w http.ResponseWriter) {
xsrfCookie := http.Cookie{Name: j.XSRFCookieName, Value: "", HttpOnly: false, Path: "/", Domain: j.JWTCookieDomain,
MaxAge: -1, Expires: time.Unix(0, 0), Secure: j.SecureCookies, SameSite: j.SameSite}
http.SetCookie(w, &xsrfCookie)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
}

// checkAuds verifies if claims.Audience in the list of allowed by audReader
Expand Down

0 comments on commit 733697d

Please sign in to comment.