mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
Merge remote-tracking branch 'upstream/aether-rust-pioneer' into fix-management-token-oauth-jsonb
# Conflicts: # crates/aether-data/src/lifecycle/bootstrap/postgres.rs # crates/aether-data/src/lifecycle/migrate/tests.rs
This commit is contained in:
@@ -152,6 +152,11 @@ const PERMISSION_GROUPS: &[PermissionGroup] = &[
|
||||
label: "系统",
|
||||
assignable: true,
|
||||
},
|
||||
PermissionGroup {
|
||||
scope: "tasks",
|
||||
label: "后台任务",
|
||||
assignable: true,
|
||||
},
|
||||
PermissionGroup {
|
||||
scope: "usage",
|
||||
label: "用量",
|
||||
@@ -434,6 +439,9 @@ fn permission_key(scope: &str, access: &str) -> &'static str {
|
||||
("system", "read") => "admin:system:read",
|
||||
("system", "write") => "admin:system:write",
|
||||
("system", "admin") => "admin:system:admin",
|
||||
("tasks", "read") => "admin:tasks:read",
|
||||
("tasks", "write") => "admin:tasks:write",
|
||||
("tasks", "admin") => "admin:tasks:admin",
|
||||
("usage", "read") => "admin:usage:read",
|
||||
("usage", "write") => "admin:usage:write",
|
||||
("usage", "admin") => "admin:usage:admin",
|
||||
@@ -492,6 +500,7 @@ mod tests {
|
||||
"security",
|
||||
"stats",
|
||||
"system",
|
||||
"tasks",
|
||||
"usage",
|
||||
"users",
|
||||
"video_tasks",
|
||||
|
||||
@@ -46,6 +46,83 @@ pub(super) fn classify_admin_operations_family_route(
|
||||
"admin:video_tasks",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET
|
||||
&& matches!(normalized_path, "/api/admin/tasks" | "/api/admin/tasks/")
|
||||
{
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"tasks_manage",
|
||||
"list_tasks",
|
||||
"admin:tasks",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET
|
||||
&& matches!(
|
||||
normalized_path,
|
||||
"/api/admin/tasks/stats" | "/api/admin/tasks/stats/"
|
||||
)
|
||||
{
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"tasks_manage",
|
||||
"stats",
|
||||
"admin:tasks",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET
|
||||
&& normalized_path.starts_with("/api/admin/tasks/")
|
||||
&& normalized_path.ends_with("/events")
|
||||
&& normalized_path.matches('/').count() == 5
|
||||
{
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"tasks_manage",
|
||||
"events",
|
||||
"admin:tasks",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST
|
||||
&& normalized_path.starts_with("/api/admin/tasks/")
|
||||
&& normalized_path.ends_with("/cancel")
|
||||
&& normalized_path.matches('/').count() == 5
|
||||
{
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"tasks_manage",
|
||||
"cancel",
|
||||
"admin:tasks",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST
|
||||
&& normalized_path.starts_with("/api/admin/tasks/")
|
||||
&& normalized_path.ends_with("/trigger")
|
||||
&& normalized_path.matches('/').count() == 5
|
||||
{
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"tasks_manage",
|
||||
"trigger",
|
||||
"admin:tasks",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET
|
||||
&& normalized_path.starts_with("/api/admin/tasks/")
|
||||
&& normalized_path["/api/admin/tasks/".len()..]
|
||||
.split('/')
|
||||
.count()
|
||||
== 1
|
||||
&& !matches!(
|
||||
normalized_path,
|
||||
"/api/admin/tasks/stats" | "/api/admin/tasks/stats/"
|
||||
)
|
||||
{
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"tasks_manage",
|
||||
"detail",
|
||||
"admin:tasks",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET
|
||||
&& normalized_path.starts_with("/api/admin/video-tasks/")
|
||||
&& normalized_path.ends_with("/video")
|
||||
|
||||
@@ -95,6 +95,14 @@ pub(super) fn classify_admin_system_family_route(
|
||||
"admin:system",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET && normalized_path == "/api/admin/system/cleanup/runs" {
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"system_manage",
|
||||
"cleanup_runs",
|
||||
"admin:system",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST && normalized_path == "/api/admin/system/purge/config" {
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
@@ -139,6 +147,16 @@ pub(super) fn classify_admin_system_family_route(
|
||||
"admin:system",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST
|
||||
&& normalized_path == "/api/admin/system/purge/request-bodies/task"
|
||||
{
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"system_manage",
|
||||
"purge_request_bodies_task",
|
||||
"admin:system",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST && normalized_path == "/api/admin/system/purge/stats" {
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
|
||||
@@ -172,6 +172,10 @@ fn classifies_admin_system_maintenance_write_routes_as_admin_proxy_route() {
|
||||
"/api/admin/system/purge/request-bodies",
|
||||
"purge_request_bodies",
|
||||
),
|
||||
(
|
||||
"/api/admin/system/purge/request-bodies/task",
|
||||
"purge_request_bodies_task",
|
||||
),
|
||||
("/api/admin/system/purge/stats", "purge_stats"),
|
||||
];
|
||||
|
||||
@@ -246,6 +250,25 @@ fn classifies_admin_system_stats_as_admin_proxy_route() {
|
||||
assert!(!decision.is_execution_runtime_candidate());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classifies_admin_system_cleanup_runs_as_admin_proxy_route() {
|
||||
let headers = headers(&[]);
|
||||
let uri: Uri = "/api/admin/system/cleanup/runs"
|
||||
.parse()
|
||||
.expect("uri should parse");
|
||||
let decision =
|
||||
classify_control_route(&http::Method::GET, &uri, &headers).expect("route should classify");
|
||||
|
||||
assert_eq!(decision.route_class.as_deref(), Some("admin_proxy"));
|
||||
assert_eq!(decision.route_family.as_deref(), Some("system_manage"));
|
||||
assert_eq!(decision.route_kind.as_deref(), Some("cleanup_runs"));
|
||||
assert_eq!(
|
||||
decision.auth_endpoint_signature.as_deref(),
|
||||
Some("admin:system")
|
||||
);
|
||||
assert!(!decision.is_execution_runtime_candidate());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classifies_admin_system_settings_set_as_admin_proxy_route() {
|
||||
let headers = headers(&[]);
|
||||
|
||||
Reference in New Issue
Block a user