You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2014/08/20 01:05:27 UTC

[1/2] git commit: Improve PasswordAuthenticator default super user setup

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 296903bd3 -> 31d5193a7


Improve PasswordAuthenticator default super user setup

patch by Aleksey Yeschenko; reviewed by Jeremiah Jordan for
CASSANDRA-7788


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

Branch: refs/heads/cassandra-2.0
Commit: 48d6950c181987952a4b05e60f918646445d62f9
Parents: 22a4629
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Wed Aug 20 02:01:14 2014 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Wed Aug 20 02:01:14 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 src/java/org/apache/cassandra/auth/Auth.java    | 25 ++++++++----------
 .../cassandra/auth/PasswordAuthenticator.java   | 27 +++++++++-----------
 3 files changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/48d6950c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9fad7c9..db5fa3a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2.19
+ * Improve PasswordAuthenticator default super user setup (CASSANDRA-7788)
  * Remove duplicates from StorageService.getJoiningNodes (CASSANDRA-7478)
  * Clone token map outside of hot gossip loops (CASSANDRA-7758)
  * Add stop method to EmbeddedCassandraService (CASSANDRA-7595)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48d6950c/src/java/org/apache/cassandra/auth/Auth.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/auth/Auth.java b/src/java/org/apache/cassandra/auth/Auth.java
index 9cee12a..60c87d7 100644
--- a/src/java/org/apache/cassandra/auth/Auth.java
+++ b/src/java/org/apache/cassandra/auth/Auth.java
@@ -38,7 +38,6 @@ import org.apache.cassandra.locator.SimpleStrategy;
 import org.apache.cassandra.service.*;
 import org.apache.cassandra.transport.messages.ResultMessage;
 import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
 
 public class Auth
 {
@@ -137,18 +136,15 @@ public class Auth
         // the delay is here to give the node some time to see its peers - to reduce
         // "Skipped default superuser setup: some nodes were not ready" log spam.
         // It's the only reason for the delay.
-        if (DatabaseDescriptor.getSeeds().contains(FBUtilities.getBroadcastAddress()) || !DatabaseDescriptor.isAutoBootstrap())
-        {
-            StorageService.tasks.schedule(new Runnable()
+        StorageService.tasks.schedule(new Runnable()
+                                      {
+                                          public void run()
                                           {
-                                              public void run()
-                                              {
-                                                  setupDefaultSuperuser();
-                                              }
-                                          },
-                                          SUPERUSER_SETUP_DELAY,
-                                          TimeUnit.MILLISECONDS);
-        }
+                                              setupDefaultSuperuser();
+                                          }
+                                      },
+                                      SUPERUSER_SETUP_DELAY,
+                                      TimeUnit.MILLISECONDS);
 
         try
         {
@@ -213,7 +209,7 @@ public class Auth
                                                      USERS_CF,
                                                      DEFAULT_SUPERUSER_NAME,
                                                      true),
-                                       ConsistencyLevel.QUORUM);
+                                       ConsistencyLevel.ONE);
                 logger.info("Created default superuser '{}'", DEFAULT_SUPERUSER_NAME);
             }
         }
@@ -228,7 +224,8 @@ public class Auth
         // Try looking up the 'cassandra' default super user first, to avoid the range query if possible.
         String defaultSUQuery = String.format("SELECT * FROM %s.%s WHERE name = '%s'", AUTH_KS, USERS_CF, DEFAULT_SUPERUSER_NAME);
         String allUsersQuery = String.format("SELECT * FROM %s.%s LIMIT 1", AUTH_KS, USERS_CF);
-        return !QueryProcessor.process(defaultSUQuery, ConsistencyLevel.QUORUM).isEmpty()
+        return !QueryProcessor.process(defaultSUQuery, ConsistencyLevel.ONE).isEmpty()
+            || !QueryProcessor.process(defaultSUQuery, ConsistencyLevel.QUORUM).isEmpty()
             || !QueryProcessor.process(allUsersQuery, ConsistencyLevel.QUORUM).isEmpty();
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48d6950c/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 9adbe4e..dfe7275 100644
--- a/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java
+++ b/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java
@@ -27,7 +27,6 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.UntypedResultSet;
 import org.apache.cassandra.cql3.QueryProcessor;
@@ -39,7 +38,6 @@ import org.apache.cassandra.service.QueryState;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.transport.messages.ResultMessage;
 import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
 import org.mindrot.jbcrypt.BCrypt;
 
 /**
@@ -169,18 +167,15 @@ public class PasswordAuthenticator implements IAuthenticator
         // the delay is here to give the node some time to see its peers - to reduce
         // "skipped default user setup: some nodes are were not ready" log spam.
         // It's the only reason for the delay.
-        if (DatabaseDescriptor.getSeeds().contains(FBUtilities.getBroadcastAddress()) || !DatabaseDescriptor.isAutoBootstrap())
-        {
-            StorageService.tasks.schedule(new Runnable()
+        StorageService.tasks.schedule(new Runnable()
+                                      {
+                                          public void run()
                                           {
-                                              public void run()
-                                              {
-                                                  setupDefaultUser();
-                                              }
-                                          },
-                                          Auth.SUPERUSER_SETUP_DELAY,
-                                          TimeUnit.MILLISECONDS);
-        }
+                                              setupDefaultUser();
+                                          }
+                                      },
+                                      Auth.SUPERUSER_SETUP_DELAY,
+                                      TimeUnit.MILLISECONDS);
 
         try
         {
@@ -224,7 +219,7 @@ public class PasswordAuthenticator implements IAuthenticator
                                       CREDENTIALS_CF,
                                       DEFAULT_USER_NAME,
                                       escape(hashpw(DEFAULT_USER_PASSWORD))),
-                        ConsistencyLevel.QUORUM);
+                        ConsistencyLevel.ONE);
                 logger.info("PasswordAuthenticator created default user '{}'", DEFAULT_USER_NAME);
             }
         }
@@ -239,7 +234,9 @@ public class PasswordAuthenticator implements IAuthenticator
         // Try looking up the 'cassandra' default user first, to avoid the range query if possible.
         String defaultSUQuery = String.format("SELECT * FROM %s.%s WHERE username = '%s'", Auth.AUTH_KS, CREDENTIALS_CF, DEFAULT_USER_NAME);
         String allUsersQuery = String.format("SELECT * FROM %s.%s LIMIT 1", Auth.AUTH_KS, CREDENTIALS_CF);
-        return !process(defaultSUQuery, ConsistencyLevel.QUORUM).isEmpty() || !process(allUsersQuery, ConsistencyLevel.QUORUM).isEmpty();
+        return !process(defaultSUQuery, ConsistencyLevel.ONE).isEmpty()
+            || !process(defaultSUQuery, ConsistencyLevel.QUORUM).isEmpty()
+            || !process(allUsersQuery, ConsistencyLevel.QUORUM).isEmpty();
     }
 
     private static String hashpw(String password)


[2/2] git commit: Merge branch 'cassandra-1.2' into cassandra-2.0

Posted by al...@apache.org.
Merge branch 'cassandra-1.2' into cassandra-2.0

Conflicts:
	CHANGES.txt


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

Branch: refs/heads/cassandra-2.0
Commit: 31d5193a7ab73d6dfaa2ec2367c24296755c5584
Parents: 296903b 48d6950
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Wed Aug 20 02:05:17 2014 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Wed Aug 20 02:05:17 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 src/java/org/apache/cassandra/auth/Auth.java    | 25 ++++++++----------
 .../cassandra/auth/PasswordAuthenticator.java   | 27 +++++++++-----------
 3 files changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/31d5193a/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index de45376,db5fa3a..1de5b33
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,62 -1,5 +1,63 @@@
 -1.2.19
 +2.0.10
 + * Throw InvalidRequestException when queries contain relations on entire
 +   collection columns (CASSANDRA-7506)
 + * Fix PRSI handling of CQL3 row markers for row cleanup (CASSANDRA-7787)
 + * (cqlsh) enable CTRL-R history search with libedit (CASSANDRA-7577)
 + * Fix dropping collection when it's the last regular column (CASSANDRA-7744)
 + * Properly reject operations on list index with conditions (CASSANDRA-7499)
 + * (Hadoop) allow ACFRW to limit nodes to local DC (CASSANDRA-7252)
 + * (cqlsh) Wait up to 10 sec for a tracing session (CASSANDRA-7222)
 + * Fix NPE in FileCacheService.sizeInBytes (CASSANDRA-7756)
 + * (cqlsh) cqlsh should automatically disable tracing when selecting
 +   from system_traces (CASSANDRA-7641)
 + * (Hadoop) Add CqlOutputFormat (CASSANDRA-6927)
 + * Don't depend on cassandra config for nodetool ring (CASSANDRA-7508)
 + * (cqlsh) Fix failing cqlsh formatting tests (CASSANDRA-7703)
 + * Fix MS expiring map timeout for Paxos messages (CASSANDRA-7752)
 + * Do not flush on truncate if durable_writes is false (CASSANDRA-7750)
 + * Give CRR a default input_cql Statement (CASSANDRA-7226)
 + * Better error message when adding a collection with the same name
 +   than a previously dropped one (CASSANDRA-6276)
 + * Fix validation when adding static columns (CASSANDRA-7730)
 + * (Thrift) fix range deletion of supercolumns (CASSANDRA-7733)
 + * Fix potential AssertionError in RangeTombstoneList (CASSANDRA-7700)
 + * Validate arguments of blobAs* functions (CASSANDRA-7707)
 + * Fix potential AssertionError with 2ndary indexes (CASSANDRA-6612)
 + * Avoid logging CompactionInterrupted at ERROR (CASSANDRA-7694)
 + * Minor leak in sstable2jon (CASSANDRA-7709)
 + * Add cassandra.auto_bootstrap system property (CASSANDRA-7650)
 + * Remove CqlPagingRecordReader/CqlPagingInputFormat (CASSANDRA-7570)
 + * Fix IncompatibleClassChangeError from hadoop2 (CASSANDRA-7229)
 + * Add 'nodetool sethintedhandoffthrottlekb' (CASSANDRA-7635)
 + * Update java driver (for hadoop) (CASSANDRA-7618)
 + * Fix truncate to always flush (CASSANDRA-7511)
 + * Remove shuffle and taketoken (CASSANDRA-7601)
 + * Switch liveRatio-related log messages to DEBUG (CASSANDRA-7467)
 + * (cqlsh) Add tab-completion for CREATE/DROP USER IF [NOT] EXISTS (CASSANDRA-7611)
 + * Always merge ranges owned by a single node (CASSANDRA-6930)
 + * Pig support for hadoop CqlInputFormat (CASSANDRA-6454)
 + * Fix ReversedType(DateType) mapping to native protocol (CASSANDRA-7576)
 + * (Windows) force range-based repair to non-sequential mode (CASSANDRA-7541)
 + * Fix range merging when DES scores are zero (CASSANDRA-7535)
 + * Warn when SSL certificates have expired (CASSANDRA-7528)
 + * Workaround JVM NPE on JMX bind failure (CASSANDRA-7254)
 + * Fix race in FileCacheService RemovalListener (CASSANDRA-7278)
 + * Fix inconsistent use of consistencyForCommit that allowed LOCAL_QUORUM
 +   operations to incorrect become full QUORUM (CASSANDRA-7345)
 + * Properly handle unrecognized opcodes and flags (CASSANDRA-7440)
 + * (Hadoop) close CqlRecordWriter clients when finished (CASSANDRA-7459)
 + * Make sure high level sstables get compacted (CASSANDRA-7414)
 + * Fix AssertionError when using empty clustering columns and static columns
 +   (CASSANDRA-7455)
 + * Add inter_dc_stream_throughput_outbound_megabits_per_sec (CASSANDRA-6596)
 + * Add option to disable STCS in L0 (CASSANDRA-6621)
 + * Fix error when doing reversed queries with static columns (CASSANDRA-7490)
 + * Backport CASSNADRA-3569/CASSANDRA-6747 (CASSANDRA-7560)
 + * Track max/min timestamps for range tombstones (CASSANDRA-7647)
 + * Fix NPE when listing saved caches dir (CASSANDRA-7632)
 + * Fix sstableloader unable to connect encrypted node (CASSANDRA-7585)
 +Merged from 1.2:
+  * Improve PasswordAuthenticator default super user setup (CASSANDRA-7788)
   * Remove duplicates from StorageService.getJoiningNodes (CASSANDRA-7478)
   * Clone token map outside of hot gossip loops (CASSANDRA-7758)
   * Add stop method to EmbeddedCassandraService (CASSANDRA-7595)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/31d5193a/src/java/org/apache/cassandra/auth/Auth.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/31d5193a/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java
----------------------------------------------------------------------