From 9e446b888187712be649fe7f61959633a5bf87ae Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Fri, 20 Sep 2024 00:16:10 +0100 Subject: [PATCH] Change Content-Type to plain text for logout and reset endpoints No text is returned so the response is not a valid JSON. --- auth_test.go | 2 +- token/jwt.go | 2 +- v2/auth_test.go | 2 +- v2/token/jwt.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/auth_test.go b/auth_test.go index 06a3b8aa..9f9fbece 100644 --- a/auth_test.go +++ b/auth_test.go @@ -298,7 +298,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")) + assert.Equal(t, "text/plain; charset=utf-8", resp.Header.Get("Content-Type")) defer resp.Body.Close() resp, err = client.Get("http://127.0.0.1:8089/private") diff --git a/token/jwt.go b/token/jwt.go index 73cc1c2c..56cae219 100644 --- a/token/jwt.go +++ b/token/jwt.go @@ -332,7 +332,7 @@ func (j *Service) Reset(w http.ResponseWriter) { 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") + w.Header().Set("Content-Type", "text/plain; charset=utf-8") } // checkAuds verifies if claims.Audience in the list of allowed by audReader diff --git a/v2/auth_test.go b/v2/auth_test.go index 81655bb6..0031d55e 100644 --- a/v2/auth_test.go +++ b/v2/auth_test.go @@ -298,7 +298,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")) + assert.Equal(t, "text/plain; charset=utf-8", resp.Header.Get("Content-Type")) defer resp.Body.Close() resp, err = client.Get("http://127.0.0.1:8089/private") diff --git a/v2/token/jwt.go b/v2/token/jwt.go index 8350ae85..729dc14c 100644 --- a/v2/token/jwt.go +++ b/v2/token/jwt.go @@ -354,7 +354,7 @@ func (j *Service) Reset(w http.ResponseWriter) { 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") + w.Header().Set("Content-Type", "text/plain; charset=utf-8") } // checkAuds verifies if claims.Audience in the list of allowed by audReader