feat(cassandra): support for user/pw authentication

This commit is contained in:
Jens Rantil 2017-09-17 13:32:00 +02:00
parent d25732a53a
commit a5e584ce22
2 changed files with 9 additions and 0 deletions

View File

@ -16,6 +16,8 @@ system_schema table which comes with 3.X
| `consistency` | ALL | Migration consistency
| `protocol` | | Cassandra protocol version (3 or 4)
| `timeout` | 1 minute | Migration timeout
| `username` | nil | Username to use when authenticating. |
| `password` | nil | Password to use when authenticating. |
`timeout` is parsed using [time.ParseDuration(s string)](https://golang.org/pkg/time/#ParseDuration)

View File

@ -65,6 +65,13 @@ func (p *Cassandra) Open(url string) (database.Driver, error) {
cluster.Consistency = gocql.All
cluster.Timeout = 1 * time.Minute
if len(u.Query().Get("username")) > 0 && len(u.Query().Get("password")) > 0 {
authenticator := gocql.PasswordAuthenticator{
Username: u.Query().Get("username"),
Password: u.Query().Get("password"),
}
cluster.Authenticator = authenticator
}
// Retrieve query string configuration
if len(u.Query().Get("consistency")) > 0 {