]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6863 Support Integrated Authentication for SQL Server with SonarQube installed...
authorKoushik Dasgupta <koushikd@microsoft.com>
Tue, 29 Sep 2015 07:41:03 +0000 (13:11 +0530)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 29 Sep 2015 21:34:04 +0000 (23:34 +0200)
Enabling Integrated Authentication for connecting to MS Sql Server. Default value for sonar.jdbc.username and sonar.jdbc.password have been removed.

server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java
server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java
sonar-application/src/main/assembly/conf/sonar.properties
sonar-db/src/main/java/org/sonar/db/DefaultDatabase.java
sonar-db/src/test/java/org/sonar/db/DefaultDatabaseTest.java
sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseProperties.java

index f9bf1353b4b520a69baddcdaf450b8620000fa95..add8ab1a4c7b8d7667962a91822a6e846d8ffa3e 100644 (file)
@@ -115,8 +115,6 @@ public class ProcessProperties {
     defaults.put(ProcessProperties.WEB_JAVA_OPTS, "-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true");
     defaults.put(ProcessProperties.WEB_JAVA_ADDITIONAL_OPTS, "");
     defaults.put(ProcessProperties.JDBC_URL, "jdbc:h2:tcp://localhost:9092/sonar");
-    defaults.put(ProcessProperties.JDBC_LOGIN, "sonar");
-    defaults.put(ProcessProperties.JDBC_PASSWORD, "sonar");
     defaults.put(ProcessProperties.JDBC_MAX_ACTIVE, "50");
     defaults.put(ProcessProperties.JDBC_MAX_IDLE, "5");
     defaults.put(ProcessProperties.JDBC_MIN_IDLE, "2");
index 65fb20ee3fc184a749901cf1de731f06d9378d1b..ea7a5f09cefda4adf37d5f285f5a2bd635d2fe83 100644 (file)
@@ -34,7 +34,6 @@ public class ProcessPropertiesTest {
     ProcessProperties.completeDefaults(props);
 
     assertThat(props.value("sonar.search.javaOpts")).contains("-Xmx");
-    assertThat(props.value("sonar.jdbc.username")).isEqualTo("sonar");
     assertThat(props.valueAsInt("sonar.jdbc.maxActive")).isEqualTo(50);
   }
 
index e9626756fffe7dc0be97ee06a880c5202ec59360..850fe3bd7d4489e448b7c8d3e2bb8b63489bf176 100644 (file)
@@ -11,8 +11,8 @@
 # User credentials.
 # Permissions to create tables, indices and triggers must be granted to JDBC user.
 # The schema must be created first.
-#sonar.jdbc.username=sonar
-#sonar.jdbc.password=sonar
+#sonar.jdbc.username=
+#sonar.jdbc.password=
 
 #----- Embedded Database (default)
 # It does not accept connections from remote hosts, so the
 
 #----- Microsoft SQLServer 2008/2012
 # Collation must be case-sensitive (CS) and accent-sensitive (AS).
+#Use the following connection string if you want to use integrated security with MS Sql Server.
+#Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Auth
+#For Integrated Security to work, you have to download the MS SQL JDBC driver package from http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774
+#and copy sqljdbc_auth.dll to your path. If you have to copy the 32 bit or 64 bit version of the dll depending upon the architecture of your server machine
+#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar;integratedSecurity=true
+
+#Use the following connection string if you want to use SQL Auth while connecting to MS Sql Server. Set the sonar.jdbc.username and sonar.jdbc.password appropriately
 #sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar
 
 
index 47db0259f00013f94ba44c3b4d80c11229eed04c..cf71253f7f5e9c7310460a46bd441adf7120b998 100644 (file)
@@ -162,8 +162,10 @@ public class DefaultDatabase implements Database {
 
   private static void completeDefaultProperties(Properties props) {
     completeDefaultProperty(props, DatabaseProperties.PROP_URL, DEFAULT_URL);
-    completeDefaultProperty(props, DatabaseProperties.PROP_USER, props.getProperty(DatabaseProperties.PROP_USER_DEPRECATED, DatabaseProperties.PROP_USER_DEFAULT_VALUE));
-    completeDefaultProperty(props, DatabaseProperties.PROP_PASSWORD, DatabaseProperties.PROP_PASSWORD_DEFAULT_VALUE);
+
+    if (props.getProperty(DatabaseProperties.PROP_USER_DEPRECATED) != null) {
+      completeDefaultProperty(props, DatabaseProperties.PROP_USER, props.getProperty(DatabaseProperties.PROP_USER_DEPRECATED));
+    }
   }
 
   private static void completeDefaultProperty(Properties props, String key, String defaultValue) {
index 8fda6636030fec6a1f7f02c9fbba2889d14c6564..0d0c4ee1ad67e62ede9eb083100c521d9d677076 100644 (file)
@@ -35,8 +35,6 @@ public class DefaultDatabaseTest {
     db.initSettings();
 
     Properties props = db.getProperties();
-    assertThat(props.getProperty("sonar.jdbc.username")).isEqualTo("sonar");
-    assertThat(props.getProperty("sonar.jdbc.password")).isEqualTo("sonar");
     assertThat(props.getProperty("sonar.jdbc.url")).isEqualTo("jdbc:h2:tcp://localhost/sonar");
     assertThat(props.getProperty("sonar.jdbc.driverClassName")).isEqualTo("org.h2.Driver");
     assertThat(db.toString()).isEqualTo("Database[jdbc:h2:tcp://localhost/sonar]");
index fe9d208b16578affa5d76eff4d756335c0247b93..7b427b3faf1e75e3e09f69c803b9d0e444dbea63 100644 (file)
@@ -27,9 +27,9 @@ public interface DatabaseProperties {
   String PROP_DRIVER = "sonar.jdbc.driverClassName";
   String PROP_USER = "sonar.jdbc.username";
   String PROP_USER_DEPRECATED = "sonar.jdbc.user";
-  String PROP_USER_DEFAULT_VALUE = "sonar";
+  String PROP_USER_DEFAULT_VALUE = "";
   String PROP_PASSWORD = "sonar.jdbc.password";
-  String PROP_PASSWORD_DEFAULT_VALUE = "sonar";
+  String PROP_PASSWORD_DEFAULT_VALUE = "";
   String PROP_DIALECT = "sonar.jdbc.dialect";
 
   /**