pub struct ConnectConfig {
pub hosts: BTreeMap<String, SignstarHost>,
pub users: BTreeMap<String, ConnectOptions>,
}Expand description
Connection configuration for sending a signature request.
The configuration tracks a list of all valid targets for connecting.
Fields§
§hosts: BTreeMap<String, SignstarHost>List of hosts configured.
users: BTreeMap<String, ConnectOptions>List of users.
Implementations§
Source§impl ConnectConfig
impl ConnectConfig
Sourcepub const CONFIG_ORDER: &[&str]
pub const CONFIG_ORDER: &[&str]
The order of configuration files.
The following files are inspected, in descending priority:
/etc/signstar/request-signature.toml/run/signstar/request-signature.toml/usr/share/signstar/request-signature.toml
Sourcepub async fn connect(&self, username: &str) -> Result<Session, Error>
pub async fn connect(&self, username: &str) -> Result<Session, Error>
Connects to a host over SSH and returns a Session object.
This function sets up an authenticated, bidirectional channel
between the client and the server. No signing requests are exchanged at this point but any
number of them can be issued later using Session::send function.
§Examples
use signstar_request_signature::ssh::client::ConnectConfig;
let options = ConnectConfig::from_first_system_config()?;
let mut session = options.connect("user").await?;
// use session to send signing requests§Errors
Returns an error if:
- the client public key is not set,
- the server public key is not present in the provided SSH
known_hostsdata, - the client public key is not recognized by the server,
- the client authentication with the agent fails,
- an SSH protocol error is encountered.
Sourcefn first_existing_system_config() -> Result<PathBuf, Error>
fn first_existing_system_config() -> Result<PathBuf, Error>
Return the first configuration file that exists in the filesystem out of
Self::CONFIG_ORDER list or returns a crate::Error::ConfigMissing error.
§Errors
Returns an error:
crate::Error::Ioif checking the config failscrate::Error::ConfigMissingif no configuration files have been found
Sourcepub fn from_first_system_config() -> Result<Self, Error>
pub fn from_first_system_config() -> Result<Self, Error>
Return the configuration created from the first configuration file that exists in the
filesystem out of Self::CONFIG_ORDER list or returns a
crate::Error::ConfigMissing error.
§Errors
Returns an error:
crate::Error::Ioif checking the config failscrate::Error::ConfigMissingif no configuration files have been foundcrate::Error::Validationif the config file has invalid contents
Sourcepub fn from_config_file(file: impl AsRef<Path>) -> Result<Self, Error>
pub fn from_config_file(file: impl AsRef<Path>) -> Result<Self, Error>
Reads the configuration file, validates it and returns the ConnectConfig.
§Errors
Returns an error:
crate::Error::Ioif reading the config file failscrate::Error::Validationif the config file has invalid contents
Trait Implementations§
Source§impl Debug for ConnectConfig
impl Debug for ConnectConfig
Source§impl Default for ConnectConfig
impl Default for ConnectConfig
Source§fn default() -> ConnectConfig
fn default() -> ConnectConfig
Source§impl<'de> Deserialize<'de> for ConnectConfig
impl<'de> Deserialize<'de> for ConnectConfig
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 Validate for ConnectConfig
impl Validate for ConnectConfig
Source§fn validate_into(
&self,
__garde_user_ctx: &Self::Context,
__garde_path: &mut dyn FnMut() -> Path,
__garde_report: &mut Report,
)
fn validate_into( &self, __garde_user_ctx: &Self::Context, __garde_path: &mut dyn FnMut() -> Path, __garde_report: &mut Report, )
Self, aggregating all validation errors into Report.§fn validate(&self) -> Result<(), Report>where
Self::Context: Default,
fn validate(&self) -> Result<(), Report>where
Self::Context: Default,
Self, returning an Err with an aggregate of all errors if
the validation failed. Read more§fn validate_with(&self, ctx: &Self::Context) -> Result<(), Report>
fn validate_with(&self, ctx: &Self::Context) -> Result<(), Report>
Self, returning an Err with an aggregate of all errors if
the validation failed. Read more