]> source.dussan.org Git - gitblit.git/commitdiff
Inlcude authorization control and revise the string resources
authorJames Moger <james.moger@gitblit.com>
Fri, 30 May 2014 01:19:59 +0000 (21:19 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 3 Jun 2014 14:34:50 +0000 (10:34 -0400)
src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java

index ac5895583c77724369ea9799838d03e92d58c3d5..3fd5a3acacae5989c572288b0f82ce96eaaf256f 100644 (file)
@@ -685,12 +685,14 @@ gb.closedMilestones = closed milestones
 gb.administration = administration
 gb.plugins = plugins
 gb.extensions = extensions
-gb.anonymous = Anonymous
-gb.anonymousRepoDescription = Anyone can see, clone, and push to this repository.
-gb.public = Public
-gb.publicRepoDescription = Anyone can see and clone this repository. You choose who can push.
-gb.protected = Protected
-gb.protectedRepoDescription = Anyone can see this repository. You choose who can clone and push.
+gb.anonymousPush = Anonymous Pushes
+gb.anonymousPushDescription = Anyone can see, clone, and push to this repository.
+gb.pushRestrictedAuthenticated = Restrict Pushes (Authenticated)
+gb.pushRestrictedAuthenticatedDescription = Anyone can see and clone this repository. All authenticated users can push.
+gb.pushRestrictedNamed = Restrict Pushes (Named)
+gb.pushRestrictedNamedDescription = Anyone can see and clone this repository. You choose who can push.
+gb.cloneRestricted = Restrict Clones & Pushes
+gb.cloneRestrictedDescription = Anyone can see this repository. You choose who can clone and push.
 gb.private = Private
 gb.privateRepoDescription = You choose who can see, clone, and push to this repository.
 gb.initialCommit = Initial Commit
index b0cc3e952f32fdd98450a0b71759c93dbbfd7010..a423ae62d512d2d9fcb0c937628b8e0fa6e9e42c 100644 (file)
@@ -148,9 +148,9 @@ public class NewRepositoryPage extends RootSubPage {
                                        repositoryModel.name = fullName;\r
                                        repositoryModel.projectPath = null;\r
 \r
-                                       Permission permisison = permissionGroup.getModelObject();\r
-                                       repositoryModel.accessRestriction = permisison.type;\r
-                                       repositoryModel.authorizationControl = AuthorizationControl.NAMED;\r
+                                       Permission permission = permissionGroup.getModelObject();\r
+                                       repositoryModel.authorizationControl = permission.control;\r
+                                       repositoryModel.accessRestriction = permission.type;\r
 \r
                                        repositoryModel.owners = new ArrayList<String>();\r
                                        repositoryModel.owners.add(GitBlitWebSession.get().getUsername());\r
@@ -229,15 +229,41 @@ public class NewRepositoryPage extends RootSubPage {
                form.add(new TextField<String>("name"));\r
                form.add(new TextField<String>("description"));\r
 \r
-               Permission anonymousPermission = new Permission(getString("gb.anonymous"), getString("gb.anonymousRepoDescription"), "blank.png", AccessRestrictionType.NONE);\r
-               Permission publicPermission = new Permission(getString("gb.public"), getString("gb.publicRepoDescription"), "lock_go_16x16.png", AccessRestrictionType.PUSH);\r
-               Permission protectedPermission = new Permission(getString("gb.protected"), getString("gb.protectedRepoDescription"), "lock_pull_16x16.png", AccessRestrictionType.CLONE);\r
-               Permission privatePermission = new Permission(getString("gb.private"), getString("gb.privateRepoDescription"), "shield_16x16.png", AccessRestrictionType.VIEW);\r
+               Permission anonymousPermission = new Permission(getString("gb.anonymousPush"),\r
+                               getString("gb.anonymousPushDescription"),\r
+                               "blank.png",\r
+                               AuthorizationControl.AUTHENTICATED,\r
+                               AccessRestrictionType.NONE);\r
+\r
+               Permission authenticatedPermission = new Permission(getString("gb.pushRestrictedAuthenticated"),\r
+                               getString("gb.pushRestrictedAuthenticatedDescription"),\r
+                               "lock_go_16x16.png",\r
+                               AuthorizationControl.AUTHENTICATED,\r
+                               AccessRestrictionType.PUSH);\r
+\r
+               Permission publicPermission = new Permission(getString("gb.pushRestrictedNamed"),\r
+                               getString("gb.pushRestrictedNamedDescription"),\r
+                               "lock_go_16x16.png",\r
+                               AuthorizationControl.NAMED,\r
+                               AccessRestrictionType.PUSH);\r
+\r
+               Permission protectedPermission = new Permission(getString("gb.cloneRestricted"),\r
+                               getString("gb.cloneRestrictedDescription"),\r
+                               "lock_pull_16x16.png",\r
+                               AuthorizationControl.NAMED,\r
+                               AccessRestrictionType.CLONE);\r
+\r
+               Permission privatePermission = new Permission(getString("gb.private"),\r
+                               getString("gb.privateRepoDescription"),\r
+                               "shield_16x16.png",\r
+                               AuthorizationControl.NAMED,\r
+                               AccessRestrictionType.VIEW);\r
 \r
                List<Permission> permissions = new ArrayList<Permission>();\r
                if (app().settings().getBoolean(Keys.git.allowAnonymousPushes, false)) {\r
                        permissions.add(anonymousPermission);\r
                }\r
+               permissions.add(authenticatedPermission);\r
                permissions.add(publicPermission);\r
                permissions.add(protectedPermission);\r
                permissions.add(privatePermission);\r
@@ -248,10 +274,17 @@ public class NewRepositoryPage extends RootSubPage {
                if (AccessRestrictionType.NONE == defaultRestriction) {\r
                        defaultRestriction = AccessRestrictionType.PUSH;\r
                }\r
+               AuthorizationControl defaultControl = AuthorizationControl.fromName(\r
+                               app().settings().getString(Keys.git.defaultAuthorizationControl, AuthorizationControl.NAMED.name()));\r
+\r
+               if (AuthorizationControl.AUTHENTICATED == defaultControl) {\r
+                       defaultRestriction = AccessRestrictionType.PUSH;\r
+               }\r
 \r
                Permission defaultPermission = publicPermission;\r
                for (Permission permission : permissions) {\r
-                       if (permission.type == defaultRestriction) {\r
+                       if (permission.type == defaultRestriction\r
+                                       && permission.control == defaultControl) {\r
                                defaultPermission = permission;\r
                        }\r
                }\r
@@ -481,12 +514,14 @@ public class NewRepositoryPage extends RootSubPage {
                final String name;\r
                final String description;\r
                final String image;\r
+               final AuthorizationControl control;\r
                final AccessRestrictionType type;\r
 \r
-               Permission(String name, String description, String img, AccessRestrictionType type) {\r
+               Permission(String name, String description, String img, AuthorizationControl control, AccessRestrictionType type) {\r
                        this.name = name;\r
                        this.description = description;\r
                        this.image = img;\r
+                       this.control = control;\r
                        this.type = type;\r
                }\r
        }\r