forked from mtusi2026/mtusi2026lab2
исправлена валидация UTF-8 и Content-Type
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user