lab7: безопасность, mTLS, OpenBao и PKI lifecycle

This commit is contained in:
Vladislav Kunetskiy
2026-11-10 10:58:07 +03:00
parent 3d216fbd50
commit 3441f2269a
183 changed files with 216667 additions and 3165 deletions
+5 -1
View File
@@ -10,6 +10,7 @@ import (
"github.com/ogen-go/ogen/ogenerrors"
"mtusi-messenger/internal/domain"
"mtusi-messenger/internal/platform/password"
"mtusi-messenger/internal/transport/rest/internal/oas"
)
@@ -70,7 +71,7 @@ func statusForDomainError(err error) int {
errors.Is(err, domain.ErrUnknownMember),
errors.Is(err, domain.ErrInvalidCursor):
return http.StatusBadRequest
case errors.Is(err, domain.ErrRateLimited):
case errors.Is(err, domain.ErrRateLimited), errors.Is(err, password.ErrBusy):
return http.StatusTooManyRequests
case errors.Is(err, domain.ErrTooLarge):
return http.StatusRequestEntityTooLarge
@@ -120,6 +121,9 @@ func writeError(ctx context.Context, log *slog.Logger, w http.ResponseWriter, r
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.Header().Set(requestIDHeader, requestID)
if status == http.StatusTooManyRequests && w.Header().Get("Retry-After") == "" {
w.Header().Set("Retry-After", "1")
}
if status == http.StatusUnauthorized {
challenge := `Bearer realm="messenger"`
if r.URL.Path == "/api/v1/auth/sessions" {