{
error_log("AUTH: asking for basic auth");
if(!isset($_SERVER["PHP_AUTH_USER"])) {
- header('WWW-Authenticate: Basic realm="My Realm"');
- header('HTTP/1.0 401 Unauthorized');
+ header('WWW-Authenticate: Basic realm="GIT Repo"');
+ header('HTTP/1.1 401 Unauthorized');
} else return;
}
{
global $BASE_URL, $LOGIN_TYPE;
+ $isgitagent = false;
+
+ // tested the user agent bit with jgit from eclipse and normal git... seems to work
+ if(isset($_SERVER["HTTP_USER_AGENT"])) {
+ $agent = $_SERVER["HTTP_USER_AGENT"];
+ error_log("in git backend with user agent $agent");
+ if(stristr($agent, "git")!==false) {
+ $isgitagent = true;
+ }
+ }
+
+ // we dont wan to send this to a git agent
+ if($isgitagent) return;
+
+
echo "<pre>";
if(isset($_SERVER["PHP_AUTH_USER"])) error_log("authuser: ".$_SERVER["PHP_AUTH_USER"]."\n");
echo "USERTYPE: $LOGIN_TYPE\n";
function gwvp_DebugBody()
{
global $BASE_URL;
+
+
?>
<a href="<?php echo $BASE_URL?>/debug/errormessage">Generate error message</a><br>
<a href="<?php echo $BASE_URL?>/debug/infomessage">Generate info message</a><br>
//$MENU_ITEMS["20repos"]["link"] = "$BASE_URL/admin/repos";
$HOME_PAGE_PROVIDERS["gitlog"] = "gwvp_GitLogProvider";
+// TODO: we could actually change backend interface such that is
+// will respond to any url's that contain "repo.git" rather then
+// having to be $BASE_URL/git/repo.git
function gwvp_gitControlCallMe()
{
if(isset($_REQUEST["q"])) {
// TODO: we need to stop passing the repo name around as "repo.git", it needs to be just "repo"
+
+ /* bizare git problem that ignores 403's or continues on with a push despite them
+ error_log("FLAP for ".$_SERVER["REQUEST_URI"]);
+ if(isset($_REQUEST)) {
+ $dump = print_r($_REQUEST, true);
+ error_log("FLAP, $dump");
+ }
+ if(isset($_SERVER["PHP_AUTH_USER"])) {
+ error_log("FLAP: donut hole");
+ }*/
+
+
+
+
$repo = "";
$repoid = false;
$newloc = "/";
$write = false;
if(isset($_REQUEST["service"])) {
if($_REQUEST["service"] == "git-receive-pack") {
+ error_log("got write as receivepack in post");
$write = true;
}
}
if($_SERVER["REQUEST_METHOD"] == "POST") {
$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
+ // no, this isnt a solution cause auth'd read attempts will come up as writes...
+ //if(isset($_SERVER["PHP_AUTH_USER"])) {
+ //$write = true;
+ //}
// if its a write, we push for authentication
if($write) {
// 1 - visible
// 2 - read
// 3 - write
+// 4 - owner/administrator
function gwvp_resolvRepoPerms($userid, $repoid)
{
$ownerid = gwvp_getRepoOwner($repoid);
error_log("USerid is $userid, ownerid $ownerid");
- if($isadmin) return 3;
+ if($isadmin) return 4;
- if($userid == $ownerid) return 3;
+ if($userid == $ownerid) return 4;
// now we load the perms table and pray
$repoperms = gwvp_getRepoPermissions($repoid);
require_once("gwvpweb.php");
-require_once("gwvpgitbackend.php");
require_once("gwvpuseradmin.php");
require_once("gwvprepoadmin.php");
require_once("gwvpauth.php");
require_once("gwvppluginloader.php");
// only enable this if you need it:
-//require_once("gwvpdebug.php");
+require_once("gwvpdebug.php");
?>
\ No newline at end of file
$manordetslink = "details";
$manordets = "Details";
if(isset($_SESSION["id"])) {
- if(gwvp_canManageRepo($_SESSION["id"], $rid)) {
+ if(gwvp_resolvRepoPerms($_SESSION["id"], $rid)>3) {
$manordetslink = "manage";
$manordets = "Manage";
}
ksort($MENU_ITEMS);
- echo "\n\n\n";
echo "<table border=\"1\"><tr><td><b><i>Menu</i></b></td>";
foreach($MENU_ITEMS as $key => $val) {
$link = $val["link"];
}
}
echo "</tr></table>";
- echo "\n\n\n";
}
{
global $WEB_ROOT_FS, $BASE_URL;
- echo "\n\n\n";
$login = gwvp_IsLoggedIn();
if($login === false) {
gwvp_SingleLineLoginForm();
} else {
echo "Hello, ".gwvp_GetFullName($login)." <a href=\"$BASE_URL/logout\">logout</a>";
}
- echo "\n\n\n";
}
// builds the body structure