forked from mtusi2026/mtusi2026lab7
Перевести пароли на Argon2id и читать секреты через AppRole.
Лимит входа общий для реплик, размер тела ограничен, исходящие клиенты проверяют TLS, если задан CA. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+12
-3
@@ -20,11 +20,18 @@ BEARER_CHALLENGE = 'Bearer realm="messenger"'
|
||||
|
||||
|
||||
class AppError(Exception):
|
||||
def __init__(self, status: int, message: str, www_authenticate: str | None = None) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
status: int,
|
||||
message: str,
|
||||
www_authenticate: str | None = None,
|
||||
headers: Optional[Dict[str, str]] = None,
|
||||
) -> None:
|
||||
super().__init__(message)
|
||||
self.status = status
|
||||
self.message = message
|
||||
self.www_authenticate = www_authenticate
|
||||
self.headers = headers or {}
|
||||
|
||||
|
||||
def error_response(
|
||||
@@ -45,5 +52,7 @@ def error_response(
|
||||
|
||||
|
||||
def from_app_error(exc: AppError, request_id: str) -> JSONResponse:
|
||||
extra = {"WWW-Authenticate": exc.www_authenticate} if exc.www_authenticate else None
|
||||
return error_response(exc.status, exc.message, request_id, extra)
|
||||
extra: Dict[str, str] = dict(exc.headers)
|
||||
if exc.www_authenticate:
|
||||
extra["WWW-Authenticate"] = exc.www_authenticate
|
||||
return error_response(exc.status, exc.message, request_id, extra or None)
|
||||
|
||||
Reference in New Issue
Block a user