mirror of
https://forge.pointfixe.fr/hubert/gitust.git
synced 2026-02-04 18:47:29 +01:00
validator for git proto
This commit is contained in:
@@ -15,15 +15,18 @@ use tokio::process::{Child, Command};
|
||||
use crate::gitust::Gitust;
|
||||
use crate::reader::ToStream;
|
||||
use crate::error;
|
||||
use crate::webutils::auth;
|
||||
|
||||
//#[get("/git/{owner}/{repo}.git/{path:.*}")]
|
||||
pub async fn git_proto(
|
||||
pub async fn git_proto<T : auth::AuthValidator>(
|
||||
mut payload : web::Payload,
|
||||
web::Path((owner, reponame, path)): web::Path<(String, String, String)>,
|
||||
mut req: HttpRequest,
|
||||
gitust : web::Data<Gitust>,
|
||||
auth : BasicAuth,
|
||||
authenticator : web::Data<T>,
|
||||
auth : Option<BasicAuth>,
|
||||
) -> Result<HttpResponse, error::Error>{
|
||||
let user = auth.and_then(|a| authenticator.check_basic(&a)).ok_or(error::Error::Unauthorized("git_proto".to_string()))?;
|
||||
//println!("enter git_proto");
|
||||
let mut cmd = Command::new("git");
|
||||
cmd.arg("http-backend");
|
||||
@@ -32,7 +35,7 @@ pub async fn git_proto(
|
||||
cmd.env("REQUEST_METHOD", req.method().as_str());
|
||||
cmd.env("GIT_PROJECT_ROOT", &gitust.repo_root_path);
|
||||
cmd.env("PATH_INFO", format!("/{}/{}.git/{}",owner, reponame, path));
|
||||
cmd.env("REMOTE_USER", auth.user_id().to_string());
|
||||
cmd.env("REMOTE_USER", user.get_name());
|
||||
//cmd.env("REMOTE_ADDR", req.remote_addr().to_string());
|
||||
cmd.env("QUERY_STRING", req.query_string());
|
||||
cmd.env("CONTENT_TYPE", header(&req, header::CONTENT_TYPE));
|
||||
|
||||
Reference in New Issue
Block a user