permissions now work, however, when pushing to a repo i have no perms
authorpaulr <me@pjr.cc>
Tue, 8 Nov 2011 10:25:27 +0000 (21:25 +1100)
committerpaulr <me@pjr.cc>
Tue, 8 Nov 2011 10:25:27 +0000 (21:25 +1100)
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
gwvplib/gwvplib.php

index 5ac3df6..842d040 100644 (file)
@@ -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;
index 824e4c4..0158b45 100644 (file)
@@ -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