forked from mtusi2026/mtusi2026lab7
lab7: безопасность, mTLS, OpenBao и PKI lifecycle
This commit is contained in:
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user