Is Authentication to a Cassandra cluster not supported?

2,130 views
Skip to first unread message

Colin McQueen

unread,
Apr 3, 2014, 3:08:49 PM4/3/14
to spring-dat...@googlegroups.com
I am trying to get authentication working on my local Cassandra cluster but it fails with the following error:

Invocation of init method failed; nested exception is com.datastax.driver.core.exceptions.AuthenticationException: Authentication error on host localhost/127.0.0.1: SASL Authentication is not supported in version 1 of the protocol

My Java config is the following:

@Configuration
@EnableCassandraRepositories(basePackages = {
    "com.foo.repository"
})
public class CassandraConfiguration extends AbstractCassandraConfiguration {

    @Value("${contactPoints}")
    private String contactPoints;
    @Value("${user}")
    private String user;
    @Value("${password}")
    private String password;

    @Override
    protected String getContactPoints() {
        return contactPoints;
    }

    @Override
    protected AuthProvider getAuthProvider() {
        return new PlainTextAuthProvider(user, password);
    }

    @Override
    protected final String getKeyspaceName() {
        return "foo";
    }

    @Bean
    @Override
    public CassandraAdminOperations cassandraTemplate() throws Exception {
        return super.cassandraTemplate();
    }

Colin McQueen

unread,
Apr 3, 2014, 3:16:14 PM4/3/14
to spring-dat...@googlegroups.com
My local Cassandra is Apache Cassandra 2.0.5.

Matthew Adams

unread,
Apr 3, 2014, 5:26:46 PM4/3/14
to spring-dat...@googlegroups.com
As noted at https://github.com/spring-projects/spring-data-cassandra#current-status, Cassandra 1.x is supported, not 2.x.  Might that be the problem?

Colin McQueen

unread,
Apr 4, 2014, 6:33:30 AM4/4/14
to spring-dat...@googlegroups.com
I was aware that right now Spring Data Cassandra is only supporting Cassandra 1. Does the Cassandra 1 driver not support authentication?

David Webb (Prowave)

unread,
Apr 4, 2014, 9:14:17 AM4/4/14
to Colin McQueen, spring-dat...@googlegroups.com

Thanks for the input, I’ll ask the DS Driver Team about that.

 

From: Colin McQueen [mailto:colin....@shiftenergy.com]
Sent: Friday, April 04, 2014 9:13 AM
To: David Webb (Prowave)
Subject: Re: Is Authentication to a Cassandra cluster not supported?

 

Hi David,

 

Option 2 does not work as updating the driver to version 2 causes a NoClassDef exception on the Query class. Driver 2 renamed the Query class to Statement and a few other classes. Going to try option 1.


Colin McQueen

Software Developer

 

On Fri, Apr 4, 2014 at 10:00 AM, David Webb (Prowave) <dw...@prowaveconsulting.com> wrote:

Colin,

 

I have 2 suggestions to try.

 

1)      Use the DseAuthProvider with the 1.0.X-dse driver (default dependency for SDC 1.0.0).  This is supported.

 

            CassandraClusterFactoryBean factory = new CassandraClusterFactoryBean();

            factory.setContactPoints(env.getProperty("seeds"));

            factory.setPort(Integer.parseInt(env.getProperty("port")));

            factory.setAuthProvider(new DseAuthProvider());

            factory.setUsername(env.getProperty("username"));

            factory.setPassword(env.getProperty("password"));

               

Note: Using XML Config you can pass the Auth Provider Ref as well.

 

2)      Using the same stratey, you can try your SASL Auth Provider class, and then override the DS Java Driver dependency to use the 2.0.X version.  DS Driver engineers have told us that the 2.0.X driver is backwards compatible, but we have not tested it yet.

 

Please respond and let the group know if either of these options work with C* 2.0. J

 

Thanks,

Dave

--
You received this message because you are subscribed to the Google Groups "Spring Data Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-data-cass...@googlegroups.com.

 

Colin McQueen

unread,
Apr 4, 2014, 9:32:14 AM4/4/14
to David Webb (Prowave), spring-dat...@googlegroups.com
Option 1 did not work, resulted in the same error.

Colin McQueen
Software Developer

David Webb (Prowave)

unread,
Apr 4, 2014, 9:34:33 AM4/4/14
to Colin McQueen, spring-dat...@googlegroups.com

Can you provide your auth settings from cassandra.yaml?

Colin McQueen

unread,
Apr 4, 2014, 9:35:23 AM4/4/14
to David Webb (Prowave), spring-dat...@googlegroups.com
# Authentication backend, implementing IAuthenticator; used to identify users
# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthenticator,
# PasswordAuthenticator}.
#
# - AllowAllAuthenticator performs no checks - set it to disable authentication.
# - PasswordAuthenticator relies on username/password pairs to authenticate
#   users. It keeps usernames and hashed passwords in system_auth.credentials table.
#   Please increase system_auth keyspace replication factor if you use this authenticator.
authenticator: PasswordAuthenticator

# Authorization backend, implementing IAuthorizer; used to limit access/provide permissions
# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthorizer,
# CassandraAuthorizer}.
#
# - AllowAllAuthorizer allows any action to any user - set it to disable authorization.
# - CassandraAuthorizer stores permissions in system_auth.permissions table. Please
#   increase system_auth keyspace replication factor if you use this authorizer.
authorizer: CassandraAuthorizer

Colin McQueen
Software Developer

David Webb (Prowave)

unread,
Apr 4, 2014, 11:20:21 AM4/4/14
to Colin McQueen, spring-dat...@googlegroups.com

Support for Cassandra 2.0 will be in SDC 1.1 and required API changes as you have discovered. There is no solution at this time based on the feedback from DataStax.

Colin McQueen

unread,
Apr 4, 2014, 11:24:37 AM4/4/14
to David Webb (Prowave), spring-dat...@googlegroups.com
Ok, thanks for letting me know. We disabled authentication for now and will turn it back on when SDC supports it.

Colin McQueen
Software Developer

David van Geest

unread,
Apr 10, 2014, 10:44:17 AM4/10/14
to spring-dat...@googlegroups.com
Hi,

I am trying to get authentication to work with Cassandra 1.2, and am having difficulty. It's not clear to me if this thread is suggesting that authentication should also not work for 1.2. Can someone clarify?


My XML config looks like this:

  <bean id="cassandraAuthProvider" class="com.datastax.driver.core.sasl.DseAuthProvider" />

  <cql:cluster
    contact-points="${cassandra.contact_points}"
    port="${cassandra.port}"
    ssl-enabled="${cassandra.ssl_enabled}"
    auth-info-provider-ref="cassandraAuthProvider"
    username="${cassandra.username}"
    password="${cassandra.password}" />
  <cql:session keyspace-name="${cassandra.keyspace_name}" />
  <cql:template />

But, I get the following exception when Cassandra has auth turned on:

Caused by: com.datastax.driver.core.exceptions.AuthenticationException: Authentication error on host localhost/127.0.0.1: java.lang.ArrayIndexOutOfBoundsException: 15
at com.datastax.driver.core.Connection.waitForSaslCompletion(Connection.java:203)
at com.datastax.driver.core.Connection.initializeTransport(Connection.java:169)
at com.datastax.driver.core.Connection.<init>(Connection.java:131)
at com.datastax.driver.core.Connection.<init>(Connection.java:59)
at com.datastax.driver.core.Connection$Factory.open(Connection.java:444)
at com.datastax.driver.core.ControlConnection.tryConnect(ControlConnection.java:205)
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:168)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:81)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:812)
at com.datastax.driver.core.Cluster$Manager.access$100(Cluster.java:739)
at com.datastax.driver.core.Cluster.<init>(Cluster.java:82)
at com.datastax.driver.core.Cluster.<init>(Cluster.java:67)
at com.datastax.driver.core.Cluster$Builder.build(Cluster.java:708)
at org.springframework.cassandra.config.CassandraCqlClusterFactoryBean.afterPropertiesSet(CassandraCqlClusterFactoryBean.java:186)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$6.run(AbstractAutowireCapableBeanFactory.java:1561)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1559)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)

Is this expected? Or am I just doing something wrong?

Thanks!

Colin McQueen
Software Developer



Colin McQueen

Software Developer

 


Colin McQueen

Software Developer

 


Colin McQueen

Software Developer

 

To unsubscribe from this group and stop receiving emails from it, send an email to spring-data-cassandra+unsub...@googlegroups.com.

David Webb

unread,
Apr 10, 2014, 1:29:55 PM4/10/14
to spring-dat...@googlegroups.com
Auth is supported in C* 1.2.  Can you start a new thread please with all your details.

Can you authenticate with cqlsh?
Reply all
Reply to author
Forward
0 new messages