Merge "Add new config option to disallow registration of new emails"
This commit is contained in:
@@ -2972,6 +2972,16 @@ and all other properties of section sendemail are ignored.
|
|||||||
+
|
+
|
||||||
By default, true, allowing notifications to be sent.
|
By default, true, allowing notifications to be sent.
|
||||||
|
|
||||||
|
[[sendemail.allowRegisterNewEmail]]sendemail.allowRegisterNewEmail::
|
||||||
|
+
|
||||||
|
Whether users are allowed to register new email addresses.
|
||||||
|
+
|
||||||
|
In addition for the HTTP authentication type
|
||||||
|
link:#auth.httpemailheader[auth.httpemailheader] must *not* be set to
|
||||||
|
enable registration of new email addresses.
|
||||||
|
+
|
||||||
|
By default, true.
|
||||||
|
|
||||||
[[sendemail.connectTimeout]]sendemail.connectTimeout::
|
[[sendemail.connectTimeout]]sendemail.connectTimeout::
|
||||||
+
|
+
|
||||||
The connection timeout of opening a socket connected to a
|
The connection timeout of opening a socket connected to a
|
||||||
|
@@ -19,6 +19,7 @@ import com.google.gerrit.reviewdb.client.Account;
|
|||||||
import com.google.gerrit.reviewdb.client.AuthType;
|
import com.google.gerrit.reviewdb.client.AuthType;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.config.AuthConfig;
|
import com.google.gerrit.server.config.AuthConfig;
|
||||||
|
import com.google.gerrit.server.mail.EmailSettings;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@@ -27,13 +28,17 @@ import java.util.Set;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class DefaultRealm extends AbstractRealm {
|
public class DefaultRealm extends AbstractRealm {
|
||||||
private final EmailExpander emailExpander;
|
private final EmailExpander emailExpander;
|
||||||
|
private final EmailSettings emailSettings;
|
||||||
private final AccountByEmailCache byEmail;
|
private final AccountByEmailCache byEmail;
|
||||||
private final AuthConfig authConfig;
|
private final AuthConfig authConfig;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DefaultRealm(final EmailExpander emailExpander,
|
DefaultRealm(EmailExpander emailExpander,
|
||||||
final AccountByEmailCache byEmail, final AuthConfig authConfig) {
|
EmailSettings emailSettings,
|
||||||
|
AccountByEmailCache byEmail,
|
||||||
|
AuthConfig authConfig) {
|
||||||
this.emailExpander = emailExpander;
|
this.emailExpander = emailExpander;
|
||||||
|
this.emailSettings = emailSettings;
|
||||||
this.byEmail = byEmail;
|
this.byEmail = byEmail;
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
}
|
}
|
||||||
@@ -47,12 +52,18 @@ public class DefaultRealm extends AbstractRealm {
|
|||||||
case FULL_NAME:
|
case FULL_NAME:
|
||||||
return Strings.emptyToNull(authConfig.getHttpDisplaynameHeader()) == null;
|
return Strings.emptyToNull(authConfig.getHttpDisplaynameHeader()) == null;
|
||||||
case REGISTER_NEW_EMAIL:
|
case REGISTER_NEW_EMAIL:
|
||||||
return Strings.emptyToNull(authConfig.getHttpEmailHeader()) == null;
|
return emailSettings.allowRegisterNewEmail
|
||||||
|
&& Strings.emptyToNull(authConfig.getHttpEmailHeader()) == null;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return true;
|
switch (field) {
|
||||||
|
case REGISTER_NEW_EMAIL:
|
||||||
|
return emailSettings.allowRegisterNewEmail;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@ import com.google.gerrit.server.account.EmailExpander;
|
|||||||
import com.google.gerrit.server.auth.AuthenticationUnavailableException;
|
import com.google.gerrit.server.auth.AuthenticationUnavailableException;
|
||||||
import com.google.gerrit.server.config.AuthConfig;
|
import com.google.gerrit.server.config.AuthConfig;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
|
import com.google.gerrit.server.mail.EmailSettings;
|
||||||
import com.google.gwtorm.server.SchemaFactory;
|
import com.google.gwtorm.server.SchemaFactory;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
@@ -75,9 +76,10 @@ public class LdapRealm extends AbstractRealm {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LdapRealm(
|
LdapRealm(
|
||||||
final Helper helper,
|
Helper helper,
|
||||||
final AuthConfig authConfig,
|
AuthConfig authConfig,
|
||||||
final EmailExpander emailExpander,
|
EmailExpander emailExpander,
|
||||||
|
EmailSettings emailSettings,
|
||||||
@Named(LdapModule.GROUP_CACHE) final LoadingCache<String, Set<AccountGroup.UUID>> membershipCache,
|
@Named(LdapModule.GROUP_CACHE) final LoadingCache<String, Set<AccountGroup.UUID>> membershipCache,
|
||||||
@Named(LdapModule.USERNAME_CACHE) final LoadingCache<String, Optional<Account.Id>> usernameCache,
|
@Named(LdapModule.USERNAME_CACHE) final LoadingCache<String, Optional<Account.Id>> usernameCache,
|
||||||
@GerritServerConfig final Config config) {
|
@GerritServerConfig final Config config) {
|
||||||
@@ -96,6 +98,9 @@ public class LdapRealm extends AbstractRealm {
|
|||||||
if (optdef(config, "accountSshUserName", "DEFAULT") != null) {
|
if (optdef(config, "accountSshUserName", "DEFAULT") != null) {
|
||||||
readOnlyAccountFields.add(Account.FieldName.USER_NAME);
|
readOnlyAccountFields.add(Account.FieldName.USER_NAME);
|
||||||
}
|
}
|
||||||
|
if (!emailSettings.allowRegisterNewEmail) {
|
||||||
|
readOnlyAccountFields.add(Account.FieldName.REGISTER_NEW_EMAIL);
|
||||||
|
}
|
||||||
|
|
||||||
fetchMemberOfEagerly = optional(config, "fetchMemberOfEagerly", true);
|
fetchMemberOfEagerly = optional(config, "fetchMemberOfEagerly", true);
|
||||||
}
|
}
|
||||||
|
@@ -21,12 +21,14 @@ import com.google.inject.Singleton;
|
|||||||
import org.eclipse.jgit.lib.Config;
|
import org.eclipse.jgit.lib.Config;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class EmailSettings {
|
public class EmailSettings {
|
||||||
final boolean includeDiff;
|
public final boolean allowRegisterNewEmail;
|
||||||
final int maximumDiffSize;
|
public final boolean includeDiff;
|
||||||
|
public final int maximumDiffSize;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
EmailSettings(@GerritServerConfig Config cfg) {
|
EmailSettings(@GerritServerConfig Config cfg) {
|
||||||
|
allowRegisterNewEmail = cfg.getBoolean("sendemail", "allowRegisterNewEmail", true);
|
||||||
includeDiff = cfg.getBoolean("sendemail", "includeDiff", false);
|
includeDiff = cfg.getBoolean("sendemail", "includeDiff", false);
|
||||||
maximumDiffSize = cfg.getInt("sendemail", "maximumDiffSize", 256 << 10);
|
maximumDiffSize = cfg.getInt("sendemail", "maximumDiffSize", 256 << 10);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user