Skip to content

Commit

Permalink
Fix issue with wrong root credentials handling in CLI (#1129)
Browse files Browse the repository at this point in the history
Add new method for creating ClientProviderConfig with possibility
to enable or disable AutoLogin option while creating from Args.
Disabling AutoLogin for CLI.
  • Loading branch information
BartoszCiesla authored Aug 13, 2024
1 parent 33b913a commit 78ac9ba
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cli"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
authors = ["bartosz.ciesla@gmail.com"]
repository = "https://github.com/iggy-rs/iggy"
Expand Down
5 changes: 4 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ async fn main() -> Result<(), IggyCmdError> {
Aes256GcmEncryptor::from_base64_key(&iggy_args.encryption_key).unwrap(),
)),
};
let client_provider_config = Arc::new(ClientProviderConfig::from_args(iggy_args.clone())?);
let client_provider_config = Arc::new(ClientProviderConfig::from_args_set_autologin(
iggy_args.clone(),
false,
)?);

let client =
client_provider::get_raw_client(client_provider_config, command.connection_required())
Expand Down
2 changes: 1 addition & 1 deletion sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iggy"
version = "0.6.3"
version = "0.6.4"
description = "Iggy is the persistent message streaming platform written in Rust, supporting QUIC, TCP and HTTP transport protocols, capable of processing millions of messages per second."
edition = "2021"
license = "MIT"
Expand Down
33 changes: 25 additions & 8 deletions sdk/src/client_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ impl Default for ClientProviderConfig {
impl ClientProviderConfig {
/// Create a new `ClientProviderConfig` from the provided `Args`.
pub fn from_args(args: crate::args::Args) -> Result<Self, ClientError> {
Self::from_args_set_autologin(args, true)
}

/// Create a new `ClientProviderConfig` from the provided `Args` with possibility to enable or disable
/// auto login option for TCP or QUIC protocols.
pub fn from_args_set_autologin(
args: crate::args::Args,
auto_login: bool,
) -> Result<Self, ClientError> {
let transport = args.transport;
let mut config = Self {
transport,
Expand All @@ -70,10 +79,14 @@ impl ClientProviderConfig {
)
.unwrap(),
},
auto_login: AutoLogin::Enabled(Credentials::UsernamePassword(
args.username,
args.password,
)),
auto_login: if auto_login {
AutoLogin::Enabled(Credentials::UsernamePassword(
args.username,
args.password,
))
} else {
AutoLogin::Disabled
},
response_buffer_size: args.quic_response_buffer_size,
max_concurrent_bidi_streams: args.quic_max_concurrent_bidi_streams,
datagram_send_buffer_size: args.quic_datagram_send_buffer_size,
Expand Down Expand Up @@ -105,10 +118,14 @@ impl ClientProviderConfig {
)
.unwrap(),
},
auto_login: AutoLogin::Enabled(Credentials::UsernamePassword(
args.username,
args.password,
)),
auto_login: if auto_login {
AutoLogin::Enabled(Credentials::UsernamePassword(
args.username,
args.password,
))
} else {
AutoLogin::Disabled
},
}));
}
_ => return Err(ClientError::InvalidTransport(config.transport.clone())),
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "server"
version = "0.4.2"
version = "0.4.3"
edition = "2021"
build = "src/build.rs"

Expand Down

0 comments on commit 78ac9ba

Please sign in to comment.