From 33783af17fc2dce244c429195bd8d211cb6ff2c3 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Mon, 26 Feb 2024 15:58:50 -0500 Subject: [PATCH] server: disable always on http auth for docker --- docker-entrypoint.sh | 2 -- libsql-server/src/auth/parsers.rs | 10 +++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 853d95a619..94289a4340 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -7,8 +7,6 @@ SQLD_NODE="${SQLD_NODE:-primary}" SQLD_DB_PATH="${SQLD_DB_PATH:-iku.db}" SQLD_HTTP_LISTEN_ADDR="${SQLD_HTTP_LISTEN_ADDR:-"0.0.0.0:8080"}" -SQLD_HTTP_AUTH="${SQLD_HTTP_AUTH:-"always"}" - if [ "$1" = '/bin/sqld' ]; then # We are running the server. declare -a server_args=() diff --git a/libsql-server/src/auth/parsers.rs b/libsql-server/src/auth/parsers.rs index e09d930eae..973415a552 100644 --- a/libsql-server/src/auth/parsers.rs +++ b/libsql-server/src/auth/parsers.rs @@ -6,7 +6,7 @@ use tonic::metadata::MetadataMap; pub fn parse_http_basic_auth_arg(arg: &str) -> Result> { if arg == "always" { - return Ok(None); + return Ok(Some("always".to_string())); } let Some((scheme, param)) = arg.split_once(':') else { @@ -71,6 +71,8 @@ mod tests { use crate::auth::{parse_http_auth_header, AuthError}; + use super::parse_http_basic_auth_arg; + #[test] fn parse_http_auth_header_returns_auth_header_param_when_valid() { assert_eq!( @@ -111,4 +113,10 @@ mod tests { AuthError::HttpAuthHeaderUnsupportedScheme ) } + + #[test] + fn parse_http_auth_arg_always() { + let out = parse_http_basic_auth_arg("always").unwrap(); + assert_eq!(out, Some("always".to_string())); + } }