Configure signed push verification on a per-project basis
Add a new inheritable boolean "enableSignedPush" to configure the hook for each project, assuming it is enabled for the server. For the default case, where it is not configured on the server, do not surface this value in the UI at all. Change-Id: I51baab5bfc15607a3c47ee8752b10d4972e8550e
This commit is contained in:
@@ -42,6 +42,7 @@ public interface AdminConstants extends Constants {
|
||||
String useContributorAgreements();
|
||||
String useSignedOffBy();
|
||||
String createNewChangeForAllNotInTarget();
|
||||
String enableSignedPush();
|
||||
String requireChangeID();
|
||||
String headingMaxObjectSizeLimit();
|
||||
String headingGroupOptions();
|
||||
|
||||
@@ -24,6 +24,7 @@ useContentMerge = Allow content merges
|
||||
useContributorAgreements = Require a valid contributor agreement to upload
|
||||
useSignedOffBy = Require <code>Signed-off-by</code> in commit message
|
||||
createNewChangeForAllNotInTarget = Create a new change for every commit not in the target branch
|
||||
enableSignedPush = Enable signed push
|
||||
requireChangeID = Require <code>Change-Id</code> in commit message
|
||||
headingMaxObjectSizeLimit = Maximum Git object size limit
|
||||
headingGroupOptions = Group Options
|
||||
|
||||
@@ -82,6 +82,7 @@ public class ProjectInfoScreen extends ProjectScreen {
|
||||
private ListBox state;
|
||||
private ListBox contentMerge;
|
||||
private ListBox newChangeForAllNotInTarget;
|
||||
private ListBox enableSignedPush;
|
||||
private NpTextBox maxObjectSizeLimit;
|
||||
private Label effectiveMaxObjectSizeLimit;
|
||||
private Map<String, Map<String, HasEnabled>> pluginConfigWidgets;
|
||||
@@ -162,6 +163,9 @@ public class ProjectInfoScreen extends ProjectScreen {
|
||||
submitType.setEnabled(isOwner);
|
||||
setEnabledForUseContentMerge();
|
||||
newChangeForAllNotInTarget.setEnabled(isOwner);
|
||||
if (enableSignedPush != null) {
|
||||
enableSignedPush.setEnabled(isOwner);
|
||||
}
|
||||
descTxt.setEnabled(isOwner);
|
||||
contributorAgreements.setEnabled(isOwner);
|
||||
signedOffBy.setEnabled(isOwner);
|
||||
@@ -226,6 +230,12 @@ public class ProjectInfoScreen extends ProjectScreen {
|
||||
saveEnabler.listenTo(requireChangeID);
|
||||
grid.addHtml(Util.C.requireChangeID(), requireChangeID);
|
||||
|
||||
if (Gerrit.info().receive().enableSignedPush()) {
|
||||
enableSignedPush = newInheritedBooleanBox();
|
||||
saveEnabler.listenTo(enableSignedPush);
|
||||
grid.add(Util.C.enableSignedPush(), enableSignedPush);
|
||||
}
|
||||
|
||||
maxObjectSizeLimit = new NpTextBox();
|
||||
saveEnabler.listenTo(maxObjectSizeLimit);
|
||||
effectiveMaxObjectSizeLimit = new Label();
|
||||
@@ -349,6 +359,9 @@ public class ProjectInfoScreen extends ProjectScreen {
|
||||
setBool(contentMerge, result.useContentMerge());
|
||||
setBool(newChangeForAllNotInTarget, result.createNewChangeForAllNotInTarget());
|
||||
setBool(requireChangeID, result.requireChangeId());
|
||||
if (enableSignedPush != null) {
|
||||
setBool(enableSignedPush, result.enableSignedPush());
|
||||
}
|
||||
setSubmitType(result.submitType());
|
||||
setState(result.state());
|
||||
maxObjectSizeLimit.setText(result.maxObjectSizeLimit().configuredValue());
|
||||
@@ -618,9 +631,12 @@ public class ProjectInfoScreen extends ProjectScreen {
|
||||
private void doSave() {
|
||||
enableForm(false);
|
||||
saveProject.setEnabled(false);
|
||||
InheritableBoolean sp = enableSignedPush != null
|
||||
? getBool(enableSignedPush) : null;
|
||||
ProjectApi.setConfig(getProjectKey(), descTxt.getText().trim(),
|
||||
getBool(contributorAgreements), getBool(contentMerge),
|
||||
getBool(signedOffBy), getBool(newChangeForAllNotInTarget), getBool(requireChangeID),
|
||||
sp,
|
||||
maxObjectSizeLimit.getText().trim(),
|
||||
SubmitType.valueOf(submitType.getValue(submitType.getSelectedIndex())),
|
||||
ProjectState.valueOf(state.getValue(state.getSelectedIndex())),
|
||||
|
||||
@@ -26,6 +26,7 @@ public class ServerInfo extends JavaScriptObject {
|
||||
public final native SshdInfo sshd() /*-{ return this.sshd; }-*/;
|
||||
public final native SuggestInfo suggest() /*-{ return this.suggest; }-*/;
|
||||
public final native UserConfigInfo user() /*-{ return this.user; }-*/;
|
||||
public final native ReceiveInfo receive() /*-{ return this.receive; }-*/;
|
||||
|
||||
public final boolean hasContactStore() {
|
||||
return contactStore() != null;
|
||||
@@ -74,4 +75,12 @@ public class ServerInfo extends JavaScriptObject {
|
||||
protected UserConfigInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ReceiveInfo extends JavaScriptObject {
|
||||
public final native boolean enableSignedPush()
|
||||
/*-{ return this.enable_signed_push || false; }-*/;
|
||||
|
||||
protected ReceiveInfo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ public class ConfigInfo extends JavaScriptObject {
|
||||
public final native InheritedBooleanInfo useSignedOffBy()
|
||||
/*-{ return this.use_signed_off_by; }-*/;
|
||||
|
||||
public final native InheritedBooleanInfo enableSignedPush()
|
||||
/*-{ return this.enable_signed_push; }-*/;
|
||||
|
||||
public final SubmitType submitType() {
|
||||
return SubmitType.valueOf(submitTypeRaw());
|
||||
}
|
||||
|
||||
@@ -99,7 +99,9 @@ public class ProjectApi {
|
||||
InheritableBoolean useContributorAgreements,
|
||||
InheritableBoolean useContentMerge, InheritableBoolean useSignedOffBy,
|
||||
InheritableBoolean createNewChangeForAllNotInTarget,
|
||||
InheritableBoolean requireChangeId, String maxObjectSizeLimit,
|
||||
InheritableBoolean requireChangeId,
|
||||
InheritableBoolean enableSignedPush,
|
||||
String maxObjectSizeLimit,
|
||||
SubmitType submitType, ProjectState state,
|
||||
Map<String, Map<String, ConfigParameterValue>> pluginConfigValues,
|
||||
AsyncCallback<ConfigInfo> cb) {
|
||||
@@ -110,6 +112,9 @@ public class ProjectApi {
|
||||
in.setUseSignedOffBy(useSignedOffBy);
|
||||
in.setRequireChangeId(requireChangeId);
|
||||
in.setCreateNewChangeForAllNotInTarget(createNewChangeForAllNotInTarget);
|
||||
if (enableSignedPush != null) {
|
||||
in.setEnableSignedPush(enableSignedPush);
|
||||
}
|
||||
in.setMaxObjectSizeLimit(maxObjectSizeLimit);
|
||||
in.setSubmitType(submitType);
|
||||
in.setState(state);
|
||||
@@ -230,6 +235,12 @@ public class ProjectApi {
|
||||
private final native void setCreateNewChangeForAllNotInTargetRaw(String v)
|
||||
/*-{ if(v)this.create_new_change_for_all_not_in_target=v; }-*/;
|
||||
|
||||
final void setEnableSignedPush(InheritableBoolean v) {
|
||||
setEnableSignedPushRaw(v.name());
|
||||
}
|
||||
private final native void setEnableSignedPushRaw(String v)
|
||||
/*-{ if(v)this.enable_signed_push=v; }-*/;
|
||||
|
||||
final native void setMaxObjectSizeLimit(String l)
|
||||
/*-{ if(l)this.max_object_size_limit=l; }-*/;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user