James Moger
2012-06-06 94dcbd617f3d06ca294d5d151390698e4bddd2cc
Implemented default access restriction (issue-88)
7 files modified
33 ■■■■■ changed files
distrib/gitblit.properties 10 ●●●●● patch | view | raw | blame | history
docs/04_releases.mkd 2 ●●●●● patch | view | raw | blame | history
src/com/gitblit/GitBlit.java 2 ●●● patch | view | raw | blame | history
src/com/gitblit/client/EditRepositoryDialog.java 4 ●●●● patch | view | raw | blame | history
src/com/gitblit/client/GitblitClient.java 9 ●●●●● patch | view | raw | blame | history
src/com/gitblit/client/RepositoriesPanel.java 1 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/EditRepositoryPage.java 5 ●●●● patch | view | raw | blame | history
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
#
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)
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);
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()));
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
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());
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) {