исправлена валидация UTF-8 и Content-Type

This commit is contained in:
2026-10-16 15:34:17 +03:00
parent 9fabf8dff3
commit fe52c2a99f
7 changed files with 331 additions and 17 deletions
+3 -1
View File
@@ -4,6 +4,7 @@ import (
"errors"
"net/http"
"time"
"unicode/utf8"
"mtusi2026lab2/internal/domain"
"mtusi2026lab2/internal/security"
@@ -28,7 +29,8 @@ func (h *Handler) CreateSession(
requestID := middleware.GetRequestID(r.Context())
username, password, ok := r.BasicAuth()
if !ok || username == "" {
if !ok || username == "" ||
!utf8.ValidString(username) || !utf8.ValidString(password) {
writeBasicUnauthorized(w, requestID)
return
}