formatting and comments
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
//! Axum HTTP/WebSocket adapter and public trust boundary.
|
||||
//!
|
||||
//! Handlers derive the tenant from a server-side session cookie; owner IDs from
|
||||
//! request bodies are never trusted. This module also enforces same-origin
|
||||
//! mutation checks, response cache policy, component-token WebSocket
|
||||
//! authentication, bounded request bodies and security headers for the static
|
||||
//! control console and OBS entry point.
|
||||
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use axum::{
|
||||
@@ -326,7 +334,7 @@ async fn login(
|
||||
Ok(result) => result,
|
||||
Err(error) => {
|
||||
state.login_limiter.failure(&body.username, &ip).await;
|
||||
return Err(ApiError::from(error).as_generic_login());
|
||||
return Err(ApiError::from(error).into_generic_login());
|
||||
}
|
||||
};
|
||||
state.login_limiter.success(&body.username, &ip).await;
|
||||
@@ -1146,7 +1154,7 @@ impl ApiError {
|
||||
self
|
||||
}
|
||||
|
||||
fn as_generic_login(mut self) -> Self {
|
||||
fn into_generic_login(mut self) -> Self {
|
||||
if self.status != StatusCode::TOO_MANY_REQUESTS {
|
||||
self.status = StatusCode::UNAUTHORIZED;
|
||||
self.code = "invalid_credentials";
|
||||
@@ -1170,10 +1178,10 @@ impl IntoResponse for ApiError {
|
||||
}),
|
||||
)
|
||||
.into_response();
|
||||
if let Some(retry_after) = self.retry_after {
|
||||
if let Ok(value) = HeaderValue::from_str(&retry_after.as_secs().max(1).to_string()) {
|
||||
response.headers_mut().insert(header::RETRY_AFTER, value);
|
||||
}
|
||||
if let Some(retry_after) = self.retry_after
|
||||
&& let Ok(value) = HeaderValue::from_str(&retry_after.as_secs().max(1).to_string())
|
||||
{
|
||||
response.headers_mut().insert(header::RETRY_AFTER, value);
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user