Extract reusable keychain sigchain model
This commit is contained in:
parent
5b2c30f817
commit
4013c868aa
11 changed files with 938 additions and 20 deletions
|
|
@ -635,6 +635,27 @@ pub enum KeychainCommand {
|
|||
signing_key: Option<PathBuf>,
|
||||
},
|
||||
Status,
|
||||
AdminAdd {
|
||||
#[arg(long)]
|
||||
admin_key: PathBuf,
|
||||
#[arg(long)]
|
||||
signing_key: PathBuf,
|
||||
#[arg(long)]
|
||||
principal: Option<String>,
|
||||
#[arg(long)]
|
||||
valid_after_ms: Option<i64>,
|
||||
#[arg(long)]
|
||||
valid_before_ms: Option<i64>,
|
||||
},
|
||||
AdminRevoke {
|
||||
key: String,
|
||||
#[arg(long)]
|
||||
signing_key: PathBuf,
|
||||
#[arg(long)]
|
||||
admin_key: Option<PathBuf>,
|
||||
},
|
||||
AllowedSigners,
|
||||
Verify,
|
||||
Sync {
|
||||
node: String,
|
||||
},
|
||||
|
|
@ -1432,6 +1453,40 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
Command::Keychain {
|
||||
command: KeychainCommand::Status,
|
||||
} => ControlRequest::KeychainStatus,
|
||||
Command::Keychain {
|
||||
command:
|
||||
KeychainCommand::AdminAdd {
|
||||
admin_key,
|
||||
signing_key,
|
||||
principal,
|
||||
valid_after_ms,
|
||||
valid_before_ms,
|
||||
},
|
||||
} => ControlRequest::KeychainAdminAdd {
|
||||
admin_key_path: admin_key,
|
||||
signing_key_path: signing_key,
|
||||
principal,
|
||||
valid_after_ms,
|
||||
valid_before_ms,
|
||||
},
|
||||
Command::Keychain {
|
||||
command:
|
||||
KeychainCommand::AdminRevoke {
|
||||
key,
|
||||
signing_key,
|
||||
admin_key,
|
||||
},
|
||||
} => ControlRequest::KeychainAdminRevoke {
|
||||
key,
|
||||
signing_key_path: signing_key,
|
||||
admin_key_path: admin_key,
|
||||
},
|
||||
Command::Keychain {
|
||||
command: KeychainCommand::AllowedSigners,
|
||||
} => ControlRequest::KeychainAllowedSigners,
|
||||
Command::Keychain {
|
||||
command: KeychainCommand::Verify,
|
||||
} => ControlRequest::KeychainVerify,
|
||||
Command::Keychain {
|
||||
command: KeychainCommand::Sync { node },
|
||||
} => ControlRequest::KeychainSync { node },
|
||||
|
|
@ -2458,6 +2513,47 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
);
|
||||
}
|
||||
}
|
||||
ControlResponse::KeychainAdminUpdated {
|
||||
op,
|
||||
signatures,
|
||||
note,
|
||||
} => {
|
||||
println!("recorded keychain op: {}", op.id);
|
||||
for signature in signatures {
|
||||
println!(
|
||||
"signed keychain op: {} by {} ({})",
|
||||
signature.op_id, signature.signer, signature.namespace
|
||||
);
|
||||
}
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::KeychainAllowedSigners {
|
||||
allowed_signers,
|
||||
note,
|
||||
..
|
||||
} => {
|
||||
print!("{allowed_signers}");
|
||||
if allowed_signers.is_empty() {
|
||||
println!("no active admin public keys available");
|
||||
}
|
||||
eprintln!("note: {note}");
|
||||
}
|
||||
ControlResponse::KeychainVerified { report } => {
|
||||
println!("ops: {}", report.ops);
|
||||
println!("signatures: {}", report.signatures);
|
||||
println!("accepted_ops: {}", report.accepted_ops);
|
||||
println!("rejected_ops: {}", report.rejected_ops);
|
||||
println!("active_admin_keys: {}", report.active_admin_keys);
|
||||
println!(
|
||||
"accepted_head: {}",
|
||||
report
|
||||
.accepted_head
|
||||
.as_ref()
|
||||
.map(|head| head.as_str())
|
||||
.unwrap_or("none")
|
||||
);
|
||||
println!("note: {}", report.note);
|
||||
}
|
||||
ControlResponse::KeychainSynced {
|
||||
peer_node_id,
|
||||
peer_agent_id,
|
||||
|
|
|
|||
Loading…
Reference in a new issue