diff --git a/pageserver/src/bin/pageserver.rs b/pageserver/src/bin/pageserver.rs index 2c2955ab7d..4a23d737c4 100644 --- a/pageserver/src/bin/pageserver.rs +++ b/pageserver/src/bin/pageserver.rs @@ -10,7 +10,6 @@ use std::{ path::{Path, PathBuf}, process::exit, str::FromStr, - sync::Arc, thread, time::Duration, }; @@ -327,17 +326,17 @@ fn start_pageserver(conf: &'static PageServerConf) -> Result<()> { // initialize authentication for incoming connections let auth = match &conf.auth_type { - AuthType::Trust | AuthType::MD5 => Arc::new(None), + AuthType::Trust | AuthType::MD5 => None, AuthType::ZenithJWT => { // unwrap is ok because check is performed when creating config, so path is set and file exists let key_path = conf.auth_validation_public_key_path.as_ref().unwrap(); - Arc::new(Some(JwtAuth::from_key_path(key_path)?)) + Some(JwtAuth::from_key_path(key_path)?.into()) } }; info!("Using auth: {:#?}", conf.auth_type); // Spawn a new thread for the http endpoint - let cloned = Arc::clone(&auth); + let cloned = auth.clone(); thread::Builder::new() .name("http_endpoint_thread".into()) .spawn(move || { diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index 257d24a2e5..d4deeb84a3 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -27,12 +27,12 @@ use crate::{ #[derive(Debug)] struct State { conf: &'static PageServerConf, - auth: Arc>, + auth: Option>, allowlist_routes: Vec, } impl State { - fn new(conf: &'static PageServerConf, auth: Arc>) -> Self { + fn new(conf: &'static PageServerConf, auth: Option>) -> Self { let allowlist_routes = ["/v1/status", "/v1/doc", "/swagger.yml"] .iter() .map(|v| v.parse().unwrap()) @@ -141,7 +141,7 @@ async fn handler_404(_: Request) -> Result, ApiError> { pub fn make_router( conf: &'static PageServerConf, - auth: Arc>, + auth: Option>, ) -> RouterBuilder { let spec = include_bytes!("openapi_spec.yml"); let mut router = attach_openapi_ui(endpoint::make_router(), spec, "/swagger.yml", "/v1/doc"); @@ -151,7 +151,7 @@ pub fn make_router( if state.allowlist_routes.contains(request.uri()) { None } else { - Option::as_ref(&state.auth) + state.auth.as_deref() } })) } diff --git a/pageserver/src/page_service.rs b/pageserver/src/page_service.rs index df6f7f421e..2788e81c21 100644 --- a/pageserver/src/page_service.rs +++ b/pageserver/src/page_service.rs @@ -145,7 +145,7 @@ impl PagestreamBeMessage { /// pub fn thread_main( conf: &'static PageServerConf, - auth: Arc>, + auth: Option>, listener: TcpListener, auth_type: AuthType, ) -> anyhow::Result<()> { @@ -153,7 +153,7 @@ pub fn thread_main( let (socket, peer_addr) = listener.accept()?; debug!("accepted connection from {}", peer_addr); socket.set_nodelay(true).unwrap(); - let local_auth = Arc::clone(&auth); + let local_auth = auth.clone(); thread::spawn(move || { if let Err(err) = page_service_conn_main(conf, local_auth, socket, auth_type) { error!("error: {}", err); @@ -164,7 +164,7 @@ pub fn thread_main( fn page_service_conn_main( conf: &'static PageServerConf, - auth: Arc>, + auth: Option>, socket: TcpStream, auth_type: AuthType, ) -> anyhow::Result<()> { @@ -185,7 +185,7 @@ fn page_service_conn_main( #[derive(Debug)] struct PageServerHandler { conf: &'static PageServerConf, - auth: Arc>, + auth: Option>, claims: Option, } @@ -208,7 +208,7 @@ lazy_static! { } impl PageServerHandler { - pub fn new(conf: &'static PageServerConf, auth: Arc>) -> Self { + pub fn new(conf: &'static PageServerConf, auth: Option>) -> Self { PageServerHandler { conf, auth,