signstar_config/config/
error.rs1use nethsm::{KeyId, NamespaceId, SystemWideUserId, UserId};
4use signstar_common::config::get_config_file_paths;
5
6#[cfg(doc)]
7use crate::SignstarConfig;
8use crate::SystemUserId;
9
10#[derive(Debug, thiserror::Error)]
12pub enum Error {
13 #[error("No configuration file found in {}.",
15 get_config_file_paths().iter().map(|path| path.display().to_string()).collect::<Vec<_>>().join(", ")
16 )]
17 ConfigIsMissing,
18
19 #[error("The NetHSM user ID {nethsm_user_id} is used more than once!")]
21 DuplicateNetHsmUserId {
22 nethsm_user_id: UserId,
24 },
25
26 #[error("The SSH public key \"{ssh_public_key}\" is used more than once!")]
28 DuplicateSshPublicKey {
29 ssh_public_key: String,
31 },
32
33 #[error(
35 "The key ID \"{key_id}\" ({}) is used more than once",
36 if let Some(namespace) = namespace {
37 format!("namespace: \"{namespace}\"")
38 } else {
39 "system-wide".to_string()
40 },
41 )]
42 DuplicateKeyId {
43 key_id: KeyId,
45 namespace: Option<NamespaceId>,
47 },
48
49 #[error("The system user ID {system_user_id} is used more than once!")]
51 DuplicateSystemUserId {
52 system_user_id: SystemUserId,
54 },
55
56 #[error(
58 "The tag {tag} ({}) is used more than once",
59 if let Some(namespace) = namespace {
60 format!("namespace: \"{namespace}\"")
61 } else {
62 "system-wide".to_string()
63 },
64 )]
65 DuplicateTag {
66 tag: String,
68 namespace: Option<NamespaceId>,
70 },
71
72 #[error("The system user name {name} is invalid")]
74 InvalidSystemUserName {
75 name: String,
77 },
78
79 #[error("The SSH authorized key \"{entry}\" is invalid")]
81 InvalidAuthorizedKeyEntry {
82 entry: String,
84 },
85
86 #[error("The NetHsm user {metrics_user} is both in the Metrics and Operator role!")]
89 MetricsAlsoOperator {
90 metrics_user: SystemWideUserId,
94 },
95
96 #[error(
99 "No user in the Administrator role exists ({})",
100 if let Some(namespaces) = namespaces {
101 namespaces.iter().map(|id| id.to_string()).collect::<Vec<_>>().join(", ")
102 } else {
103 "system-wide".to_string()
104 }
105 )]
106 MissingAdministrator {
107 namespaces: Option<Vec<NamespaceId>>,
109 },
110
111 #[error("No system user for downloading shares of a shared secret exists.")]
113 MissingShareDownloadSystemUser,
114
115 #[error("No system user for uploading shares of a shared secret exists.")]
117 MissingShareUploadSystemUser,
118
119 #[error("No SSH authorized key provided!")]
121 NoAuthorizedKeys,
122
123 #[error("No mapping found where a system user matches the name {name}")]
125 NoMatchingMappingForSystemUser {
126 name: String,
128 },
129
130 #[error(
133 "Shamir's Secret Sharing not used for administrative secret handling, but the following users are setup to handle shares: {share_users:?}"
134 )]
135 NoSssButShareUsers {
136 share_users: Vec<SystemUserId>,
138 },
139
140 #[error("User data invalid: {0}")]
142 User(#[from] nethsm::UserError),
143
144 #[error("SSH key error: {0}")]
146 SshKey(#[from] ssh_key::Error),
147}