From 0780f6c50167a3169bb820babc7f98bfb545d427 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 31 Jan 2020 10:04:29 +0000 Subject: [PATCH] Added optional provider auth token to config --- nym-client/src/config/mod.rs | 12 +++++++++++- nym-client/src/config/template.rs | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/nym-client/src/config/mod.rs b/nym-client/src/config/mod.rs index 09481334cf..2e8dd80952 100644 --- a/nym-client/src/config/mod.rs +++ b/nym-client/src/config/mod.rs @@ -86,6 +86,11 @@ impl Config { self } + pub fn with_provider_auth_token(mut self, token: String) -> Self { + self.client.provider_authtoken = Some(token); + self + } + pub fn with_custom_directory(mut self, directory_server: String) -> Self { self.client.directory_server = directory_server; self @@ -133,6 +138,10 @@ pub struct Client { /// If initially omitted, a random provider will be chosen from the available topology. provider_id: String, + /// A provider specific, optional, stringified authentication token used for + /// communication with particular provider. + provider_authtoken: Option, + /// nym_home_directory specifies absolute path to the home nym Clients directory. /// It is expected to use default value and hence .toml file should not redefine this field. nym_root_directory: PathBuf, @@ -147,6 +156,7 @@ impl Default for Client { private_identity_key_file: Default::default(), public_identity_key_file: Default::default(), provider_id: "".to_string(), + provider_authtoken: None, nym_root_directory: Config::default_root_directory(), } } @@ -265,7 +275,7 @@ mod client_config { .save_to_file(Some(temp_location.clone())) .unwrap(); - let loaded_config = Config::load_from_file(Some(temp_location)).unwrap(); + let loaded_config = Config::load_from_file(Some(temp_location), None).unwrap(); assert_eq!(default_config, loaded_config); } diff --git a/nym-client/src/config/template.rs b/nym-client/src/config/template.rs index 65f7cb8cc7..feb40aca45 100644 --- a/nym-client/src/config/template.rs +++ b/nym-client/src/config/template.rs @@ -27,6 +27,10 @@ public_identity_key_file = "{{ client.public_identity_key_file }}" # ID of the provider from which the client should be fetching messages. provider_id = "{{ client.provider_id }}" +# A provider specific, optional, stringified authentication token used for +# communication with particular provider. +provider_authtoken = "{{ client.provider_authtoken }}" + ##### advanced configuration options ##### # Absolute path to the home Nym Clients directory.