Enforce SSH workflow capabilities locally

This commit is contained in:
Eric Wendland 2026-05-19 15:44:13 +02:00
commit f7e85960f7
8 changed files with 328 additions and 62 deletions

View file

@ -403,8 +403,13 @@ pub enum SshCertCommand {
renewal_of: Option<String>,
#[arg(long)]
reason: Option<String>,
#[arg(long)]
subject: Option<String>,
},
Requests {
#[arg(long)]
subject: Option<String>,
},
Requests,
Approve {
request_id: String,
#[arg(long)]
@ -415,13 +420,20 @@ pub enum SshCertCommand {
serial: Option<u64>,
#[arg(long)]
out: Option<PathBuf>,
#[arg(long)]
subject: Option<String>,
},
Import {
request_id: String,
#[arg(long)]
cert: PathBuf,
#[arg(long)]
subject: Option<String>,
},
List {
#[arg(long)]
subject: Option<String>,
},
List,
Sync {
node: String,
},
@ -434,8 +446,13 @@ pub enum SshRevocationCommand {
target: String,
#[arg(long)]
reason: Option<String>,
#[arg(long)]
subject: Option<String>,
},
List {
#[arg(long)]
subject: Option<String>,
},
List,
Export {
#[arg(long)]
out: PathBuf,
@ -443,11 +460,15 @@ pub enum SshRevocationCommand {
format: String,
#[arg(long)]
ca_public: Option<PathBuf>,
#[arg(long)]
subject: Option<String>,
},
Import {
path: PathBuf,
#[arg(long, default_value = "jsonl")]
format: String,
#[arg(long)]
subject: Option<String>,
},
Sync {
node: String,
@ -701,6 +722,7 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
valid_for,
renewal_of,
reason,
subject,
} => ControlRequest::SshCertRequest {
public_key_path: public_key,
cert_kind: kind,
@ -708,26 +730,34 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
requested_validity: valid_for,
renewal_of,
reason,
subject,
},
SshCertCommand::Requests => ControlRequest::SshCertRequests,
SshCertCommand::Requests { subject } => ControlRequest::SshCertRequests { subject },
SshCertCommand::Approve {
request_id,
ca_key,
valid_for,
serial,
out,
subject,
} => ControlRequest::SshCertApprove {
request_id,
ca_key_path: ca_key,
valid_for,
serial,
out,
subject,
},
SshCertCommand::Import { request_id, cert } => ControlRequest::SshCertImport {
SshCertCommand::Import {
request_id,
cert,
subject,
} => ControlRequest::SshCertImport {
request_id,
cert_path: cert,
subject,
},
SshCertCommand::List => ControlRequest::SshCertList,
SshCertCommand::List { subject } => ControlRequest::SshCertList { subject },
SshCertCommand::Sync { node } => ControlRequest::SshCertSync { node },
},
SshCommand::Revocation { command } => match command {
@ -735,24 +765,36 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
kind,
target,
reason,
subject,
} => ControlRequest::SshRevocationAdd {
kind,
target,
reason,
subject,
},
SshRevocationCommand::List => ControlRequest::SshRevocationList,
SshRevocationCommand::List { subject } => {
ControlRequest::SshRevocationList { subject }
}
SshRevocationCommand::Export {
out,
format,
ca_public,
subject,
} => ControlRequest::SshRevocationExport {
out,
format,
ca_public,
subject,
},
SshRevocationCommand::Import {
path,
format,
subject,
} => ControlRequest::SshRevocationImport {
path,
format,
subject,
},
SshRevocationCommand::Import { path, format } => {
ControlRequest::SshRevocationImport { path, format }
}
SshRevocationCommand::Sync { node } => ControlRequest::SshRevocationSync { node },
},
},