feat: add rejecting git connection if `enable_http_clone` is `false`
Diff
src/methods/repo/smart_git.rs | 12 ++++++++++++
1 file changed, 12 insertions(+)
@@ -23,6 +23,7 @@ use tokio_util::io::StreamReader;
use tracing::{debug, error, info_span, warn, Instrument};
use crate::{
configuration::AppConfig,
methods::repo::{Repository, RepositoryPath, Result},
StatusCode,
};
@@ -31,11 +32,22 @@ use crate::{
pub async fn handle(
Extension(RepositoryPath(repository_path)): Extension<RepositoryPath>,
Extension(Repository(repository)): Extension<Repository>,
Extension(config): Extension<AppConfig>,
method: Method,
uri: Uri,
headers: HeaderMap,
body: Body,
) -> Result<impl IntoResponse> {
if !config.http_clone_enabled() {
let headers = Response::builder()
.status(StatusCode::SERVICE_UNAVAILABLE)
.body(())
.context("error forming response when `enable_http_clone` is `false`")?;
let body = Body::from("HTTP(s) clone is not enabled on this server.");
return Ok((headers, body));
}
let path = extract_path(&uri, &repository)?;
let mut command = Command::new("git");