ソースを参照

Added setting to globally disable anonymous pushes in the receive pack

Change-Id: I3460c9c0eeb32503d58325fd09793a0cd40aa2c4
tags/v1.4.0
James Moger 10年前
コミット
629806c4c0

+ 2
- 0
releases.moxie ファイルの表示

- Added branch graph image servlet based on EGit's branch graph renderer (issue-194) - Added branch graph image servlet based on EGit's branch graph renderer (issue-194)
- Added option to render Markdown commit messages (issue-203) - Added option to render Markdown commit messages (issue-203)
- Added setting to control creating a repository as --shared on Unix servers (issue-263) - Added setting to control creating a repository as --shared on Unix servers (issue-263)
- Added setting to globally disable anonymous pushes in the receive pack
dependencyChanges: ~ dependencyChanges: ~
settings: settings:
- { name: 'git.createRepositoriesShared', defaultValue: 'false' } - { name: 'git.createRepositoriesShared', defaultValue: 'false' }
- { name: 'git.allowAnonymousPushes', defaultValue: 'true' }
- { name: 'web.commitMessageRenderer', defaultValue: 'plain' } - { name: 'web.commitMessageRenderer', defaultValue: 'plain' }
- { name: 'web.showBranchGraph', defaultValue: 'true' } - { name: 'web.showBranchGraph', defaultValue: 'true' }
contributors: contributors:

+ 12
- 0
src/main/distrib/data/gitblit.properties ファイルの表示

# SINCE 1.2.0 # SINCE 1.2.0
git.allowCreateOnPush = true git.allowCreateOnPush = true
# Global setting to control anonymous pushes.
#
# This setting allows/rejects anonymous pushes at the level of the receive pack.
# This trumps all repository config settings. While anonymous pushes are convenient
# on your own box when you are a lone developer, they are not recommended for
# any multi-user installation where accountability is required. Since Gitblit
# tracks pushes and user accounts, allowing anonymous pushes compromises that
# information.
#
# SINCE 1.4.0
git.allowAnonymousPushes = true
# The default access restriction for new repositories. # The default access restriction for new repositories.
# Valid values are NONE, PUSH, CLONE, VIEW # Valid values are NONE, PUSH, CLONE, VIEW
# NONE = anonymous view, clone, & push # NONE = anonymous view, clone, & push

+ 11
- 0
src/main/java/com/gitblit/Constants.java ファイルの表示

import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.jar.Attributes; import java.util.jar.Attributes;
import java.util.jar.Manifest; import java.util.jar.Manifest;
*/ */
public static enum AccessRestrictionType { public static enum AccessRestrictionType {
NONE, PUSH, CLONE, VIEW; NONE, PUSH, CLONE, VIEW;
private static final AccessRestrictionType [] AUTH_TYPES = { PUSH, CLONE, VIEW };
public static AccessRestrictionType fromName(String name) { public static AccessRestrictionType fromName(String name) {
for (AccessRestrictionType type : values()) { for (AccessRestrictionType type : values()) {
} }
return NONE; return NONE;
} }
public static List<AccessRestrictionType> choices(boolean allowAnonymousPush) {
if (allowAnonymousPush) {
return Arrays.asList(values());
}
return Arrays.asList(AUTH_TYPES);
}
public boolean exceeds(AccessRestrictionType type) { public boolean exceeds(AccessRestrictionType type) {
return this.ordinal() > type.ordinal(); return this.ordinal() > type.ordinal();

+ 2
- 2
src/main/java/com/gitblit/git/GitblitReceivePackFactory.java ファイルの表示

import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;


import com.gitblit.GitBlit; import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.RepositoryModel; import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel; import com.gitblit.models.UserModel;
import com.gitblit.utils.HttpUtils; import com.gitblit.utils.HttpUtils;
timeout = client.getDaemon().getTimeout(); timeout = client.getDaemon().getTimeout();
} }


// TODO make this a setting
boolean allowAnonymousPushes = true;
boolean allowAnonymousPushes = GitBlit.getBoolean(Keys.git.allowAnonymousPushes, true);
if (!allowAnonymousPushes && UserModel.ANONYMOUS.equals(user)) { if (!allowAnonymousPushes && UserModel.ANONYMOUS.equals(user)) {
// prohibit anonymous pushes // prohibit anonymous pushes
throw new ServiceNotEnabledException(); throw new ServiceNotEnabledException();

+ 2
- 2
src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java ファイルの表示

form.add(new TextField<String>("description")); form.add(new TextField<String>("description"));
form.add(ownersPalette); form.add(ownersPalette);
form.add(new CheckBox("allowForks").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true))); form.add(new CheckBox("allowForks").setEnabled(GitBlit.getBoolean(Keys.web.allowForking, true)));
DropDownChoice<AccessRestrictionType> accessRestriction = new DropDownChoice<AccessRestrictionType>("accessRestriction", Arrays
.asList(AccessRestrictionType.values()), new AccessRestrictionRenderer());
DropDownChoice<AccessRestrictionType> accessRestriction = new DropDownChoice<AccessRestrictionType>("accessRestriction",
AccessRestrictionType.choices(GitBlit.getBoolean(Keys.git.allowAnonymousPushes, true)), new AccessRestrictionRenderer());
form.add(accessRestriction); form.add(accessRestriction);
form.add(new CheckBox("isFrozen")); form.add(new CheckBox("isFrozen"));
// TODO enable origin definition // TODO enable origin definition

読み込み中…
キャンセル
保存