Skip to content

Commit

Permalink
feat(BE): support SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewinci committed Sep 24, 2022
1 parent 88eef82 commit 02e0a58
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
15 changes: 10 additions & 5 deletions src-tauri/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ pub struct Cluster {
pub name: String,
pub endpoint: String,
pub authentication: Authentication,
pub schemaRegistry: Option<SchemaRegistry>,
#[serde(rename = "schemaRegistry")]
pub schema_registry: Option<SchemaRegistry>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum Authentication {
Ssl {
caLocation: String,
certificateLocation: String,
keyLocation: String,
keyPassword: Option<String>,
#[serde(rename = "caLocation")]
ca_location: String,
#[serde(rename = "certificateLocation")]
certificate_location: String,
#[serde(rename = "keyLocation")]
key_location: String,
#[serde(rename = "keyPassword")]
key_password: Option<String>,
},
Sasl {
username: String,
Expand Down
21 changes: 16 additions & 5 deletions src-tauri/src/kafka.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,23 @@ fn create_consumer(cluster: &Cluster) -> Result<StreamConsumer, String> {
.set("sasl.username", username)
.set("sasl.password", password);
}

crate::configuration::Authentication::Ssl {
caLocation,
certificateLocation,
keyLocation,
keyPassword,
} => todo!(),
ca_location,
certificate_location,
key_location,
key_password,
} => {
config
.set("security.protocol", "ssl")
.set("ssl.ca.location", ca_location)
.set("ssl.certificate.location", certificate_location)
.set("ssl.key.location", key_location);

if let Some(password) = key_password {
config.set("ssl.key.password", password);
}
}
}
config.create().map_err(|err| format!("Unable to build the Kafka consumer. {}", err))
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/clusters/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export const ClusterForm = ({ onSubmit, initialValues }: ClusterFormProps) => {
});
return (
<form onSubmit={form.onSubmit(onSubmit)}>
<ScrollArea style={{ height: "calc(100vh - 150px)" }}>
{/* padding required to avoid to have the scroll bar on top of the password eye */}
<ScrollArea style={{ height: "calc(100vh - 150px)", paddingRight: 20 }}>
<Stack>
<TextInput
label="Custer name"
Expand Down

0 comments on commit 02e0a58

Please sign in to comment.