Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ members = [
"crates/providers/fleet-provider-tailscale",
"crates/providers/fleet-provider-docker",
"crates/providers/fleet-provider-proxmox",
"crates/providers/fleet-provider-git",
"crates/providers/fleet-provider-github",
"crates/providers/fleet-provider-skills-manager",
"crates/providers/fleet-provider-frogenv",
Expand Down
18 changes: 16 additions & 2 deletions crates/fleet-application/src/authz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ pub enum Permission {
/// Execute an authorized apply plan on a machine. A mutation: it
/// composes every mutation the plan may run.
ApplyExecute,
/// Fetch and inspect candidates from the desired-state Git source. A
/// read, but a topology-revealing one.
SourceFetch,
/// Activate a validated candidate as the desired revision. A
/// mutation: it changes what Fleet converges machines toward.
SourceActivate,
}

impl Permission {
Expand Down Expand Up @@ -164,6 +170,8 @@ impl Permission {
Permission::MiseOperate,
Permission::ProjectsReady,
Permission::ApplyExecute,
Permission::SourceFetch,
Permission::SourceActivate,
];

/// The stable action id, as recorded in decisions and audit events.
Expand Down Expand Up @@ -204,6 +212,8 @@ impl Permission {
Permission::MiseOperate => "mise.operate",
Permission::ProjectsReady => "projects.ready",
Permission::ApplyExecute => "apply.execute",
Permission::SourceFetch => "source.fetch",
Permission::SourceActivate => "source.activate",
}
}

Expand Down Expand Up @@ -246,7 +256,9 @@ impl Permission {
| Permission::ToolsRead
| Permission::MiseOperate
| Permission::ProjectsReady
| Permission::ApplyExecute => true,
| Permission::ApplyExecute
| Permission::SourceFetch
| Permission::SourceActivate => true,
}
}

Expand All @@ -267,7 +279,9 @@ impl Permission {
| Permission::TailnetRead
| Permission::TailnetConfig
| Permission::ProjectsRead
| Permission::ProjectsCreate => false,
| Permission::ProjectsCreate
| Permission::SourceFetch
| Permission::SourceActivate => false,
Permission::MachineReadSensitive
| Permission::OperationCancel
| Permission::SecretRead
Expand Down
1 change: 1 addition & 0 deletions crates/fleet-application/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ pub mod operation;
pub mod planner;
pub mod project;
pub mod ready;
pub mod source;
pub mod tailnet;
pub mod worker;
18 changes: 16 additions & 2 deletions crates/fleet-application/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ use crate::authz::{AccessRequest, Authorizer, Decision, Permission, ReasonId, au
/// (FM-304); the ready workflow carries the machine-scoped shape plus
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
/// `projectId` and `dryRun` (FM-305); the apply workflow carries the
/// machine-scoped shape plus the plan and its approval identities
/// (FM-402).
pub const CREATABLE_KINDS: [&str; 29] = [
/// (FM-402); the source kinds carry the remote/commit payloads and are
/// catalog-level (FM-403).
pub const CREATABLE_KINDS: [&str; 31] = [
"noop",
"ssh.exec",
"agentless.inventory",
Expand Down Expand Up @@ -72,6 +73,8 @@ pub const CREATABLE_KINDS: [&str; 29] = [
"mise.exec",
"ready.workflow",
"apply.workflow",
"source.fetch",
"source.activate",
];

/// The machine-scoped permission a kind's creation requires, when any.
Expand All @@ -80,6 +83,16 @@ pub const CREATABLE_KINDS: [&str; 29] = [
/// governs both the dedicated endpoint and the generic one.
#[must_use]
fn machine_scoped_kind_permission(kind: &str, payload: Option<&str>) -> Option<Permission> {
// The source kinds are catalog-level: their permission is enforced
// here with `resource: None`, never a machine id.
match kind {
"source.fetch" => Some(Permission::SourceFetch),
"source.activate" => Some(Permission::SourceActivate),
_ => machine_scoped_kind_permission_inner(kind, payload),
}
}

fn machine_scoped_kind_permission_inner(kind: &str, payload: Option<&str>) -> Option<Permission> {
match kind {
"projects.discover" => Some(Permission::ProjectsDiscover),
"projects.clone" | "projects.pull" | "projects.status" => {
Expand Down Expand Up @@ -109,6 +122,7 @@ fn machine_scoped_kind_permission(kind: &str, payload: Option<&str>) -> Option<P
"mise.install" | "mise.exec" => Some(Permission::MiseOperate),
"ready.workflow" => Some(Permission::ProjectsReady),
"apply.workflow" => Some(Permission::ApplyExecute),

_ => None,
}
}
Expand Down
Loading