X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=gwvpmini%2Fgwvpmini_gitbackend.php;h=c3975e665663acc2312c641bc2d198b3b124b3e4;hb=b26baaa1fd812e3c01646323119ca2b97ccdbd1d;hp=19f695fdba3ec410e4a548ab9baf1e4ba947a8e6;hpb=d76aa228c79718838a8874fc10a21163e31b732e;p=gwvp-mini.git diff --git a/gwvpmini/gwvpmini_gitbackend.php b/gwvpmini/gwvpmini_gitbackend.php index 19f695f..c3975e6 100644 --- a/gwvpmini/gwvpmini_gitbackend.php +++ b/gwvpmini/gwvpmini_gitbackend.php @@ -31,6 +31,14 @@ function gwvpmini_gitBackendInterface() // and this is where i re-code the git backend interface from scratch global $BASE_URL; + header_remove("Pragma"); + header_remove("Cache-Control"); + header_remove("Set-Cookie"); + header_remove("Expires"); + header_remove("X-Powered-By"); + header_remove("Vary"); + + $repo_base = gwvpmini_getConfigVal("repodir"); // TODO: we need to stop passing the repo name around as "repo.git", it needs to be just "repo" @@ -81,9 +89,6 @@ function gwvpmini_gitBackendInterface() $write = true; } } - if($_SERVER["REQUEST_METHOD"] == "POST") { - $write = true; - } //$write = true; // THIS MAY CAUSE ISSUES LATER ON but we do it cause the git client ignores our 403 when it uses git-receive-pack after an auth @@ -92,42 +97,56 @@ function gwvpmini_gitBackendInterface() //$write = true; //} - $perms = 5; - $write = true; + $person = gwvpmini_checkBasicAuthLogin(); + //$write = true; + // next, figure out permissions for repo + $rid = gwvpmini_GetRepoId($repo); + $uid = -1; + error_log("AT THIS POINT WE HAVE $uid, $rid, $repo $person"); - // if its a write, we push for authentication - if($write) { - error_log("is write attempt, ask for login"); - $person = gwvpmini_checkBasicAuthLogin(); - if($person == false) { - error_log("person is false, push auth"); + if(!$person) { + if($write) { + error_log("ASK FOR BASIC AUTH"); gwvpmini_AskForBasicAuth(); - echo "Login"; return; } else { - error_log("checking perms for $person against $repoid for repo $repo"); - // here we pass to the git backend - error_log("perms are $perms and im allowed"); - gwvpmini_callGitBackend($person["username"], $repo); + $perm = gwvpmini_GetRepoPerm($rid, "a"); + if($perm < 1) { + error_log("ASK FOR BASIC AUTH 2"); + gwvpmini_AskForBasicAuth(); + return; + } } - return; - } - - - // if they're less then read, we need to then check the user auth permissions - if($perms < 2) { - // we ask for auth - $person = gwvpmini_checkBasicAuthLogin(); - if($person == false) { - gwvpmini_AskForBasicAuth(); - return; + } else { + $uid = gwvpmini_GetUserId($person); + $perm = gwvpmini_GetRepoPerm($rid, $uid); + if($write) { + if($perm < 2) { + error_log("SEND FOFF"); + gwvpmini_fourZeroThree(); + return; + } } else { + if($perm < 1) { + gwvpmini_fourZeroThree(); + return; + } } } + // if its a write, we push for authentication + + //if($write) { + if(!$person) { + $person = "anonymous"; + } + gwvpmini_callGitBackend($person, $repo); + return; + //} + // if we made it this far, we a read and we have permissions to do so, just search the file from the repo - if(file_exists("$repo_base/$repo.git/$newloc")) { + /*if(file_exists("$repo_base/$repo.git/$newloc")) { error_log("would ask $repo for $repo.git/$newloc from $repo_base/$repo.git/$newloc"); $fh = fopen("$repo_base/$repo.git/$newloc", "rb"); @@ -136,10 +155,10 @@ function gwvpmini_gitBackendInterface() echo fread($fh, 8192); } } else { - //echo "would ask $repo,$actual_repo_name for $repo/$newloc from $repo_base/$repo/$newloc, NE"; + error_log("would ask $repo for $repo/$newloc from $repo_base/$repo/$newloc, NE"); gwvpmini_fourZeroFour(); return; - } + }*/ }