From e9c10b0bc2d09d21b4ff0e630a140ddc58a7dccb Mon Sep 17 00:00:00 2001 From: paulr Date: Tue, 8 Nov 2011 21:25:27 +1100 Subject: [PATCH] permissions now work, however, when pushing to a repo i have no perms to the git client goes a little spastic... i return a 403, but then it asks for another password and then errors out with a most useless error. not sure if its how im dealing with it or something more annoying than that --- gwvplib/gwvpgitcontrol.php | 14 +++++++++----- gwvplib/gwvplib.php | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gwvplib/gwvpgitcontrol.php b/gwvplib/gwvpgitcontrol.php index 5ac3df6..842d040 100644 --- a/gwvplib/gwvpgitcontrol.php +++ b/gwvplib/gwvpgitcontrol.php @@ -80,16 +80,18 @@ function gwvp_gitBackendInterface() // if its a write, we push for authentication if($write) { + error_log("is write attempt, ask for login"); $person = gwvp_checkBasicAuthLogin(); if($person == false) { gwvp_AskForBasicAuth(); return; } else { - error_log("checking perms for $person against $repoid"); - $perms = gwvp_resolvRepoPerms(gwvp_getUserId($person), $repoid); + error_log("checking perms for $person against $repoid for repo $repo"); + $perms = gwvp_resolvRepoPerms(gwvp_getUserId(null, $person), $repoid); if($perms < 3) { + error_log("perms are $perms and im not allowed"); gwvp_fourZeroThree(); - return; + exit(0); } else { // here we pass to the git backend error_log("perms are $perms and im allowed"); @@ -110,7 +112,7 @@ function gwvp_gitBackendInterface() gwvp_AskForBasicAuth(); return; } else { - $perms = gwvp_resolvRepoPerms(gwvp_getUserId($person), $repoid); + $perms = gwvp_resolvRepoPerms(gwvp_getUserId(null, $person), $repoid); if($perms < 3) { $dump = print_r($person, true); error_log("in basic read, called 403 for $perms $dump"); @@ -122,7 +124,7 @@ function gwvp_gitBackendInterface() // 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")) { - error_log("would ask $repo,$actual_repo_name for $repo/$newloc from $repo_base/$repo/$newloc"); + error_log("would ask $repo for $repo.git/$newloc from $repo_base/$repo.git/$newloc"); $fh = fopen("$repo_base/$repo.git/$newloc", "rb"); error_log("pushing file"); @@ -468,6 +470,8 @@ function gwvp_resolvRepoPerms($userid, $repoid) $ownerid = gwvp_getRepoOwner($repoid); $isadmin = gwvp_IsUserAdmin(null, null, $userid); + error_log("USerid is $userid, ownerid $ownerid"); + if($isadmin) return 3; if($userid == $ownerid) return 3; diff --git a/gwvplib/gwvplib.php b/gwvplib/gwvplib.php index 824e4c4..0158b45 100644 --- a/gwvplib/gwvplib.php +++ b/gwvplib/gwvplib.php @@ -17,7 +17,7 @@ require_once("gwvpemail.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 -- 1.7.0.4