Debian Codegraph @

src/cli/pki/vouch.rs

raw
1 //! Command-line parser for `sq pki vouch`.
2
3 pub mod authorize;
4 pub mod add;
5 pub mod list;
6 pub mod replay;
7
8 use clap::{Parser, Subcommand};
9
10 use crate::cli::examples::*;
11
12 /// Key for the help augmentation.
13 pub const CERTIFIER_SELF: &str = "pki.vouch.certifier-self";
14
15 /// Key for the help augmentation.
16 pub const CERTIFICATION_EXPIRATION: &str = "pki.vouch.expiration";
17
18 #[derive(Parser, Debug)]
19 #[clap(
20 name = "vouch",
21 about = "Manage certifications",
22 long_about =
23 "Manage certifications
24
25 A vouch is a potentially public statement that something is true. In \
26 OpenPGP there are two main types of statements that you can make: \
27 certifications, and authorizations.
28
29 You can assert that a certificate belongs to a particular entity. \
30 This says nothing about an entity's trustworthiness. For instance, \
31 you might certify `[email protected]` for a given certificate. This just \
32 means that you think the person behind the email address `[email protected]` \
33 really controls that certificate. That's a useful statement to make \
34 even if you don't trust that person to act in your interest.
35
36 Alternatively you can say that you believe a certificate is a \
37 reasonable trusted introducer. A trusted introducer is a third-party \
38 that you authorize to make introductions. For instance, your bank \
39 might have a certification authority (CA). If you verify the CA's \
40 fingerprint, you can authorize it to make certifications. That means \
41 that sq will use those certifications almost as if you made them. \
42 This is convenient as now you can authenticate any of the bank's \
43 employee.
44
45 Authorizing a trusted introducer gives the trusted introducer a lot of \
46 power. You can constrain the amount of power that you give it by \
47 saying that it is only authorized to certify user IDs that have an \
48 email address in one or more domains, for instance. In this way, you \
49 can take advantage of the places where your and a CA's interests are \
50 aligned, and protect yourself from potentially malicious actions. For \
51 example, you could authorize your bank's CA to certify user IDs that \
52 have an email address in `bank.com`. sq will then ignore any other \
53 certifications made by the CA.
54 ",
55 after_help = VOUCH_EXAMPLES,
56 subcommand_required = true,
57 arg_required_else_help = true,
58 disable_help_subcommand = true,
59 )]
60 pub struct Command {
61 #[clap(subcommand)]
62 pub subcommand: Subcommands,
63 }
64
65
66 const VOUCH_EXAMPLES: Actions = Actions {
67 actions: &[
68 Action::setup().command(&[
69 "sq", "key", "import", "ca-secret.pgp",
70 ]).build(),
71
72 Action::setup().command(&[
73 "sq", "cert", "import", "alice-secret.pgp",
74 ]).build(),
75
76 Action::example().comment(
77 "Certify EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \
78 for [email protected].",
79 ).command(&[
80 "sq", "pki", "vouch", "add",
81 "--certifier=E7FC51AD886BBB5C4F44C3D7A9DA14F3E740F63F",
82 "--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
83 "[email protected]",
84 ]).build(),
85
86 Action::example().comment(
87 "Certify EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \
88 as a trusted introducer for example.org.",
89 ).command(&[
90 "sq", "pki", "vouch", "authorize",
91 "--certifier=E7FC51AD886BBB5C4F44C3D7A9DA14F3E740F63F",
92 "--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
93 "--domain=example.org",
94 "--all",
95 ]).build(),
96 ],
97 };
98 test_examples!(sq_pki_vouch, VOUCH_EXAMPLES);
99
100 #[derive(Debug, Subcommand)]
101 pub enum Subcommands {
102 Add(add::Command),
103 Authorize(authorize::Command),
104 List(list::Command),
105 Replay(replay::Command),
106 }