nethsm_config

Enum UserMapping

Source
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

Fields

§nethsm_user: SystemWideUserId
§ssh_authorized_key: AuthorizedKeyEntry
§system_user: SystemUserId
§

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

Fields

§nethsm_users: NetHsmMetricsUsers
§ssh_authorized_key: AuthorizedKeyEntry
§system_user: SystemUserId
§

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.

Fields

§nethsm_user: UserId
§nethsm_key_setup: SigningKeySetup
§ssh_authorized_key: AuthorizedKeyEntry
§system_user: SystemUserId
§

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

Fields

§nethsm_users: NetHsmMetricsUsers
§system_user: SystemUserId
§

SystemOnlyShareDownload

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

Fields

§system_user: SystemUserId
§ssh_authorized_keys: AuthorizedKeyEntryList
§

SystemOnlyShareUpload

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

Fields

§system_user: SystemUserId
§ssh_authorized_keys: AuthorizedKeyEntryList
§

SystemOnlyWireGuardDownload

A system user, with SSH access for one or more SSH keys, not mapped to any NetHsm user, used for downloading WireGuard configuration

Fields

§system_user: SystemUserId
§ssh_authorized_keys: AuthorizedKeyEntryList

Implementations§

Source§

impl UserMapping

Source

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);
Source

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())?]);
Source

pub fn get_ssh_authorized_keys(&self) -> Vec<AuthorizedKeyEntry>

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![]);
Source

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![]);
Source

pub fn get_tags(&self, namespace: Option<&str>) -> Vec<&str>

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"]);
Source

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

Source§

fn clone(&self) -> UserMapping

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UserMapping

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UserMapping

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for UserMapping

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for UserMapping

Source§

fn eq(&self, other: &UserMapping) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for UserMapping

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for UserMapping

Source§

impl StructuralPartialEq for UserMapping

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T