Make PasswordAuthenticator number of hashing rounds configurable

Patch by Sam Tunnicliffe; Reviewed by Robert Stupp for CASSANDRA-8085
This commit is contained in:
Sam Tunnicliffe 2015-03-24 14:14:18 +01:00 committed by Robert Stupp
parent bcf0ec6819
commit bf1ea024d5
2 changed files with 15 additions and 2 deletions

View File

@ -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)

View File

@ -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";