Crate nethsm_config

Source
Expand description

A library for working with application configuration files for Nitrokey NetHSM devices

Provides configuration file management for custom applications designed around working with Nitrokey NetHSM devices or containers. Configuration settings allow for individualizing the configuration use and its use-cases (interactive or non-interactive).

A module for interactive prompts provides extra convenience around creating applications that may request further data from their users interactively.

ยงExamples

use nethsm::{ConnectionSecurity, UserRole};
use nethsm_config::{Config, ConfigCredentials, ConfigInteractivity, ConfigSettings};

// a configuration for a non-interactive application called "my_app"
let config_settings = ConfigSettings::new(
    "my_app".to_string(),
    ConfigInteractivity::NonInteractive,
    None,
);

// let's assume a custom configuration file path
let tmpfile = testdir::testdir!().join("my_app.conf");
let config = Config::new(config_settings, Some(&tmpfile))?;

// add a first device to commnicate with
config.add_device(
    "nethsm1".to_string(),
    "https://example.org/api/v1".parse()?,
    ConnectionSecurity::Unsafe,
)?;

// add credentials to communicate with the the device
config.add_credentials(
    "nethsm1".to_string(),
    ConfigCredentials::new(
        UserRole::Administrator,
        "admin1".parse()?,
        Some("my-passphrase".to_string()),
    ),
)?;

// write configuration to file
config.store(Some(&tmpfile))?;

Modulesยง

config ๐Ÿ”’
credentials ๐Ÿ”’
mapping ๐Ÿ”’
prompt ๐Ÿ”’

Structsยง

AuthorizedKeyEntry
An entry of an authorized_keys file
AuthorizedKeyEntryList
A list of AuthorizedKeyEntrys
Config
A configuration for NetHSM devices
ConfigCredentials
A set of credentials for a [NetHsm][nethsm::NetHsm]
ConfigName
The name of a configuration
ConfigSettings
The settings for a Config
DeviceConfig
The configuration for a [NetHsm]
ExtendedUserMapping
A UserMapping centric view of a HermeticParallelConfig.
HermeticParallelConfig
A configuration for parallel use of connections with a set of system and NetHSM users.
NetHsmMetricsUsers
A set of users with unique [UserId]s, used for metrics retrieval
SystemUserId
The name of a user on a Unix system
SystemWideUserId
A guaranteed to be system-wide [NetHsm][nethsm::NetHsm] user
UserPrompt
Username prompt

Enumsยง

AdministrativeSecretHandling
The handling of administrative secrets.
ConfigInteractivity
The interactivity of a configuration
Error
Errors related to configuration
NonAdministrativeSecretHandling
The handling of non-administrative secrets.
PassphrasePrompt
Passphrase prompt
UserMapping
User mapping between system users and [NetHsm][nethsm::NetHsm] users