Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/buzz-relay/src/api/admin/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Private, read-only deployment moderation API.

mod auth;
mod error;
pub(crate) mod error;

use std::sync::Arc;

Expand All @@ -27,8 +27,8 @@ pub(crate) fn is_admin_host(state: &crate::state::AppState, headers: &HeaderMap)
pub(crate) fn authorize_request(
state: &crate::state::AppState,
headers: &HeaderMap,
) -> Result<(), Response> {
authorize(state, headers).map_err(|error| error.into_response())
) -> Result<(), ApiError> {
authorize(state, headers)
}

/// Build the read-only deployment-admin routes.
Expand Down
2 changes: 1 addition & 1 deletion crates/buzz-relay/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ mod tests {
"BUZZ_ADMIN_PASSWORD",
"BUZZ_ADMIN_WEB_DIR",
];
let previous = NAMES.map(|name| std::env::var_os(name));
let previous = NAMES.map(std::env::var_os);
for name in NAMES {
std::env::remove_var(name);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/buzz-relay/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ pub fn build_router(state: Arc<AppState>) -> Router {
let path = req.uri().path();
let admin_host = api::admin::is_admin_host(&state, req.headers());
if admin_host {
if let Err(response) = api::admin::authorize_request(&state, req.headers()) {
return Ok(response);
if let Err(error) = api::admin::authorize_request(&state, req.headers()) {
return Ok(error.into_response());
}
if let (Some(index), Some(files)) = (admin_index, admin_files) {
if path.starts_with("/assets/") {
Expand Down Expand Up @@ -274,8 +274,8 @@ async fn nip11_or_ws_handler(
// Short-circuit the exact admin authority here and never let it serve the
// public web bundle, NIP-11 document, or WebSocket endpoint.
if api::admin::is_admin_host(&state, &headers) {
if let Err(response) = api::admin::authorize_request(&state, &headers) {
return response;
if let Err(error) = api::admin::authorize_request(&state, &headers) {
return error.into_response();
}
if !accept.contains("text/html") {
return StatusCode::NOT_FOUND.into_response();
Expand Down
Loading