This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new c4bfbc5f1 ATLAS-3422: Cassandra audit repository updated to support
authenticated Cassandra cluster
c4bfbc5f1 is described below
commit c4bfbc5f15cdd3fa49f5403b6f5adaac4d93090c
Author: Arun Vasudevan <[email protected]>
AuthorDate: Tue Sep 24 14:37:35 2019 -0500
ATLAS-3422: Cassandra audit repository updated to support authenticated
Cassandra cluster
Signed-off-by: Madhan Neethiraj <[email protected]>
(cherry picked from commit e156bb56756aaa6ed23af41c4305b3f9d4bb5912)
---
distro/src/conf/atlas-application.properties | 2 ++
.../atlas/repository/audit/CassandraBasedAuditRepository.java | 8 +++++++-
.../atlas/repository/audit/CassandraAuditRepositoryTest.java | 5 +++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/distro/src/conf/atlas-application.properties
b/distro/src/conf/atlas-application.properties
index dade26e80..79c1273d7 100755
--- a/distro/src/conf/atlas-application.properties
+++ b/distro/src/conf/atlas-application.properties
@@ -35,6 +35,8 @@
# See the configuration documentation for more information about configuring
the various storage backends.
#
atlas.graph.storage.backend=${graph.storage.backend}
+atlas.graph.storage.username=
+atlas.graph.storage.password=
atlas.graph.storage.hbase.table=apache_atlas_janus
${graph.storage.properties}
diff --git
a/repository/src/main/java/org/apache/atlas/repository/audit/CassandraBasedAuditRepository.java
b/repository/src/main/java/org/apache/atlas/repository/audit/CassandraBasedAuditRepository.java
index 4037ac206..1f9174e2e 100644
---
a/repository/src/main/java/org/apache/atlas/repository/audit/CassandraBasedAuditRepository.java
+++
b/repository/src/main/java/org/apache/atlas/repository/audit/CassandraBasedAuditRepository.java
@@ -69,6 +69,8 @@ public class CassandraBasedAuditRepository extends
AbstractStorageBasedAuditRepo
public static final String CASSANDRA_PORT_PROPERTY =
"atlas.graph.storage.port";
public static final String CASSANDRA_REPLICATION_FACTOR_PROPERTY =
"atlas.EntityAuditRepository.replicationFactor";
public static final String CASSANDRA_AUDIT_KEYSPACE_PROPERTY =
"atlas.EntityAuditRepository.keyspace";
+ public static final String CASSANDRA_USERNAME_PROPERTY =
"atlas.graph.storage.username";
+ public static final String CASSANDRA_PASSWORD_PROPERTY =
"atlas.graph.storage.password";
private static final String AUDIT_TABLE_SCHEMA =
"CREATE TABLE audit(entityid text, "
@@ -97,6 +99,8 @@ public class CassandraBasedAuditRepository extends
AbstractStorageBasedAuditRepo
private Session cassSession;
private String clusterName;
private int port;
+ private String username;
+ private String password;
private Map<String, List<String>> auditExcludedAttributesCache = new
HashMap<>();
private PreparedStatement insertStatement;
@@ -211,6 +215,8 @@ public class CassandraBasedAuditRepository extends
AbstractStorageBasedAuditRepo
replicationFactor =
APPLICATION_PROPERTIES.getInt(CASSANDRA_REPLICATION_FACTOR_PROPERTY,
DEFAULT_REPLICATION_FACTOR);
clusterName =
APPLICATION_PROPERTIES.getString(CASSANDRA_CLUSTERNAME_PROPERTY,
DEFAULT_CLUSTER_NAME);
port = APPLICATION_PROPERTIES.getInt(CASSANDRA_PORT_PROPERTY,
DEFAULT_PORT);
+ username = APPLICATION_PROPERTIES.getString(CASSANDRA_USERNAME_PROPERTY,
"");
+ password = APPLICATION_PROPERTIES.getString(CASSANDRA_PASSWORD_PROPERTY,
"");
}
@VisibleForTesting
@@ -222,7 +228,7 @@ public class CassandraBasedAuditRepository extends
AbstractStorageBasedAuditRepo
Cluster.Builder cassandraClusterBuilder = Cluster.builder();
String hostname =
APPLICATION_PROPERTIES.getString(CASSANDRA_HOSTNAME_PROPERTY, "localhost");
- Cluster cluster =
cassandraClusterBuilder.addContactPoint(hostname).withClusterName(clusterName).withPort(port).build();
+ Cluster cluster =
cassandraClusterBuilder.addContactPoint(hostname).withClusterName(clusterName).withPort(port).withCredentials(username.trim(),
password.trim()).build();
try {
cassSession = cluster.connect();
if (cluster.getMetadata().getKeyspace(keyspace) == null) {
diff --git
a/repository/src/test/java/org/apache/atlas/repository/audit/CassandraAuditRepositoryTest.java
b/repository/src/test/java/org/apache/atlas/repository/audit/CassandraAuditRepositoryTest.java
index 26d3a6042..6d28ada6e 100644
---
a/repository/src/test/java/org/apache/atlas/repository/audit/CassandraAuditRepositoryTest.java
+++
b/repository/src/test/java/org/apache/atlas/repository/audit/CassandraAuditRepositoryTest.java
@@ -38,6 +38,8 @@ public class CassandraAuditRepositoryTest extends
AuditRepositoryTestBase {
private final String CLUSTER_HOST = "localhost";
private final String CLUSTER_NAME_TEST = "Test Cluster";
private final int CLUSTER_PORT = 9042;
+ private final String CLUSTER_USERNAME = "";
+ private final String CLUSTER_PASSWORD = "";
@BeforeClass
public void setup() {
@@ -61,6 +63,8 @@ public class CassandraAuditRepositoryTest extends
AuditRepositoryTestBase {
props.put(CassandraBasedAuditRepository.CASSANDRA_CLUSTERNAME_PROPERTY,
CLUSTER_NAME_TEST);
props.put(CassandraBasedAuditRepository.CASSANDRA_HOSTNAME_PROPERTY,
CLUSTER_HOST);
props.put(CassandraBasedAuditRepository.CASSANDRA_PORT_PROPERTY,
CLUSTER_PORT);
+ props.put(CassandraBasedAuditRepository.CASSANDRA_USERNAME_PROPERTY,
CLUSTER_USERNAME);
+ props.put(CassandraBasedAuditRepository.CASSANDRA_PASSWORD_PROPERTY,
CLUSTER_PASSWORD);
return props;
}
@@ -69,6 +73,7 @@ public class CassandraAuditRepositoryTest extends
AuditRepositoryTestBase {
Cluster.Builder cassandraClusterBuilder = Cluster.builder();
Cluster cluster =
cassandraClusterBuilder.addContactPoint(CLUSTER_HOST).withClusterName(CLUSTER_NAME_TEST).withPort(CLUSTER_PORT)
+ .withCredentials(CLUSTER_USERNAME.trim(),
CLUSTER_PASSWORD.trim())
.build();
int retryCount = 0;