| 1 |
//! Command-line parser for `sq pki link`. |
| 2 |
|
| 3 |
use clap::{ArgGroup, Parser, Subcommand}; |
| 4 |
|
| 5 |
use crate::cli::examples::*; |
| 6 |
use crate::cli::types::CertDesignators; |
| 7 |
use crate::cli::types::cert_designator; |
| 8 |
use crate::cli::types::UserIDDesignators; |
| 9 |
use crate::cli::types::userid_designator; |
| 10 |
use crate::cli::types::ExpirationArg; |
| 11 |
use crate::cli::types::TrustAmount; |
| 12 |
use crate::cli::types::cert_designator::*; |
| 13 |
|
| 14 |
#[derive(Parser, Debug)] |
| 15 |
#[clap( |
| 16 |
name = "link", |
| 17 |
about = "Manage authenticated certificate and User ID links", |
| 18 |
long_about = |
| 19 |
"Manage authenticated certificate and User ID links |
| 20 |
|
| 21 |
Linking a certificate and User ID is one way of making `sq` consider a \ |
| 22 |
binding to be authentic. Another way is to use `sq pki vouch add` to \ |
| 23 |
certify the binding with an explicitly configured trust root. The \ |
| 24 |
linking functionality is often easier to work with, and the \ |
| 25 |
information is private by default. |
| 26 |
|
| 27 |
Authenticated bindings can be used to designate a certificate using a \ |
| 28 |
symbolic name. For instance, using `sq encrypt`'s \ |
| 29 |
`--for-userid` and `--for-email` options, a user can \ |
| 30 |
designate a certificate using a User ID or an email address that is \ |
| 31 |
authenticated for that certificate. |
| 32 |
|
| 33 |
`sq` also uses authenticated certificates to authenticate other \ |
| 34 |
data. For instance, `sq verify` considers signatures made by an \ |
| 35 |
authenticated certificate to be authentic. |
| 36 |
|
| 37 |
Users can create a link using `sq pki link add`. That link can later be \ |
| 38 |
retracted using `sq pki link retract`. A certificate can also be \ |
| 39 |
accepted as a trusted introducer by using `sq pki link authorize`. |
| 40 |
|
| 41 |
`sq` implements linking using non-exportable certifications, and an \ |
| 42 |
implicit trust root. An OpenPGP certificate directory, the default \ |
| 43 |
certificate store used by `sq`, includes a local trust root, which \ |
| 44 |
is stored under the `trust-root` special name. When the user \ |
| 45 |
instructs `sq` to accept a binding, `sq` uses the local trust root \ |
| 46 |
to create a non-exportable certification, which it stores in the \ |
| 47 |
certificate directory. In this way, operations that use the Web of \ |
| 48 |
Trust to authenticate a binding automatically use links. |
| 49 |
|
| 50 |
When a user retracts a link, `sq` creates a new, non-exportable \ |
| 51 |
certification with zero trust. This certification suppresses the \ |
| 52 |
previous link. |
| 53 |
", |
| 54 |
after_help = LINK_EXAMPLES, |
| 55 |
subcommand_required = true, |
| 56 |
arg_required_else_help = true, |
| 57 |
disable_help_subcommand = true, |
| 58 |
)] |
| 59 |
pub struct Command { |
| 60 |
#[clap(subcommand)] |
| 61 |
pub subcommand: Subcommands, |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
const LINK_EXAMPLES: Actions = Actions { |
| 66 |
actions: &[ |
| 67 |
Action::example().comment( |
| 68 |
"Link the certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \ |
| 69 |
with the email address [email protected].", |
| 70 |
).command(&[ |
| 71 |
"sq", "pki", "link", "add", |
| 72 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 73 |
"[email protected]", |
| 74 |
]).build(), |
| 75 |
|
| 76 |
Action::example().comment( |
| 77 |
"Then, temporarily accept the certificate \ |
| 78 |
EB28F26E2739A4870ECC47726F0073F60FD0CBF0 with all of \ |
| 79 |
its self-signed user IDs for a week.", |
| 80 |
).command(&[ |
| 81 |
"sq", "pki", "link", "add", |
| 82 |
"--expiration=1w", |
| 83 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 84 |
"--all", |
| 85 |
]).build(), |
| 86 |
|
| 87 |
Action::example().comment( |
| 88 |
"Accept the certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \ |
| 89 |
with all of its self-signed user IDs as a trusted certification \ |
| 90 |
authority constrained to the domain example.org. That is, the \ |
| 91 |
certificate is considered a trusted introducer for example.org.", |
| 92 |
).command(&[ |
| 93 |
"sq", "pki", "link", "authorize", |
| 94 |
"--domain=example.org", |
| 95 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 96 |
"--all", |
| 97 |
]).build(), |
| 98 |
|
| 99 |
Action::example().comment( |
| 100 |
"List all links.", |
| 101 |
).command(&[ |
| 102 |
"sq", "pki", "link", "list", |
| 103 |
]).build(), |
| 104 |
|
| 105 |
Action::example().comment( |
| 106 |
"Retract the acceptance of certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \ |
| 107 |
and any associated user IDs. This effectively invalidates all links.", |
| 108 |
).command(&[ |
| 109 |
"sq", "pki", "link", "retract", |
| 110 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 111 |
"--all", |
| 112 |
]).build(), |
| 113 |
], |
| 114 |
}; |
| 115 |
test_examples!(sq_pki_link, LINK_EXAMPLES); |
| 116 |
|
| 117 |
#[derive(Debug, Subcommand)] |
| 118 |
pub enum Subcommands { |
| 119 |
Add(AddCommand), |
| 120 |
Authorize(AuthorizeCommand), |
| 121 |
Retract(RetractCommand), |
| 122 |
List(ListCommand), |
| 123 |
} |
| 124 |
|
| 125 |
#[derive(Parser, Debug)] |
| 126 |
#[clap( |
| 127 |
name = "add", |
| 128 |
about = "Link a certificate and a user ID", |
| 129 |
long_about = |
| 130 |
"Link a certificate and a user ID |
| 131 |
|
| 132 |
This causes `sq` to consider the certificate and user ID binding to be \ |
| 133 |
authentic. You would do this if you are confident that a particular \ |
| 134 |
certificate should be associated with Alice, for example. Note: this \ |
| 135 |
does not consider the certificate to be a trusted introducer; it only \ |
| 136 |
considers the binding to be authentic. To authorize a certificate to \ |
| 137 |
be a trusted introducer use `sq pki link authorize`. |
| 138 |
|
| 139 |
A link can be retracted using `sq pki link retract`. |
| 140 |
|
| 141 |
This command is similar to `sq pki vouch add`, but the certifications it \ |
| 142 |
makes are done using the certificate directory's trust root, not an \ |
| 143 |
arbitrary key. Further, the certificates are marked as \ |
| 144 |
non-exportable. The former makes it easier to manage certifications, \ |
| 145 |
especially when the user's certification key is offline. And the \ |
| 146 |
latter improves the user's privacy, by reducing the chance that parts \ |
| 147 |
of the user's social graph is leaked when a certificate is shared. |
| 148 |
|
| 149 |
By default a link never expires. This can be overridden using \ |
| 150 |
`--expiration` argument. |
| 151 |
|
| 152 |
`sq pki link add` respects the reference time set by the top-level \ |
| 153 |
`--time` argument. It sets the link's creation time to the reference \ |
| 154 |
time. |
| 155 |
", |
| 156 |
after_help = ADD_EXAMPLES, |
| 157 |
)] |
| 158 |
#[clap(group(ArgGroup::new("expiration-group") |
| 159 |
.args(&["expiration", "temporary"])))] |
| 160 |
pub struct AddCommand { |
| 161 |
#[command(flatten)] |
| 162 |
pub cert: CertDesignators< |
| 163 |
cert_designator::CertSpecialArgs, |
| 164 |
cert_designator::CertPrefix, |
| 165 |
cert_designator::OneValue>, |
| 166 |
|
| 167 |
#[command(flatten)] |
| 168 |
pub userids: UserIDDesignators< |
| 169 |
userid_designator::AllExactByAndAddArgs>, |
| 170 |
|
| 171 |
#[clap( |
| 172 |
long = "amount", |
| 173 |
value_name = "AMOUNT", |
| 174 |
default_value = "full", |
| 175 |
help = "Set the amount of trust", |
| 176 |
long_help = |
| 177 |
"Set the amount of trust |
| 178 |
|
| 179 |
Values between 1 and 120 are meaningful. \ |
| 180 |
120 means fully trusted. Values less than 120 indicate the degree \ |
| 181 |
of trust. 60 is usually used for partially trusted.", |
| 182 |
)] |
| 183 |
pub amount: TrustAmount<u8>, |
| 184 |
|
| 185 |
#[clap( |
| 186 |
long = "temporary", |
| 187 |
conflicts_with_all = &[ "amount" ], |
| 188 |
help = "Temporarily accepts the binding", |
| 189 |
long_help = |
| 190 |
"Temporarily accepts the binding |
| 191 |
|
| 192 |
Creates a fully \ |
| 193 |
trust link between a certificate and one or more \ |
| 194 |
User IDs for a week. After that, the link is \ |
| 195 |
automatically downgraded to a partially trusted link \ |
| 196 |
(trust = 40).", |
| 197 |
)] |
| 198 |
pub temporary: bool, |
| 199 |
#[command(flatten)] |
| 200 |
pub expiration: ExpirationArg, |
| 201 |
|
| 202 |
|
| 203 |
#[clap( |
| 204 |
long = "recreate", |
| 205 |
help = "Recreate signature even if the parameters did not change", |
| 206 |
long_help = "\ |
| 207 |
Recreate signature even if the parameters did not change |
| 208 |
|
| 209 |
If the link parameters did not change, and thus creating a signature \ |
| 210 |
should not be necessary, we omit the operation. This flag can be given \ |
| 211 |
to force the signature to be re-created anyway.", |
| 212 |
)] |
| 213 |
pub recreate: bool, |
| 214 |
|
| 215 |
#[command(flatten)] |
| 216 |
pub signature_notations: crate::cli::types::SignatureNotationsArg, |
| 217 |
} |
| 218 |
|
| 219 |
const ADD_EXAMPLES: Actions = Actions { |
| 220 |
actions: &[ |
| 221 |
Action::example().comment( |
| 222 |
"Link the certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \ |
| 223 |
with the email address [email protected].", |
| 224 |
).command(&[ |
| 225 |
"sq", "pki", "link", "add", |
| 226 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 227 |
"[email protected]", |
| 228 |
]).build(), |
| 229 |
|
| 230 |
Action::example().comment( |
| 231 |
"First, examine the certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0.", |
| 232 |
).command(&[ |
| 233 |
"sq", "inspect", |
| 234 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 235 |
]).build(), |
| 236 |
|
| 237 |
Action::example().comment( |
| 238 |
"Then, temporarily accept the certificate \ |
| 239 |
EB28F26E2739A4870ECC47726F0073F60FD0CBF0 with all of its self-signed \ |
| 240 |
user IDs for a week.", |
| 241 |
).command(&[ |
| 242 |
"sq", "pki", "link", "add", |
| 243 |
"--expiration=1w", |
| 244 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 245 |
"--all", |
| 246 |
]).build(), |
| 247 |
|
| 248 |
Action::example().comment( |
| 249 |
"Once satisfied, permanently accept the certificate \ |
| 250 |
EB28F26E2739A4870ECC47726F0073F60FD0CBF0 with all of its self-signed \ |
| 251 |
user IDs.", |
| 252 |
).command(&[ |
| 253 |
"sq", "pki", "link", "add", |
| 254 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 255 |
"--all", |
| 256 |
]).build(), |
| 257 |
], |
| 258 |
}; |
| 259 |
test_examples!(sq_pki_link_add, ADD_EXAMPLES); |
| 260 |
|
| 261 |
#[derive(Parser, Debug)] |
| 262 |
#[clap( |
| 263 |
name = "authorize", |
| 264 |
about = "Make a certificate a trusted introducer", |
| 265 |
long_about = "\ |
| 266 |
Make a certificate a trusted introducer |
| 267 |
|
| 268 |
This causes `sq` to consider the certificate to be a be a trusted \ |
| 269 |
introducer. Trusted introducer is another word for certification \ |
| 270 |
authority (CA). When you link a trusted introducer, you consider \ |
| 271 |
certifications made by the trusted introducer to be valid. A trusted \ |
| 272 |
introducer can also designate further trusted introducers. |
| 273 |
|
| 274 |
As is, a trusted introducer has a lot of power. This power can be \ |
| 275 |
limited in several ways. |
| 276 |
|
| 277 |
- The ability to specify further introducers can be constrained \ |
| 278 |
using the `--depth` parameter. |
| 279 |
|
| 280 |
- The degree to which an introducer is trusted can be changed using \ |
| 281 |
the `--amount` parameter. |
| 282 |
|
| 283 |
- The user IDs that an introducer can certify can be constrained by \ |
| 284 |
domain using the `--domain` parameter or a regular expression using \ |
| 285 |
the `--regex` parameter. |
| 286 |
|
| 287 |
These mechanisms allow you to say that you are willing to rely on the \ |
| 288 |
CA for example.org, but only for user IDs that have an email address \ |
| 289 |
for example.org, for instance. |
| 290 |
|
| 291 |
A link can be retracted using `sq pki link retract`. |
| 292 |
|
| 293 |
This command is similar to `sq pki vouch authorize`, but the certifications \ |
| 294 |
it makes are done using the certificate directory's trust root, not an \ |
| 295 |
arbitrary key. Further, the certificates are marked as \ |
| 296 |
non-exportable. The former makes it easier to manage certifications, \ |
| 297 |
especially when your certification key is offline. And the latter \ |
| 298 |
improves your privacy, by reducing the chance that parts of your \ |
| 299 |
social graph are leaked when a certificate is shared. |
| 300 |
|
| 301 |
By default a link never expires. Using the `--expiration` argument \ |
| 302 |
specific validity periods may be defined. It allows for providing a \ |
| 303 |
point in time for validity to end or a validity duration. |
| 304 |
|
| 305 |
`sq pki link authorize` respects the reference time set by the \ |
| 306 |
top-level `--time` argument. It sets the link's creation time to the \ |
| 307 |
reference time. |
| 308 |
", |
| 309 |
after_help = AUTHORIZE_EXAMPLES, |
| 310 |
)] |
| 311 |
#[clap(group(ArgGroup::new("constraint").args(&["regex", "domain", "unconstrained"]).required(true).multiple(true)))] |
| 312 |
pub struct AuthorizeCommand { |
| 313 |
#[command(flatten)] |
| 314 |
pub cert: CertDesignators< |
| 315 |
cert_designator::CertSpecialArgs, |
| 316 |
cert_designator::CertPrefix, |
| 317 |
cert_designator::OneValue>, |
| 318 |
|
| 319 |
#[command(flatten)] |
| 320 |
pub userids: UserIDDesignators< |
| 321 |
userid_designator::AllExactByAndAddArgs>, |
| 322 |
|
| 323 |
#[clap( |
| 324 |
long = "amount", |
| 325 |
value_name = "AMOUNT", |
| 326 |
default_value = "full", |
| 327 |
help = "Set the amount of trust", |
| 328 |
long_help = |
| 329 |
"Set the amount of trust |
| 330 |
|
| 331 |
Values between 1 and 120 are meaningful. \ |
| 332 |
120 means fully trusted. Values less than 120 indicate the degree \ |
| 333 |
of trust. 60 is usually used for partially trusted.", |
| 334 |
)] |
| 335 |
pub amount: TrustAmount<u8>, |
| 336 |
|
| 337 |
#[clap( |
| 338 |
long = "depth", |
| 339 |
value_name = "TRUST_DEPTH", |
| 340 |
default_value = "255", |
| 341 |
help = "Set the trust depth", |
| 342 |
long_help = "Set the trust depth |
| 343 |
|
| 344 |
This is sometimes referred to as the trust level. 1 \ |
| 345 |
means CERTIFICATE is a trusted introducer (default), 2 means \ |
| 346 |
CERTIFICATE is a meta-trusted introducer and can authorize another \ |
| 347 |
trusted introducer, etc.", |
| 348 |
)] |
| 349 |
pub depth: u8, |
| 350 |
|
| 351 |
#[clap( |
| 352 |
long = "domain", |
| 353 |
value_name = "DOMAIN", |
| 354 |
help = "Add a domain constraint to the introducer", |
| 355 |
long_help = "\ |
| 356 |
Add a domain constraint to the introducer |
| 357 |
|
| 358 |
Add a domain to constrain what certifications are respected. A \ |
| 359 |
certification made by the certificate is only respected if it is over \ |
| 360 |
a user ID with an email address in the specified domain. Multiple \ |
| 361 |
domains may be specified. In that case, one must match.", |
| 362 |
)] |
| 363 |
pub domain: Vec<String>, |
| 364 |
#[clap( |
| 365 |
long = "regex", |
| 366 |
value_name = "REGEX", |
| 367 |
help = "Add a regular expression to constrain the introducer", |
| 368 |
long_help = "\ |
| 369 |
Add a regular expression to constrain the introducer |
| 370 |
|
| 371 |
Add a regular expression to constrain what certifications are \ |
| 372 |
respected. A certification made by the certificate is only respected \ |
| 373 |
if it is over a user ID that matches one of the specified regular \ |
| 374 |
expression. Multiple regular expressions may be specified. In that \ |
| 375 |
case, at least one must match.", |
| 376 |
)] |
| 377 |
pub regex: Vec<String>, |
| 378 |
#[clap( |
| 379 |
long, |
| 380 |
conflicts_with = "regex", |
| 381 |
help = "Don't constrain the introducer", |
| 382 |
long_help = "\ |
| 383 |
Don't constrain the introducer |
| 384 |
|
| 385 |
Normally an introducer is constrained so that only certain user IDs \ |
| 386 |
are respected, e.g., those that have an email address for a certain \ |
| 387 |
domain name. This option authorizes an introducer without \ |
| 388 |
constraining it in this way. Because this grants the introducer a lot \ |
| 389 |
of power, you have to opt in to this behavior explicitly.", |
| 390 |
)] |
| 391 |
pub unconstrained: bool, |
| 392 |
|
| 393 |
#[command(flatten)] |
| 394 |
pub expiration: ExpirationArg, |
| 395 |
|
| 396 |
#[clap( |
| 397 |
long = "recreate", |
| 398 |
help = "Recreate the signature even if the parameters did not change", |
| 399 |
long_help = "\ |
| 400 |
Recreate the signature even if the parameters did not change |
| 401 |
|
| 402 |
If the link parameters did not change, and thus creating a signature \ |
| 403 |
should not be necessary, we omit the operation. This flag can be given \ |
| 404 |
to force the signature to be recreated anyway.", |
| 405 |
)] |
| 406 |
pub recreate: bool, |
| 407 |
|
| 408 |
#[command(flatten)] |
| 409 |
pub signature_notations: crate::cli::types::SignatureNotationsArg, |
| 410 |
} |
| 411 |
|
| 412 |
const AUTHORIZE_EXAMPLES: Actions = Actions { |
| 413 |
actions: &[ |
| 414 |
Action::example().comment( |
| 415 |
"Add an unconstrained trusted introducer.", |
| 416 |
).command(&[ |
| 417 |
"sq", "pki", "link", "authorize", |
| 418 |
"--unconstrained", |
| 419 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 420 |
"--all", |
| 421 |
]).build(), |
| 422 |
|
| 423 |
Action::example().comment( |
| 424 |
"Add a trusted introducer for example.org and example.com.", |
| 425 |
).command(&[ |
| 426 |
"sq", "pki", "link", "authorize", |
| 427 |
"--domain=example.org", |
| 428 |
"--domain=example.com", |
| 429 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 430 |
"--all", |
| 431 |
]).build(), |
| 432 |
|
| 433 |
Action::example().comment( |
| 434 |
"Add a partially trusted introducer.", |
| 435 |
).command(&[ |
| 436 |
"sq", "pki", "link", "authorize", |
| 437 |
"--unconstrained", |
| 438 |
"--amount=60", |
| 439 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 440 |
"--all", |
| 441 |
]).build(), |
| 442 |
], |
| 443 |
}; |
| 444 |
test_examples!(sq_pki_link_authorize, AUTHORIZE_EXAMPLES); |
| 445 |
|
| 446 |
#[derive(Parser, Debug)] |
| 447 |
#[clap( |
| 448 |
name = "retract", |
| 449 |
about = "Retract links", |
| 450 |
long_about = |
| 451 |
"Retract links |
| 452 |
|
| 453 |
This command retracts links that were previously created using `sq \ |
| 454 |
pki link add` or `sq pki link authorize`. See that subcommand's \ |
| 455 |
documentation for more details. \ |
| 456 |
Note: this is called `retract` and not `remove`, because the \ |
| 457 |
certifications are not removed. Instead a new certification is added, \ |
| 458 |
which says that the binding has not been authenticated. |
| 459 |
|
| 460 |
`sq pki link retract` respects the reference time set by the top-level \ |
| 461 |
`--time` argument. This causes a link to be retracted as of a \ |
| 462 |
particular time instead of the current time. |
| 463 |
", |
| 464 |
after_help = RETRACT_EXAMPLES, |
| 465 |
)] |
| 466 |
pub struct RetractCommand { |
| 467 |
#[command(flatten)] |
| 468 |
pub signature_notations: crate::cli::types::SignatureNotationsArg, |
| 469 |
|
| 470 |
#[clap( |
| 471 |
long = "recreate", |
| 472 |
help = "Recreate signature even if the parameters did not change", |
| 473 |
long_help = "\ |
| 474 |
Recreate signature even if the parameters did not change |
| 475 |
|
| 476 |
If the link parameters did not change, and thus creating a signature \ |
| 477 |
should not be necessary, we omit the operation. This flag can be given \ |
| 478 |
to force the signature to be re-created anyway.", |
| 479 |
)] |
| 480 |
pub recreate: bool, |
| 481 |
|
| 482 |
#[command(flatten)] |
| 483 |
pub cert: CertDesignators< |
| 484 |
cert_designator::CertSpecialArgs, |
| 485 |
cert_designator::CertPrefix, |
| 486 |
cert_designator::OneValue>, |
| 487 |
|
| 488 |
#[command(flatten)] |
| 489 |
pub userids: UserIDDesignators< |
| 490 |
userid_designator::AllPlainAddAndByArgs, |
| 491 |
userid_designator::AllMatchesNonSelfSignedNoLinting>, |
| 492 |
} |
| 493 |
|
| 494 |
const RETRACT_EXAMPLES: Actions = Actions { |
| 495 |
actions: &[ |
| 496 |
Action::example().comment( |
| 497 |
"Link the certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \ |
| 498 |
with the email address [email protected]." |
| 499 |
).command(&[ |
| 500 |
"sq", "pki", "link", "add", |
| 501 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 502 |
"[email protected]", |
| 503 |
]).build(), |
| 504 |
|
| 505 |
Action::example().comment( |
| 506 |
"Retract the acceptance of certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \ |
| 507 |
and the email address [email protected].", |
| 508 |
).command(&[ |
| 509 |
"sq", "pki", "link", "retract", |
| 510 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 511 |
"[email protected]", |
| 512 |
]).build(), |
| 513 |
|
| 514 |
Action::example().comment( |
| 515 |
"Retract the acceptance of certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \ |
| 516 |
and any associated user IDs. This effectively invalidates all links.", |
| 517 |
).command(&[ |
| 518 |
"sq", "pki", "link", "retract", |
| 519 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 520 |
"--all", |
| 521 |
]).build(), |
| 522 |
], |
| 523 |
}; |
| 524 |
test_examples!(sq_pki_link_retract, RETRACT_EXAMPLES); |
| 525 |
|
| 526 |
#[derive(Parser, Debug)] |
| 527 |
#[clap( |
| 528 |
name = "list", |
| 529 |
about = "List links", |
| 530 |
long_about = |
| 531 |
"List links |
| 532 |
|
| 533 |
This command lists all bindings that are linked or whose link has been \ |
| 534 |
retracted. |
| 535 |
|
| 536 |
Returns a non-zero exit code if an explicitly designated certificate |
| 537 |
was never linked.", |
| 538 |
after_help = LIST_EXAMPLES, |
| 539 |
)] |
| 540 |
pub struct ListCommand { |
| 541 |
#[command(flatten)] |
| 542 |
pub certs: CertDesignators<CertUserIDEmailDomainGrepArgs, |
| 543 |
CertPrefix, |
| 544 |
OptionalValue>, |
| 545 |
|
| 546 |
/// A pattern to select the bindings to authenticate |
| 547 |
/// |
| 548 |
/// The pattern is treated as a UTF-8 encoded string and a |
| 549 |
/// case insensitive substring search (using the current |
| 550 |
/// locale) is performed against each User ID. If a User ID |
| 551 |
/// is not valid UTF-8, the binding is ignored. |
| 552 |
#[clap( |
| 553 |
conflicts_with_all = &["cert", "cert-userid", "cert-email", |
| 554 |
"cert-domain", "cert-grep"], |
| 555 |
)] |
| 556 |
pub pattern: Option<String>, |
| 557 |
|
| 558 |
#[clap( |
| 559 |
long = "ca", |
| 560 |
required = false, |
| 561 |
help = "Only lists bindings linked as CAs", |
| 562 |
long_help = "Only lists bindings linked as CAs |
| 563 |
|
| 564 |
That is, only list a link if its trust depth is greater than 0.", |
| 565 |
)] |
| 566 |
pub ca: bool, |
| 567 |
} |
| 568 |
|
| 569 |
const LIST_EXAMPLES: Actions = Actions { |
| 570 |
actions: &[ |
| 571 |
Action::example().comment( |
| 572 |
"Link the certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \ |
| 573 |
with the email address [email protected].", |
| 574 |
).command(&[ |
| 575 |
"sq", "pki", "link", "add", |
| 576 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 577 |
"[email protected]", |
| 578 |
]).build(), |
| 579 |
|
| 580 |
Action::example().comment( |
| 581 |
"List all links.", |
| 582 |
).command(&[ |
| 583 |
"sq", "pki", "link", "list", |
| 584 |
]).build(), |
| 585 |
|
| 586 |
Action::example().comment( |
| 587 |
"List links to certificates with an authenticated user ID \ |
| 588 |
that contains an email address in the specified domain.", |
| 589 |
).command(&[ |
| 590 |
"sq", "pki", "link", "list", |
| 591 |
"--cert-domain=example.org", |
| 592 |
]).build(), |
| 593 |
], |
| 594 |
}; |
| 595 |
test_examples!(sq_pki_link_list, LIST_EXAMPLES); |