Skip to content

Commit

Permalink
Implement username/password authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris O'Meara committed Jul 12, 2016
1 parent cd5517d commit 577941a
Show file tree
Hide file tree
Showing 6 changed files with 840 additions and 10 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,24 @@ application.conf might look like the following:
acceptance_test {
cassandra-seed-address: "127.0.0.1"
cassandra-keyspace-name: "pillar_acceptance_test"
cassandra-port: "9042"
cassandra-ssl: "true"
cassandra-username: "faker"
cassandra-password: "soopersecret"
}
}

[typesafeconfig]:https://github.com/typesafehub/config

Alternatively, Pillar accepts environment variable overrides according to the following table.

| Key | Environment Variable | Default |
|------------------------------------------------|----------------------|---------|
| pillar.\<store>.\<env>.cassandra-seed-address | PILLAR_SEED_ADDRESS | |
| pillar.\<store>.\<env>.cassandra-keyspace-name | | |
| pillar.\<store>.\<env>.cassandra-port | PILLAR_PORT | 9042 |
| pillar.\<store>.\<env>.cassandra-ssl | PILLAR_SSL | false |
| Key | Environment Variable | Default |
|------------------------------------------------|----------------------|-----------|
| pillar.\<store>.\<env>.cassandra-seed-address | PILLAR_SEED_ADDRESS | |
| pillar.\<store>.\<env>.cassandra-keyspace-name | | |
| pillar.\<store>.\<env>.cassandra-port | PILLAR_PORT | 9042 |
| pillar.\<store>.\<env>.cassandra-ssl | PILLAR_SSL | false |
| pillar.\<store>.\<env>.cassandra-username | PILLAR_USERNAME | cassandra |
| pillar.\<store>.\<env>.cassandra-password | PILLAR_PASSWORD | cassandra |

Reference the acceptance spec suite for details.

Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/com/chrisomeara/pillar/cli/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class App(reporter: Reporter) {
case Some(s) => s
case _ => getFromConfiguration(configuration, dataStoreName, environment, "cassandra-port", Some(9042.toString))
})
val builder = Cluster.builder().addContactPoint(seedAddress).withPort(port)
val username = sys.env.getOrElse("PILLAR_USERNAME", getFromConfiguration(configuration, dataStoreName, environment, "cassandra-username", Some("cassandra")))
val password = sys.env.getOrElse("PILLAR_PASSWORD", getFromConfiguration(configuration, dataStoreName, environment, "cassandra-password", Some("cassandra")))
val builder = Cluster.builder().addContactPoint(seedAddress).withPort(port).withCredentials(username, password)
if(sys.env.get("PILLAR_SSL") match {
case Some(s) => s.toBoolean
case None => getFromConfiguration(configuration, dataStoreName, environment, "cassandra-ssl", Some("false")).toBoolean
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/docker/cassandra-with-auth-2.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM cassandra:2.1

ADD contents /
Loading

0 comments on commit 577941a

Please sign in to comment.