Merge pull request 'add password support to vorebot' (#2) from feature/nikocs/nats-password-auth into develop
All checks were successful
/ build-all-services (push) Successful in 9m18s
All checks were successful
/ build-all-services (push) Successful in 9m18s
Reviewed-on: #2
This commit is contained in:
commit
927ce9d3ed
2 changed files with 12 additions and 22 deletions
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -4276,25 +4276,6 @@ version = "4.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
|
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "searchservice"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"asklyphe-common",
|
|
||||||
"async-nats",
|
|
||||||
"async-recursion",
|
|
||||||
"chrono",
|
|
||||||
"env_logger 0.10.2",
|
|
||||||
"futures",
|
|
||||||
"log",
|
|
||||||
"once_cell",
|
|
||||||
"rand 0.8.5",
|
|
||||||
"rmp-serde",
|
|
||||||
"serde",
|
|
||||||
"tokio",
|
|
||||||
"ulid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "security-framework"
|
name = "security-framework"
|
||||||
version = "2.11.1"
|
version = "2.11.1"
|
||||||
|
|
|
@ -34,6 +34,9 @@ use crate::webparse::web_parse;
|
||||||
|
|
||||||
pub static NATS_URL: Lazy<String> =
|
pub static NATS_URL: Lazy<String> =
|
||||||
Lazy::new(|| std::env::var("NATS_URL").expect("NO NATS URL DEFINED"));
|
Lazy::new(|| std::env::var("NATS_URL").expect("NO NATS URL DEFINED"));
|
||||||
|
pub static NATS_PASSWORD: Lazy<Option<String>> = Lazy::new(|| {
|
||||||
|
std::env::var("NATS_PASSWORD").ok()
|
||||||
|
});
|
||||||
pub static NATS_CERT: Lazy<String> = Lazy::new(|| std::env::var("NATS_CERT").expect("NO NATS_CERT DEFINED"));
|
pub static NATS_CERT: Lazy<String> = Lazy::new(|| std::env::var("NATS_CERT").expect("NO NATS_CERT DEFINED"));
|
||||||
pub static NATS_KEY: Lazy<String> = Lazy::new(|| std::env::var("NATS_KEY").expect("NO NATS_KEY DEFINED"));
|
pub static NATS_KEY: Lazy<String> = Lazy::new(|| std::env::var("NATS_KEY").expect("NO NATS_KEY DEFINED"));
|
||||||
pub static BROWSER_THREADS: Lazy<Vec<String>> =
|
pub static BROWSER_THREADS: Lazy<Vec<String>> =
|
||||||
|
@ -69,9 +72,15 @@ async fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
info!("began at {}", chrono::Utc::now().to_string());
|
info!("began at {}", chrono::Utc::now().to_string());
|
||||||
|
|
||||||
let nats = async_nats::ConnectOptions::new()
|
let mut nats = async_nats::ConnectOptions::new();
|
||||||
.add_client_certificate(NATS_CERT.as_str().into(), NATS_KEY.as_str().into())
|
|
||||||
.connect(NATS_URL.as_str())
|
if let Some(password) = NATS_PASSWORD.as_ref() {
|
||||||
|
nats = nats.user_and_password("vorebot".to_string(), password.to_string());
|
||||||
|
} else {
|
||||||
|
nats = nats.add_client_certificate(NATS_CERT.as_str().into(), NATS_KEY.as_str().into());
|
||||||
|
}
|
||||||
|
|
||||||
|
let nats = nats.connect(NATS_URL.as_str())
|
||||||
.await;
|
.await;
|
||||||
if let Err(e) = nats {
|
if let Err(e) = nats {
|
||||||
error!("FATAL ERROR, COULDN'T CONNECT TO NATS: {}", e);
|
error!("FATAL ERROR, COULDN'T CONNECT TO NATS: {}", e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue