signstar_config/config/
error.rs1#[cfg(doc)]
4use nethsm::NetHsm;
5use nethsm::{KeyId, NamespaceId, UserId};
6use signstar_common::config::get_config_file_paths;
7
8#[cfg(doc)]
9use crate::SignstarConfig;
10use crate::{SystemUserId, SystemWideUserId};
11
12#[derive(Debug, thiserror::Error)]
14pub enum Error {
15 #[error("No configuration file found in {}.",
17 get_config_file_paths().iter().map(|path| path.display().to_string()).collect::<Vec<_>>().join(", ")
18 )]
19 ConfigIsMissing,
20
21 #[error("The NetHsm user ID {nethsm_user_id} is used more than once!")]
23 DuplicateNetHsmUserId {
24 nethsm_user_id: UserId,
26 },
27
28 #[error("The SSH public key \"{ssh_public_key}\" is used more than once!")]
30 DuplicateSshPublicKey {
31 ssh_public_key: String,
33 },
34
35 #[error(
37 "The key ID \"{key_id}\" ({}) is used more than once",
38 if let Some(namespace) = namespace {
39 format!("namespace: \"{namespace}\"")
40 } else {
41 "system-wide".to_string()
42 },
43 )]
44 DuplicateKeyId {
45 key_id: KeyId,
47 namespace: Option<NamespaceId>,
49 },
50
51 #[error("The system user ID {system_user_id} is used more than once!")]
53 DuplicateSystemUserId {
54 system_user_id: SystemUserId,
56 },
57
58 #[error(
60 "The tag {tag} ({}) is used more than once",
61 if let Some(namespace) = namespace {
62 format!("namespace: \"{namespace}\"")
63 } else {
64 "system-wide".to_string()
65 },
66 )]
67 DuplicateTag {
68 tag: String,
70 namespace: Option<NamespaceId>,
72 },
73
74 #[error("The system user name {name} is invalid")]
76 InvalidSystemUserName {
77 name: String,
79 },
80
81 #[error("The SSH authorized key \"{entry}\" is invalid")]
83 InvalidAuthorizedKeyEntry {
84 entry: String,
86 },
87
88 #[error("The NetHsm user {metrics_user} is both in the Metrics and Operator role!")]
91 MetricsAlsoOperator {
92 metrics_user: SystemWideUserId,
96 },
97
98 #[error(
101 "No user in the Administrator role exists ({})",
102 if let Some(namespaces) = namespaces {
103 namespaces.iter().map(|id| id.to_string()).collect::<Vec<_>>().join(", ")
104 } else {
105 "system-wide".to_string()
106 }
107 )]
108 MissingAdministrator {
109 namespaces: Option<Vec<NamespaceId>>,
111 },
112
113 #[error("No system user for downloading shares of a shared secret exists.")]
115 MissingShareDownloadSystemUser,
116
117 #[error("No system user for uploading shares of a shared secret exists.")]
119 MissingShareUploadSystemUser,
120
121 #[error("No SSH authorized key provided!")]
123 NoAuthorizedKeys,
124
125 #[error("No mapping found where a system user matches the name {name}")]
127 NoMatchingMappingForSystemUser {
128 name: String,
130 },
131
132 #[error(
135 "Shamir's Secret Sharing not used for administrative secret handling, but the following users are setup to handle shares: {share_users:?}"
136 )]
137 NoSssButShareUsers {
138 share_users: Vec<SystemUserId>,
140 },
141
142 #[error("User data invalid: {0}")]
144 User(#[from] nethsm::UserError),
145
146 #[error("SSH key error: {0}")]
148 SshKey(#[from] ssh_key::Error),
149
150 #[error("The system-wide User ID has a namespace: {0}")]
152 SystemWideUserIdWithNamespace(UserId),
153}