fix: exclude RefreshToken from JSON response (G117)
CI / Env docs check (push) Successful in 8s
CI / Docker compose check (push) Successful in 14s
CI / Nginx config check (push) Successful in 17s
CI / Frontend deps check (push) Successful in 31s
CI / Frontend major deps (push) Failing after 32s
CI / Secrets scan (push) Successful in 38s
CI / Go build (push) Successful in 39s
CI / Frontend build (push) Successful in 1m14s
CI / Knip (push) Successful in 37s
CI / Frontend a11y check (push) Failing after 1m52s
CI / Go vet (prod) (push) Successful in 1m51s
CI / Go vet (dev) (push) Successful in 1m51s
CI / Staticcheck (prod) (push) Failing after 2m2s
CI / Staticcheck (dev) (push) Failing after 2m3s
CI / golangci-lint (push) Successful in 2m10s
CI / go mod tidy (push) Successful in 48s
CI / Frontend QC (audit) (push) Successful in 47s
CI / Frontend QC (lint) (push) Failing after 1m0s
CI / Go vulnerabilities (push) Successful in 1m14s
CI / Frontend QC (typecheck) (push) Failing after 1m10s
CI / Svelte strict check (push) Has been skipped
CI / Security scan (prod) (push) Failing after 4m5s
CI / Security scan (dev) (push) Failing after 4m11s
CI / Tests (prod) (push) Has been skipped
CI / Tests (dev) (push) Has been skipped
CI / Race (prod) (push) Has been skipped
CI / Race (dev) (push) Has been skipped

This commit is contained in:
2026-07-10 12:09:54 +01:00
parent cb09020b0d
commit 9ea929901a
2 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ var TokenAuth *jwtauth.JWTAuth
type AuthResponse struct {
Token string `json:"token"`
JTI string `json:"jti"`
RefreshToken string `json:"refreshToken,omitempty"`
RefreshToken string `json:"-"`
}
// generateJTI generates a UUID v4 string using crypto/rand
+9 -5
View File
@@ -1747,9 +1747,9 @@ func TestJTI_Revocation_PostgreSQL(t *testing.T) {
// Login Response Field Tests (new from security pass)
// =============================================================================
// TestLogin_ResponseIncludesRefreshToken verifies the login response
// includes a refreshToken field alongside the JWT.
func TestLogin_ResponseIncludesRefreshToken(t *testing.T) {
// TestLogin_ResponseOmitsRefreshToken verifies the login response
// does not include refreshToken (G117 — 90-day credential excluded from JSON).
func TestLogin_ResponseOmitsRefreshToken(t *testing.T) {
ctx, tx := resetTestData(t)
handler := http.HandlerFunc(LoginHandler)
@@ -1771,6 +1771,10 @@ func TestLogin_ResponseIncludesRefreshToken(t *testing.T) {
t.Fatalf("expected 200, got %d. body: %s", w.Code, w.Body.String())
}
if strings.Contains(w.Body.String(), "refreshToken") {
t.Error("login response should NOT contain refreshToken (G117)")
}
var resp struct {
Token string `json:"token"`
JTI string `json:"jti"`
@@ -1786,8 +1790,8 @@ func TestLogin_ResponseIncludesRefreshToken(t *testing.T) {
if resp.JTI == "" {
t.Error("expected non-empty jti")
}
if resp.RefreshToken == "" {
t.Error("expected non-empty refreshToken in login response")
if resp.RefreshToken != "" {
t.Error("refreshToken should be excluded from JSON response (G117)")
}
}