cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject [1/3] cassandra git commit: Make PasswordAuthenticator number of hashing rounds configurable
Date Tue, 24 Mar 2015 13:15:43 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 bcf0ec681 -> bf1ea024d
  refs/heads/trunk 789aa72e5 -> 5735f2a25


Make PasswordAuthenticator number of hashing rounds configurable

Patch by Sam Tunnicliffe; Reviewed by Robert Stupp for CASSANDRA-8085


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/bf1ea024
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/bf1ea024
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/bf1ea024

Branch: refs/heads/cassandra-2.1
Commit: bf1ea024d50dc0243bb8cec2a23b01a709b4e705
Parents: bcf0ec6
Author: Sam Tunnicliffe <sam@beobal.com>
Authored: Tue Mar 24 14:14:18 2015 +0100
Committer: Robert Stupp <snazy@snazy.de>
Committed: Tue Mar 24 14:14:18 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../cassandra/auth/PasswordAuthenticator.java       | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/bf1ea024/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 0e75973..e85b622 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)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/bf1ea024/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java b/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java
index 9570770..7d30664 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";


Mime
View raw message