Non-optional auth secret

This commit is contained in:
Antoine Gersant 2020-01-16 01:58:51 -08:00
parent f7efeef653
commit 6f642c34e2
4 changed files with 9 additions and 9 deletions

View file

@ -221,7 +221,7 @@ fn main() -> Result<()> {
std::thread::spawn(move || {
let _ = service::server::run(
port,
Some(auth_secret.as_slice()),
&auth_secret,
api_url,
web_url,
web_dir_path,

View file

@ -8,7 +8,7 @@ use crate::index::CommandSender;
pub fn run(
port: u16,
auth_secret: Option<&[u8]>,
auth_secret: &[u8],
api_url: String,
web_url: String,
web_dir_path: PathBuf,

View file

@ -11,7 +11,7 @@ use crate::index::CommandSender;
pub fn get_server(
port: u16,
auth_secret: Option<&[u8]>,
auth_secret: &[u8],
api_url: &str,
web_url: &str,
web_dir_path: &PathBuf,
@ -26,10 +26,8 @@ pub fn get_server(
.keep_alive(0)
.finalize()?;
if let Some(secret) = auth_secret {
let encoded = base64::encode(secret);
config.set_secret_key(encoded)?;
}
let encoded = base64::encode(auth_secret);
config.set_secret_key(encoded)?;
let swagger_routes_rank = 0;
let web_routes_rank = swagger_routes_rank + 1;
@ -50,7 +48,7 @@ pub fn get_server(
pub fn run(
port: u16,
auth_secret: Option<&[u8]>,
auth_secret: &[u8],
api_url: String,
web_url: String,
web_dir_path: PathBuf,

View file

@ -44,9 +44,11 @@ pub fn get_test_environment(db_name: &str) -> TestEnvironment {
swagger_dir_path.push("swagger");
let command_sender = index::init(db.clone());
let auth_secret: [u8; 32] = [0; 32];
let server = server::get_server(
5050,
None,
&auth_secret,
"/api",
"/",
&web_dir_path,