diff --git a/CHANGES.txt b/CHANGES.txt index 0e75973025..e85b622802 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.4 + * Make PasswordAuthenticator number of hashing rounds configurable (CASSANDRA-8085) * Fix AssertionError when binding nested collections in DELETE (CASSANDRA-8900) * Check for overlap with non-early sstables in LCS (CASSANDRA-8739) * Only calculate max purgable timestamp if we have to (CASSANDRA-8914) diff --git a/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java b/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java index 957077042e..7d3066425c 100644 --- a/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java +++ b/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java @@ -31,6 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.cassandra.concurrent.ScheduledExecutors; +import org.apache.cassandra.config.Config; import org.apache.cassandra.cql3.UntypedResultSet; import org.apache.cassandra.cql3.QueryProcessor; import org.apache.cassandra.cql3.QueryOptions; @@ -51,8 +52,19 @@ public class PasswordAuthenticator implements ISaslAwareAuthenticator { private static final Logger logger = LoggerFactory.getLogger(PasswordAuthenticator.class); - // 2 ** GENSALT_LOG2_ROUNS rounds of hashing will be performed. - private static final int GENSALT_LOG2_ROUNDS = 10; + // 2 ** GENSALT_LOG2_ROUNDS rounds of hashing will be performed. + private static final String GENSALT_LOG2_ROUNDS_PROPERTY = Config.PROPERTY_PREFIX + "auth_bcrypt_gensalt_log2_rounds"; + private static final int GENSALT_LOG2_ROUNDS = getGensaltLogRounds(); + + static int getGensaltLogRounds() + { + int rounds = Integer.getInteger(GENSALT_LOG2_ROUNDS_PROPERTY, 10); + if (rounds < 4 || rounds > 31) + throw new RuntimeException(new ConfigurationException(String.format("Bad value for system property -D%s. " + + "Please use a value 4 and 31", + GENSALT_LOG2_ROUNDS_PROPERTY))); + return rounds; + } // name of the hash column. private static final String SALTED_HASH = "salted_hash";