]> source.dussan.org Git - gitblit.git/commitdiff
Fixed anonymous browsing of branch panel
authorJames Moger <james.moger@gitblit.com>
Thu, 6 Dec 2012 22:05:15 +0000 (17:05 -0500)
committerJames Moger <james.moger@gitblit.com>
Thu, 6 Dec 2012 22:05:15 +0000 (17:05 -0500)
src/com/gitblit/models/UserModel.java
src/com/gitblit/wicket/pages/RepositoryPage.java
src/com/gitblit/wicket/panels/BranchesPanel.java

index f1bc5efc6821403ef023d7d600a2dc744ce8b95f..ac67ff7872b6e2085fea4eaeab2d30fa1676ba88 100644 (file)
@@ -360,6 +360,12 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
        public boolean canView(RepositoryModel repository) {\r
                return canAccess(repository, AccessRestrictionType.VIEW, AccessPermission.VIEW);\r
        }\r
+       \r
+       public boolean canView(RepositoryModel repository, String ref) {\r
+               // Default UserModel doesn't implement ref-level security.\r
+               // Other Realms (i.e. Gerrit) may override this method.\r
+               return canView(repository);\r
+       }\r
 \r
        public boolean canClone(RepositoryModel repository) {\r
                return canAccess(repository, AccessRestrictionType.CLONE, AccessPermission.CLONE);\r
@@ -587,6 +593,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
                return nameVerified && emailVerified;\r
        }\r
        \r
+       @Deprecated\r
        public boolean hasBranchPermission(String repositoryName, String branch) {\r
                // Default UserModel doesn't implement branch-level security. Other Realms (i.e. Gerrit) may override this method.\r
                return hasRepositoryPermission(repositoryName) || hasTeamRepositoryPermission(repositoryName);\r
index 3acf73af774b6b67f71c45f9c966b12c784dfccb..b4e1a0e30b7524528ef3fe1623e61d1734986e65 100644 (file)
@@ -112,7 +112,7 @@ public abstract class RepositoryPage extends BasePage {
                                        // workaround until get().getUser() is reviewed throughout the app\r
                                        user = UserModel.ANONYMOUS;\r
                                }\r
-                               boolean canAccess = user.hasBranchPermission(repositoryName,\r
+                               boolean canAccess = user.canView(getRepositoryModel(),\r
                                                                branch.reference.getName());\r
                                if (!canAccess) {\r
                                        error(getString("gb.accessDenied"), true);\r
index 26fedc1ecd7f6e1605dd51109eacf22047fe8cbb..1262077c95bc219e69d2b0150e333c9afacf84d8 100644 (file)
@@ -67,14 +67,14 @@ public class BranchesPanel extends BasePanel {
 \r
                List<RefModel> localBranches = JGitUtils.getLocalBranches(r, false, -1);\r
                for (RefModel refModel : localBranches) {\r
-                       if (user.hasBranchPermission(model.name, refModel.reference.getName())) {\r
+                       if (user.canView(model, refModel.reference.getName())) {\r
                                branches.add(refModel);\r
                        }\r
                }\r
                if (model.showRemoteBranches) {\r
                        List<RefModel> remoteBranches = JGitUtils.getRemoteBranches(r, false, -1);\r
                        for (RefModel refModel : remoteBranches) {\r
-                               if (user.hasBranchPermission(model.name, refModel.reference.getName())) {\r
+                               if (user.canView(model, refModel.reference.getName())) {\r
                                        branches.add(refModel);\r
                                }\r
                        }\r