mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-27 08:09:21 +00:00
fix: let scoped tokens reach shared_ui routes through the apps scope (#12141)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a1241914eb
commit
8e57691cbc
@@ -1473,6 +1473,19 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shared_ui_routes_use_apps_scopes() {
|
||||
let scopes = |s: &[&str]| s.iter().map(|s| s.to_string()).collect::<Vec<_>>();
|
||||
for route in ["shared_ui/get", "shared_ui/list", "shared_ui/version"] {
|
||||
let route = format!("/api/w/ws/{route}");
|
||||
assert!(check_route_access(&scopes(&["apps:read"]), &route, "GET").is_ok());
|
||||
assert!(check_route_access(&scopes(&["scripts:read"]), &route, "GET").is_err());
|
||||
}
|
||||
let put = "/api/w/ws/shared_ui";
|
||||
assert!(check_route_access(&scopes(&["apps:write"]), put, "PUT").is_ok());
|
||||
assert!(check_route_access(&scopes(&["apps:read"]), put, "PUT").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_flow_conversations_scope_access() {
|
||||
let read_scopes = vec!["flow_conversations:read".to_string()];
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
use crate::db::{ApiAuthed, DB};
|
||||
use crate::utils::check_scopes;
|
||||
use axum::{
|
||||
extract::{Extension, Json, Path},
|
||||
routing::{get, put},
|
||||
@@ -152,6 +153,9 @@ async fn update_shared_ui(
|
||||
Json(payload): Json<UpdateSharedUi>,
|
||||
) -> Result<String> {
|
||||
require_admin(authed.is_admin, &authed.username)?;
|
||||
// The route layer matches `apps:write:<paths>` too; the store is workspace-wide, so
|
||||
// only a grant spanning every app path may replace it.
|
||||
check_scopes(&authed, || "apps:write".to_string())?;
|
||||
|
||||
let files_json = serde_json::to_value(&payload.files)
|
||||
.map_err(|e| Error::internal_err(format!("serializing files: {e}")))?;
|
||||
|
||||
@@ -381,7 +381,9 @@ impl ScopeDomain {
|
||||
"data_metrics" => Some(Self::DataMetrics),
|
||||
"flows" => Some(Self::Flows),
|
||||
"flow_conversations" => Some(Self::FlowConversations),
|
||||
"apps" | "apps_u" => Some(Self::Apps),
|
||||
// `shared_ui` is the workspace `ui/` folder raw apps import from, so a token
|
||||
// that syncs apps reaches it without a scope of its own.
|
||||
"apps" | "apps_u" | "shared_ui" => Some(Self::Apps),
|
||||
"variables" => Some(Self::Variables),
|
||||
"resources" => Some(Self::Resources),
|
||||
"schedules" => Some(Self::Schedules),
|
||||
|
||||
Reference in New Issue
Block a user