Skip to content
This repository was archived by the owner on Jun 28, 2018. It is now read-only.

Commit 62cddb9

Browse files
authored
Merge pull request #278 from JensRantil/cassandra-auth
feat(cassandra): support for user/pw authentication
2 parents eabba5b + a5e584c commit 62cddb9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

database/cassandra/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ system_schema table which comes with 3.X
1616
| `consistency` | ALL | Migration consistency
1717
| `protocol` | | Cassandra protocol version (3 or 4)
1818
| `timeout` | 1 minute | Migration timeout
19+
| `username` | nil | Username to use when authenticating. |
20+
| `password` | nil | Password to use when authenticating. |
1921

2022

2123
`timeout` is parsed using [time.ParseDuration(s string)](https://golang.org/pkg/time/#ParseDuration)

database/cassandra/cassandra.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ func (p *Cassandra) Open(url string) (database.Driver, error) {
6565
cluster.Consistency = gocql.All
6666
cluster.Timeout = 1 * time.Minute
6767

68+
if len(u.Query().Get("username")) > 0 && len(u.Query().Get("password")) > 0 {
69+
authenticator := gocql.PasswordAuthenticator{
70+
Username: u.Query().Get("username"),
71+
Password: u.Query().Get("password"),
72+
}
73+
cluster.Authenticator = authenticator
74+
}
6875

6976
// Retrieve query string configuration
7077
if len(u.Query().Get("consistency")) > 0 {

0 commit comments

Comments
 (0)