mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
fix: exempt admins from default user group limits
This commit is contained in:
@@ -290,6 +290,7 @@ mod tests {
|
||||
user_rate_limit: None,
|
||||
api_key_rate_limit: None,
|
||||
api_key_is_standalone: false,
|
||||
admin_bypass_limits: false,
|
||||
local_rejection: None,
|
||||
allowed_models: Some(allowed_models),
|
||||
});
|
||||
|
||||
@@ -43,6 +43,8 @@ pub(crate) struct GatewayControlAuthContext {
|
||||
#[serde(skip)]
|
||||
pub(crate) api_key_is_standalone: bool,
|
||||
#[serde(skip)]
|
||||
pub(crate) admin_bypass_limits: bool,
|
||||
#[serde(skip)]
|
||||
pub(crate) local_rejection: Option<GatewayLocalAuthRejection>,
|
||||
#[serde(skip)]
|
||||
pub(crate) allowed_models: Option<Vec<String>>,
|
||||
@@ -512,6 +514,7 @@ pub(super) async fn resolve_data_backed_auth_context(
|
||||
user_rate_limit: None,
|
||||
api_key_rate_limit: None,
|
||||
api_key_is_standalone: false,
|
||||
admin_bypass_limits: false,
|
||||
local_rejection: Some(GatewayLocalAuthRejection::InvalidApiKey),
|
||||
allowed_models: None,
|
||||
}));
|
||||
@@ -568,6 +571,7 @@ async fn resolve_trusted_auth_context(
|
||||
user_rate_limit: None,
|
||||
api_key_rate_limit: None,
|
||||
api_key_is_standalone: false,
|
||||
admin_bypass_limits: false,
|
||||
local_rejection: Some(GatewayLocalAuthRejection::InvalidApiKey),
|
||||
allowed_models: None,
|
||||
}));
|
||||
@@ -656,6 +660,8 @@ async fn build_data_backed_auth_context(
|
||||
user_rate_limit: snapshot.user_rate_limit,
|
||||
api_key_rate_limit: snapshot.api_key_rate_limit,
|
||||
api_key_is_standalone: snapshot.api_key_is_standalone,
|
||||
admin_bypass_limits: snapshot.user_role.eq_ignore_ascii_case("admin")
|
||||
&& !snapshot.api_key_is_standalone,
|
||||
local_rejection,
|
||||
allowed_models,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user