pub enum UserMapping {
NetHsmOnlyAdmin(UserId),
SystemNetHsmBackup {
nethsm_user: SystemWideUserId,
ssh_authorized_key: AuthorizedKeyEntry,
system_user: SystemUserId,
},
SystemNetHsmMetrics {
nethsm_users: NetHsmMetricsUsers,
ssh_authorized_key: AuthorizedKeyEntry,
system_user: SystemUserId,
},
SystemNetHsmOperatorSigning {
nethsm_user: UserId,
nethsm_key_setup: SigningKeySetup,
ssh_authorized_key: AuthorizedKeyEntry,
system_user: SystemUserId,
tag: String,
},
HermeticSystemNetHsmMetrics {
nethsm_users: NetHsmMetricsUsers,
system_user: SystemUserId,
},
SystemOnlyShareDownload {
system_user: SystemUserId,
ssh_authorized_keys: AuthorizedKeyEntryList,
},
SystemOnlyShareUpload {
system_user: SystemUserId,
ssh_authorized_keys: AuthorizedKeyEntryList,
},
SystemOnlyWireGuardDownload {
system_user: SystemUserId,
ssh_authorized_keys: AuthorizedKeyEntryList,
},
}
Expand description
User mapping between system users and [NetHsm
][nethsm::NetHsm
] users
Variants§
NetHsmOnlyAdmin(UserId)
A NetHsm user in the Administrator role, without a system user mapped to it
SystemNetHsmBackup
A system user, with SSH access, mapped to a system-wide [NetHsm
][nethsm::NetHsm
] user
in the Backup role
SystemNetHsmMetrics
A system user, with SSH access, mapped to a system-wide [NetHsm
][nethsm::NetHsm
] user
in the Metrics role and n
users in the Operator role with read-only access to zero or
more keys
SystemNetHsmOperatorSigning
A system user, with SSH access, mapped to a [NetHsm
][nethsm::NetHsm
] user in the
Operator role with access to a single signing key.
Signing key and NetHSM user are mapped using a tag.
HermeticSystemNetHsmMetrics
A system user, without SSH access, mapped to a system-wide [NetHsm
][nethsm::NetHsm
]
user in the Metrics role and one or more NetHsm users in the Operator role with
read-only access to zero or more keys
A system user, with SSH access for one or more SSH keys, not mapped to any NetHsm user, used for downloading shares of a shared secret
A system user, with SSH access for one or more SSH keys, not mapped to any NetHsm user, used for uploading shares of a shared secret
SystemOnlyWireGuardDownload
A system user, with SSH access for one or more SSH keys, not mapped to any NetHsm user, used for downloading WireGuard configuration
Implementations§
Source§impl UserMapping
impl UserMapping
Sourcepub fn get_system_user(&self) -> Option<&SystemUserId>
pub fn get_system_user(&self) -> Option<&SystemUserId>
Returns the optional system user of the mapping
§Examples
use nethsm_config::{AuthorizedKeyEntryList, SystemUserId, UserMapping};
let mapping = UserMapping::SystemOnlyShareDownload {
system_user: "user1".parse()?,
ssh_authorized_keys: AuthorizedKeyEntryList::new(vec!["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".parse()?])?,
};
assert_eq!(mapping.get_system_user(), Some(&SystemUserId::new("user1".to_string())?));
let mapping = UserMapping::NetHsmOnlyAdmin("user1".parse()?);
assert_eq!(mapping.get_system_user(), None);
Sourcepub fn get_nethsm_users(&self) -> Vec<UserId>
pub fn get_nethsm_users(&self) -> Vec<UserId>
Returns the NetHsm users of the mapping
§Examples
use nethsm::UserId;
use nethsm_config::{AuthorizedKeyEntryList, UserMapping};
let mapping = UserMapping::SystemOnlyShareDownload {
system_user: "user1".parse()?,
ssh_authorized_keys: AuthorizedKeyEntryList::new(vec!["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".parse()?])?,
};
assert!(mapping.get_nethsm_users().is_empty());
let mapping = UserMapping::NetHsmOnlyAdmin("user1".parse()?);
assert_eq!(mapping.get_nethsm_users(), vec![UserId::new("user1".to_string())?]);
Returns the SSH authorized keys of the mapping
§Examples
use nethsm_config::{AuthorizedKeyEntry, AuthorizedKeyEntryList, UserMapping};
let mapping = UserMapping::SystemOnlyShareDownload {
system_user: "user1".parse()?,
ssh_authorized_keys: AuthorizedKeyEntryList::new(vec!["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".parse()?])?,
};
assert_eq!(mapping.get_ssh_authorized_keys(), vec![AuthorizedKeyEntry::new("ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".to_string())?]);
let mapping = UserMapping::NetHsmOnlyAdmin("user1".parse()?);
assert_eq!(mapping.get_ssh_authorized_keys(), vec![]);
Sourcepub fn get_key_ids(&self, namespace: Option<&str>) -> Vec<KeyId>
pub fn get_key_ids(&self, namespace: Option<&str>) -> Vec<KeyId>
Returns all used [KeyId
]s of the mapping
§Examples
use nethsm::{CryptographicKeyContext, KeyId, OpenPgpUserIdList, SigningKeySetup};
use nethsm_config::{AuthorizedKeyEntryList, UserMapping};
let mapping = UserMapping::SystemNetHsmOperatorSigning {
nethsm_user: "user1".parse()?,
nethsm_key_setup: SigningKeySetup::new(
"key1".parse()?,
"Curve25519".parse()?,
vec!["EdDsaSignature".parse()?],
None,
"EdDsa".parse()?,
CryptographicKeyContext::OpenPgp{
user_ids: OpenPgpUserIdList::new(vec!["John Doe <john@example.org>".parse()?])?,
version: "v4".parse()?,
},
)?,
system_user: "ssh-user1".parse()?,
ssh_authorized_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".parse()?,
tag: "tag1".to_string(),
};
assert_eq!(mapping.get_key_ids(None), vec![KeyId::new("key1".to_string())?]);
let mapping = UserMapping::SystemOnlyShareDownload {
system_user: "user1".parse()?,
ssh_authorized_keys: AuthorizedKeyEntryList::new(vec!["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".parse()?])?,
};
assert_eq!(mapping.get_key_ids(None), vec![]);
Returns tags for keys and users
Tags can be filtered by namespace by providing Some
namespace
.
Providing None
implies that the context is system-wide.
§Examples
use nethsm::{CryptographicKeyContext, OpenPgpUserIdList, SigningKeySetup};
use nethsm_config::{AuthorizedKeyEntryList, UserMapping};
let mapping = UserMapping::SystemOnlyShareDownload {
system_user: "user1".parse()?,
ssh_authorized_keys: AuthorizedKeyEntryList::new(vec!["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".parse()?])?,
};
assert!(mapping.get_tags(None).is_empty());
let mapping = UserMapping::NetHsmOnlyAdmin("user1".parse()?);
assert!(mapping.get_tags(None).is_empty());
let mapping = UserMapping::SystemNetHsmOperatorSigning{
nethsm_user: "ns1~user1".parse()?,
nethsm_key_setup: SigningKeySetup::new(
"key1".parse()?,
"Curve25519".parse()?,
vec!["EdDsaSignature".parse()?],
None,
"EdDsa".parse()?,
CryptographicKeyContext::OpenPgp{
user_ids: OpenPgpUserIdList::new(vec!["John Doe <john@example.org>".parse()?])?,
version: "4".parse()?,
})?,
system_user: "user1".parse()?,
ssh_authorized_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".parse()?,
tag: "tag1".to_string(),
};
assert!(mapping.get_tags(None).is_empty());
assert_eq!(mapping.get_tags(Some("ns1")), vec!["tag1"]);
Sourcepub fn get_namespaces(&self) -> Vec<String>
pub fn get_namespaces(&self) -> Vec<String>
Returns all [NetHsm
][nethsm::NetHsm
] namespaces of the mapping
§Examples
use nethsm::{CryptographicKeyContext, OpenPgpUserIdList, SigningKeySetup};
use nethsm_config::{AuthorizedKeyEntryList, UserMapping};
let mapping = UserMapping::SystemOnlyShareDownload {
system_user: "user1".parse()?,
ssh_authorized_keys: AuthorizedKeyEntryList::new(vec!["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".parse()?])?,
};
assert!(mapping.get_namespaces().is_empty());
let mapping = UserMapping::NetHsmOnlyAdmin("user1".parse()?);
assert!(mapping.get_namespaces().is_empty());
let mapping = UserMapping::SystemNetHsmOperatorSigning{
nethsm_user: "ns1~user1".parse()?,
nethsm_key_setup: SigningKeySetup::new(
"key1".parse()?,
"Curve25519".parse()?,
vec!["EdDsaSignature".parse()?],
None,
"EdDsa".parse()?,
CryptographicKeyContext::OpenPgp{
user_ids: OpenPgpUserIdList::new(vec!["John Doe <john@example.org>".parse()?])?,
version: "4".parse()?,
})?,
system_user: "user1".parse()?,
ssh_authorized_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH3NyNfSqtDxdnWwSVzulZi0k7Lyjw3vBEG+U8y6KsuW user@host".parse()?,
tag: "tag1".to_string(),
};
assert_eq!(mapping.get_namespaces(), vec!["ns1".to_string()]);
Trait Implementations§
Source§impl Clone for UserMapping
impl Clone for UserMapping
Source§fn clone(&self) -> UserMapping
fn clone(&self) -> UserMapping
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for UserMapping
impl Debug for UserMapping
Source§impl<'de> Deserialize<'de> for UserMapping
impl<'de> Deserialize<'de> for UserMapping
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for UserMapping
impl Hash for UserMapping
Source§impl PartialEq for UserMapping
impl PartialEq for UserMapping
Source§impl Serialize for UserMapping
impl Serialize for UserMapping
impl Eq for UserMapping
impl StructuralPartialEq for UserMapping
Auto Trait Implementations§
impl Freeze for UserMapping
impl RefUnwindSafe for UserMapping
impl Send for UserMapping
impl Sync for UserMapping
impl Unpin for UserMapping
impl UnwindSafe for UserMapping
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.