diff options
8 files changed, 15 insertions, 85 deletions
diff --git a/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java b/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java index bbf78cb077e..defd825a670 100644 --- a/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java +++ b/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java @@ -24,7 +24,6 @@ import com.google.common.collect.Maps; import com.sonar.orchestrator.Orchestrator; import java.util.Map; import javax.annotation.CheckForNull; -import org.apache.commons.lang.RandomStringUtils; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; @@ -85,7 +84,6 @@ public class RealmAuthenticationTest { public void resetData() throws Exception { setServerProperty(orchestrator, USERS_PROPERTY, null); setServerProperty(orchestrator, "sonar.security.updateUserAttributes", null); - setServerProperty(orchestrator, "sonar.authenticator.createUsers", null); USER_RULE.resetUsers(); } @@ -215,30 +213,6 @@ public class RealmAuthenticationTest { verifyAuthenticationIsNotOk(username, "wrong"); } - /** - * SONAR-1334 (createUsers=false) - */ - @Test - public void shouldNotCreateNewUsers() { - // Given clean Sonar installation and no users in external system - setServerProperty(orchestrator, "sonar.authenticator.createUsers", "false"); - // Use a random user name because if we use existing disabled user then it doesn't work because rails doesn't handle this case - // (it's using User.find_by_login to know if user exists or not - String username = RandomStringUtils.randomAlphanumeric(20); - String password = "1234567"; - Map<String, String> users = Maps.newHashMap(); - - // When user not exists in external system - // Then - verifyAuthenticationIsNotOk(username, password); - - // When user created in external system - users.put(username + ".password", password); - updateUsersInExtAuth(users); - // Then - verifyAuthenticationIsNotOk(username, password); - } - // SONAR-3258 @Test public void shouldAutomaticallyReactivateDeletedUser() throws Exception { diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index b2329a2c1b8..391e632c063 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -109,7 +109,7 @@ public class ComputeEngineContainerImplTest { + 25 // level 1 + 47 // content of DaoModule + 3 // content of EsSearchModule - + 61 // content of CorePropertyDefinitions + + 60 // content of CorePropertyDefinitions + 1 // content of CePropertyDefinitions ); assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/RealmAuthenticator.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/RealmAuthenticator.java index e8b7b0cd9dd..26dd2d1a09c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/RealmAuthenticator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/RealmAuthenticator.java @@ -45,7 +45,6 @@ import org.sonar.server.user.SecurityRealmFactory; import static java.util.Objects.requireNonNull; import static org.apache.commons.lang.StringUtils.isEmpty; import static org.apache.commons.lang.StringUtils.trimToNull; -import static org.sonar.api.CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS; import static org.sonar.server.authentication.event.AuthenticationEvent.Source; import static org.sonar.server.user.ExternalIdentity.SQ_AUTHORITY; @@ -150,7 +149,7 @@ public class RealmAuthenticator implements Startable { return userLogin; } - private class ExternalIdentityProvider implements IdentityProvider { + private static class ExternalIdentityProvider implements IdentityProvider { @Override public String getKey() { return SQ_AUTHORITY; @@ -173,7 +172,7 @@ public class RealmAuthenticator implements Startable { @Override public boolean allowsUsersToSignUp() { - return settings.getBoolean(CORE_AUTHENTICATOR_CREATE_USERS); + return true; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java index a9c2bf37104..b7f56c83760 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java @@ -102,10 +102,6 @@ public class SonarQubeMonitor extends BaseMonitorMBean implements SonarQubeMonit .collect(Collectors.toList()); } - private boolean getAutomaticUserCreation() { - return settings.getBoolean(CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS); - } - private boolean getForceAuthentication() { return settings.getBoolean(CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY); } @@ -131,7 +127,6 @@ public class SonarQubeMonitor extends BaseMonitorMBean implements SonarQubeMonit addIfNotNull("External User Authentication", getExternalUserAuthentication(), attributes); addIfNotEmpty("Accepted external identity providers", getEnabledIdentityProviders(), attributes); addIfNotEmpty("External identity providers whose users are allowed to sign themselves up", getAllowsToSignUpEnabledIdentityProviders(), attributes); - attributes.put("Automatic User Creation", getAutomaticUserCreation()); attributes.put("Force authentication", getForceAuthentication()); attributes.put("Official Distribution", isOfficialDistribution()); attributes.put("Home Dir", settings.getString(ProcessProperties.PATH_HOME)); diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/RealmAuthenticatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/RealmAuthenticatorTest.java index 23d54777ac1..b2e42f84217 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/RealmAuthenticatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/RealmAuthenticatorTest.java @@ -181,30 +181,6 @@ public class RealmAuthenticatorTest { } @Test - public void allow_to_sign_up_property() throws Exception { - settings.setProperty("sonar.authenticator.createUsers", true); - when(userIdentityAuthenticator.authenticate(any(UserIdentity.class), any(IdentityProvider.class), any(Source.class))).thenReturn(USER); - executeStartWithoutGroupSync(); - executeAuthenticate(); - - verify(userIdentityAuthenticator).authenticate(userIdentityArgumentCaptor.capture(), identityProviderArgumentCaptor.capture(), sourceCaptor.capture()); - assertThat(identityProviderArgumentCaptor.getValue().allowsUsersToSignUp()).isTrue(); - verify(authenticationEvent).loginSuccess(request, LOGIN, Source.realm(BASIC, REALM_NAME)); - } - - @Test - public void does_not_allow_to_sign_up_property() throws Exception { - settings.setProperty("sonar.authenticator.createUsers", false); - when(userIdentityAuthenticator.authenticate(any(UserIdentity.class), any(IdentityProvider.class), any(Source.class))).thenReturn(USER); - executeStartWithoutGroupSync(); - executeAuthenticate(); - - verify(userIdentityAuthenticator).authenticate(userIdentityArgumentCaptor.capture(), identityProviderArgumentCaptor.capture(), sourceCaptor.capture()); - assertThat(identityProviderArgumentCaptor.getValue().allowsUsersToSignUp()).isFalse(); - verify(authenticationEvent).loginSuccess(request, LOGIN, Source.realm(BASIC, REALM_NAME)); - } - - @Test public void use_downcase_login() throws Exception { settings.setProperty("sonar.authenticator.downcase", true); when(userIdentityAuthenticator.authenticate(any(UserIdentity.class), any(IdentityProvider.class), any(Source.class))).thenReturn(USER); diff --git a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java index 12bbe0a1185..ffac9913d82 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java +++ b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java @@ -135,13 +135,6 @@ public class CorePropertyDefinitions { .defaultValue(String.valueOf(false)) .hidden() .build(), - PropertyDefinition.builder(CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS) - .name("Create user accounts") - .description("Create accounts when authenticating users via an external system") - .type(PropertyType.BOOLEAN) - .defaultValue(String.valueOf(true)) - .hidden() - .build(), PropertyDefinition.builder(CoreProperties.CORE_AUTHENTICATOR_IGNORE_STARTUP_FAILURE) .name("Ignore failures during authenticator startup") .type(PropertyType.BOOLEAN) diff --git a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java index b1198a6ef83..01f3d1bf9d2 100644 --- a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java @@ -19,42 +19,29 @@ */ package org.sonar.core.config; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; import java.util.List; -import javax.annotation.Nonnull; +import java.util.Optional; import org.junit.Test; import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.database.DatabaseProperties; -import static com.google.common.collect.FluentIterable.from; import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.api.database.DatabaseProperties.PROP_PASSWORD; public class CorePropertyDefinitionsTest { + @Test public void all() { List<PropertyDefinition> defs = CorePropertyDefinitions.all(); - assertThat(defs).hasSize(63); + assertThat(defs).hasSize(62); } @Test public void jdbc_password_property_has_password_type() { List<PropertyDefinition> defs = CorePropertyDefinitions.all(); - Optional<PropertyDefinition> prop = from(defs).filter(new HasKeyPredicate(DatabaseProperties.PROP_PASSWORD)).first(); + + Optional<PropertyDefinition> prop = defs.stream().filter(def -> PROP_PASSWORD.equals(def.key())).findFirst(); assertThat(prop.get().type()).isEqualTo(PropertyType.PASSWORD); } - private final class HasKeyPredicate implements Predicate<PropertyDefinition> { - private final String key; - - HasKeyPredicate(String key) { - this.key = key; - } - - @Override - public boolean apply(@Nonnull PropertyDefinition input) { - return key.equals(input.key()); - } - } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index f5e43721afd..2ca7280bea8 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -207,6 +207,12 @@ public interface CoreProperties { String CORE_AUTHENTICATOR_REALM = "sonar.security.realm"; String CORE_AUTHENTICATOR_IGNORE_STARTUP_FAILURE = "sonar.authenticator.ignoreStartupFailure"; + + /** + * @deprecated since 6.3. This feature is not supported anymore + * @see <a href="https://jira.sonarsource.com/browse/SONAR-8208">SONAR-8208/a> + */ + @Deprecated String CORE_AUTHENTICATOR_CREATE_USERS = "sonar.authenticator.createUsers"; /** |