]> source.dussan.org Git - gitblit.git/commitdiff
Fixed anonymous clone for 'Authenticated Push' repository (issue 96)
authorJames Moger <james.moger@gitblit.com>
Wed, 6 Jun 2012 20:26:46 +0000 (16:26 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 6 Jun 2012 20:26:46 +0000 (16:26 -0400)
docs/04_releases.mkd
src/com/gitblit/AccessRestrictionFilter.java
src/com/gitblit/DownloadZipFilter.java
src/com/gitblit/GitFilter.java
src/com/gitblit/PagesFilter.java
src/com/gitblit/SyndicationFilter.java

index d4e5620ad7564663690fbe0fc493db2d9af7c62a..8a24acfca8cb16cd6c45a5c2624789025c6ba65f 100644 (file)
@@ -6,6 +6,7 @@
 \r
 #### fixes\r
 \r
+- Fixed bug where a repository set as authenticated push did not have anonymous clone access (issue 96)\r
 - Fixed bug in Basic authentication if passwords had a colon (Github/peterloron)\r
 \r
 #### changes\r
index e9b6587b4372a53c54a647fa8491144d4aac5dc1..aeb6835c5deeebf1221b7d0d4fcdea2d4778fc19 100644 (file)
@@ -74,9 +74,10 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
         * Determine if the repository requires authentication.\r
         * \r
         * @param repository\r
+        * @param action\r
         * @return true if authentication required\r
         */\r
-       protected abstract boolean requiresAuthentication(RepositoryModel repository);\r
+       protected abstract boolean requiresAuthentication(RepositoryModel repository, String action);\r
 \r
        /**\r
         * Determine if the user can access the repository and perform the specified\r
@@ -144,7 +145,7 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
                }\r
 \r
                // BASIC authentication challenge and response processing\r
-               if (!StringUtils.isEmpty(urlRequestType) && requiresAuthentication(model)) {\r
+               if (!StringUtils.isEmpty(urlRequestType) && requiresAuthentication(model, urlRequestType)) {\r
                        if (user == null) {\r
                                // challenge client to provide credentials. send 401.\r
                                if (GitBlit.isDebugMode()) {\r
index d22649b5eb8753ccf98e6c070d60298f8f058a4a..e515b55ec38bbc5d075a202aac39dbc16201d713 100644 (file)
@@ -72,10 +72,11 @@ public class DownloadZipFilter extends AccessRestrictionFilter {
         * Determine if the repository requires authentication.\r
         * \r
         * @param repository\r
+        * @param action\r
         * @return true if authentication required\r
         */\r
        @Override\r
-       protected boolean requiresAuthentication(RepositoryModel repository) {\r
+       protected boolean requiresAuthentication(RepositoryModel repository, String action) {\r
                return repository.accessRestriction.atLeast(AccessRestrictionType.VIEW);\r
        }\r
 \r
index e76fd767bf2902ac47b2ec22fa973076ad9c3ba0..4ae5b6c26f48c1a73d2f80c4376e08ad96a93819 100644 (file)
@@ -105,11 +105,19 @@ public class GitFilter extends AccessRestrictionFilter {
         * Determine if the repository requires authentication.\r
         * \r
         * @param repository\r
+        * @param action\r
         * @return true if authentication required\r
         */\r
        @Override\r
-       protected boolean requiresAuthentication(RepositoryModel repository) {\r
-               return repository.accessRestriction.atLeast(AccessRestrictionType.PUSH);\r
+       protected boolean requiresAuthentication(RepositoryModel repository, String action) {\r
+               if (gitUploadPack.equals(action)) {\r
+                       // send to client\r
+                       return repository.accessRestriction.atLeast(AccessRestrictionType.CLONE);       \r
+               } else if (gitReceivePack.equals(action)) {\r
+                       // receive from client\r
+                       return repository.accessRestriction.atLeast(AccessRestrictionType.PUSH);\r
+               }\r
+               return false;\r
        }\r
 \r
        /**\r
index b29bede2536468022091f4a2dd620279327ce960..c092c64d7060a65c938e12f638b2d435ce824ee2 100644 (file)
@@ -92,10 +92,11 @@ public class PagesFilter extends AccessRestrictionFilter {
         * Determine if the repository requires authentication.\r
         * \r
         * @param repository\r
+        * @param action\r
         * @return true if authentication required\r
         */\r
        @Override\r
-       protected boolean requiresAuthentication(RepositoryModel repository) {\r
+       protected boolean requiresAuthentication(RepositoryModel repository, String action) {\r
                return repository.accessRestriction.atLeast(AccessRestrictionType.VIEW);\r
        }\r
 \r
index 7e2561b9832db6f1c246f2bda89868440887bc22..08265666ba821d7acc58d5088fb0ec9d28abb090 100644 (file)
@@ -70,10 +70,11 @@ public class SyndicationFilter extends AccessRestrictionFilter {
         * Determine if the repository requires authentication.\r
         * \r
         * @param repository\r
+        * @param action\r
         * @return true if authentication required\r
         */\r
        @Override\r
-       protected boolean requiresAuthentication(RepositoryModel repository) {\r
+       protected boolean requiresAuthentication(RepositoryModel repository, String action) {\r
                return repository.accessRestriction.atLeast(AccessRestrictionType.VIEW);\r
        }\r
 \r