Implemented default access restriction (issue 88)
diff --git a/distrib/gitblit.properties b/distrib/gitblit.properties
index 6353696..58833c0 100644
--- a/distrib/gitblit.properties
+++ b/distrib/gitblit.properties
@@ -37,6 +37,16 @@
 # SINCE 0.9.0

 git.onlyAccessBareRepositories = false

 

+# The default access restriction for new repositories.

+# Valid values are NONE, PUSH, CLONE, VIEW

+#  NONE = anonymous view, clone, & push

+#  PUSH = anonymous view & clone and authenticated push

+#  CLONE = anonymous view, authenticated clone & push

+#  VIEW = authenticated view, clone, & push

+#

+# SINCE 1.0.0

+git.defaultAccessRestriction = NONE

+

 #

 # Groovy Integration

 #

diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd
index 8a24acf..9e61a82 100644
--- a/docs/04_releases.mkd
+++ b/docs/04_releases.mkd
@@ -16,6 +16,8 @@
 

 #### additions

 

+- Added default access restriction.  Applies to new repositories and repositories that have not been configured with Gitblit. (issue 88)  

+    **New:** *git.defaultAccessRestriction = NONE*  

 - Added LDAP User Service with many new *realm.ldap* keys (Github/jcrygier)

 - Added support for custom repository properties for Groovy hooks (Github/jcrygier)

 - Added script to facilitate proxy environment setup on Linux (Github/mragab)

diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index a86cfd7..969dc53 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -849,7 +849,7 @@
 			model.useTickets = getConfig(config, "useTickets", false);

 			model.useDocs = getConfig(config, "useDocs", false);

 			model.accessRestriction = AccessRestrictionType.fromName(getConfig(config,

-					"accessRestriction", null));

+					"accessRestriction", settings.getString(Keys.git.defaultAccessRestriction, null)));

 			model.showRemoteBranches = getConfig(config, "showRemoteBranches", false);

 			model.isFrozen = getConfig(config, "isFrozen", false);

 			model.showReadme = getConfig(config, "showReadme", false);

diff --git a/src/com/gitblit/client/EditRepositoryDialog.java b/src/com/gitblit/client/EditRepositoryDialog.java
index 96c0dd1..f6a315b 100644
--- a/src/com/gitblit/client/EditRepositoryDialog.java
+++ b/src/com/gitblit/client/EditRepositoryDialog.java
@@ -487,6 +487,10 @@
 		JOptionPane.showMessageDialog(EditRepositoryDialog.this, message,

 				Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);

 	}

+	

+	public void setAccessRestriction(AccessRestrictionType restriction) {

+		this.accessRestriction.setSelectedItem(restriction);

+	}

 

 	public void setUsers(String owner, List<String> all, List<String> selected) {

 		ownerField.setModel(new DefaultComboBoxModel(all.toArray()));

diff --git a/src/com/gitblit/client/GitblitClient.java b/src/com/gitblit/client/GitblitClient.java
index 09bcaab..ed5a133 100644
--- a/src/com/gitblit/client/GitblitClient.java
+++ b/src/com/gitblit/client/GitblitClient.java
@@ -28,6 +28,7 @@
 import java.util.TreeSet;

 

 import com.gitblit.Constants;

+import com.gitblit.Constants.AccessRestrictionType;

 import com.gitblit.GitBlitException.ForbiddenException;

 import com.gitblit.GitBlitException.NotAllowedException;

 import com.gitblit.GitBlitException.UnauthorizedException;

@@ -185,6 +186,14 @@
 			return sb.toString();

 		}

 	}

+	

+	public AccessRestrictionType getDefaultAccessRestriction() {

+		String restriction = null;

+		if (settings.hasKey(Keys.git.defaultAccessRestriction)) {

+			restriction = settings.get(Keys.git.defaultAccessRestriction).currentValue;

+		}

+		return AccessRestrictionType.fromName(restriction);

+	}

 

 	/**

 	 * Returns the list of pre-receive scripts the repository inherited from the

diff --git a/src/com/gitblit/client/RepositoriesPanel.java b/src/com/gitblit/client/RepositoriesPanel.java
index 7cff4b6..c5d0d35 100644
--- a/src/com/gitblit/client/RepositoriesPanel.java
+++ b/src/com/gitblit/client/RepositoriesPanel.java
@@ -357,6 +357,7 @@
 	protected void createRepository() {

 		EditRepositoryDialog dialog = new EditRepositoryDialog(gitblit.getProtocolVersion());

 		dialog.setLocationRelativeTo(RepositoriesPanel.this);

+		dialog.setAccessRestriction(gitblit.getDefaultAccessRestriction());

 		dialog.setUsers(null, gitblit.getUsernames(), null);

 		dialog.setTeams(gitblit.getTeamnames(), null);

 		dialog.setRepositories(gitblit.getRepositories());

diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
index e057e2a..572f650 100644
--- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java
+++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -72,7 +72,10 @@
 		// create constructor

 		super();

 		isCreate = true;

-		setupPage(new RepositoryModel());

+		RepositoryModel model = new RepositoryModel();

+		String restriction = GitBlit.getString(Keys.git.defaultAccessRestriction, null);

+		model.accessRestriction = AccessRestrictionType.fromName(restriction);

+		setupPage(model);

 	}

 

 	public EditRepositoryPage(PageParameters params) {