| 1 |
//! Command-line parser for `sq pki identify`. |
| 2 |
|
| 3 |
use clap::Parser; |
| 4 |
|
| 5 |
use crate::cli::examples; |
| 6 |
use examples::Action; |
| 7 |
use examples::Actions; |
| 8 |
|
| 9 |
use crate::cli::types::cert_designator; |
| 10 |
use crate::cli::types::CertDesignators; |
| 11 |
|
| 12 |
use super::CertificationNetworkArg; |
| 13 |
use super::GossipArg; |
| 14 |
use super::RequiredTrustAmountArg; |
| 15 |
use super::ShowPathsArg; |
| 16 |
use super::UnusableArg; |
| 17 |
|
| 18 |
/// Identify a certificate |
| 19 |
/// |
| 20 |
/// Identify a certificate by finding authenticated bindings (User |
| 21 |
/// ID and certificate pairs). |
| 22 |
/// |
| 23 |
/// An error is return if no binding could be authenticated to the |
| 24 |
/// specified level (by default: fully authenticated, i.e., a trust |
| 25 |
/// amount of 120). |
| 26 |
/// |
| 27 |
/// If a binding could be partially authenticated (i.e., its trust |
| 28 |
/// amount is greater than 0), then the binding is displayed, even |
| 29 |
/// if the trust is below the specified threshold. |
| 30 |
#[derive(Parser, Debug)] |
| 31 |
#[clap( |
| 32 |
name = "identify", |
| 33 |
after_help = EXAMPLES, |
| 34 |
)] |
| 35 |
pub struct Command { |
| 36 |
// Note: don't add --cert-file: the certificate needs to be merged |
| 37 |
// into the certificate store, and --cert-file doesn't do that. |
| 38 |
// Instead, the user should use --keyring FILE and --cert FPR. |
| 39 |
#[command(flatten)] |
| 40 |
pub cert: CertDesignators< |
| 41 |
cert_designator::CertArg, |
| 42 |
cert_designator::CertPrefix, |
| 43 |
cert_designator::OneValue>, |
| 44 |
|
| 45 |
#[command(flatten)] |
| 46 |
pub show_paths: ShowPathsArg, |
| 47 |
|
| 48 |
#[command(flatten)] |
| 49 |
pub gossip: GossipArg, |
| 50 |
|
| 51 |
#[command(flatten)] |
| 52 |
pub unusable: UnusableArg, |
| 53 |
|
| 54 |
#[command(flatten)] |
| 55 |
pub certification_network: CertificationNetworkArg, |
| 56 |
|
| 57 |
#[command(flatten)] |
| 58 |
pub trust_amount: RequiredTrustAmountArg, |
| 59 |
} |
| 60 |
|
| 61 |
const EXAMPLES: Actions = Actions { |
| 62 |
actions: &[ |
| 63 |
// Link Alice's certificate. |
| 64 |
Action::setup().command(&[ |
| 65 |
"sq", "pki", "link", "add", |
| 66 |
"--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 67 |
"--all", |
| 68 |
]).build(), |
| 69 |
|
| 70 |
Action::example().comment( |
| 71 |
"Identify the user IDs that can be authenticated for the certificate.", |
| 72 |
).command(&[ |
| 73 |
"sq", "pki", "identify", |
| 74 |
"--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 75 |
]).build(), |
| 76 |
|
| 77 |
Action::example().comment( |
| 78 |
"List all user IDs that have that have been certified by anyone.", |
| 79 |
).command(&[ |
| 80 |
"sq", "pki", "identify", "--gossip", |
| 81 |
"--cert", "511257EBBF077B7AEDAE5D093F68CB84CE537C9A", |
| 82 |
]).build(), |
| 83 |
], |
| 84 |
}; |
| 85 |
test_examples!(sq_pki_identify, EXAMPLES); |