src/server/rest.rs: reduce delay for permission error to 500ms
This commit is contained in:
parent
1cf7bbf412
commit
9989d2c4e9
@ -521,6 +521,7 @@ pub async fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> Result<R
|
|||||||
let user_info = CachedUserInfo::new()?;
|
let user_info = CachedUserInfo::new()?;
|
||||||
|
|
||||||
let delay_unauth_time = std::time::Instant::now() + std::time::Duration::from_millis(3000);
|
let delay_unauth_time = std::time::Instant::now() + std::time::Duration::from_millis(3000);
|
||||||
|
let access_forbidden_time = std::time::Instant::now() + std::time::Duration::from_millis(500);
|
||||||
|
|
||||||
if comp_len >= 1 && components[0] == "api2" {
|
if comp_len >= 1 && components[0] == "api2" {
|
||||||
|
|
||||||
@ -563,7 +564,7 @@ pub async fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> Result<R
|
|||||||
let user = rpcenv.get_user();
|
let user = rpcenv.get_user();
|
||||||
if !check_api_permission(api_method.access.permission, user.as_deref(), &uri_param, &user_info) {
|
if !check_api_permission(api_method.access.permission, user.as_deref(), &uri_param, &user_info) {
|
||||||
let err = http_err!(FORBIDDEN, format!("permission check failed"));
|
let err = http_err!(FORBIDDEN, format!("permission check failed"));
|
||||||
tokio::time::delay_until(Instant::from_std(delay_unauth_time)).await;
|
tokio::time::delay_until(Instant::from_std(access_forbidden_time)).await;
|
||||||
return Ok((formatter.format_error)(err));
|
return Ok((formatter.format_error)(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user