diff --git a/builtin/logical/database/dbs/cassandra.go b/builtin/logical/database/dbs/cassandra.go index 9956372d6..1be26766b 100644 --- a/builtin/logical/database/dbs/cassandra.go +++ b/builtin/logical/database/dbs/cassandra.go @@ -45,8 +45,17 @@ func (c *Cassandra) CreateUser(statements Statements, username, password, expira return err } + creationCQL := statements.CreationStatements + if creationCQL == "" { + creationCQL = defaultCreationCQL + } + rollbackCQL := statements.RollbackStatements + if rollbackCQL == "" { + rollbackCQL = defaultRollbackCQL + } + // Execute each query - for _, query := range strutil.ParseArbitraryStringSlice(statements.CreationStatements, ";") { + for _, query := range strutil.ParseArbitraryStringSlice(creationCQL, ";") { query = strings.TrimSpace(query) if len(query) == 0 { continue @@ -57,7 +66,7 @@ func (c *Cassandra) CreateUser(statements Statements, username, password, expira "password": password, })).Exec() if err != nil { - for _, query := range strutil.ParseArbitraryStringSlice(statements.RollbackStatements, ";") { + for _, query := range strutil.ParseArbitraryStringSlice(rollbackCQL, ";") { query = strings.TrimSpace(query) if len(query) == 0 { continue diff --git a/builtin/logical/database/dbs/db.go b/builtin/logical/database/dbs/db.go index e3e8cb39b..e173e2dd8 100644 --- a/builtin/logical/database/dbs/db.go +++ b/builtin/logical/database/dbs/db.go @@ -94,6 +94,8 @@ type DatabaseConfig struct { MaxConnectionLifetime time.Duration `json:"max_connection_lifetime" structs:"max_connection_lifetime" mapstructure:"max_connection_lifetime"` } +// Statments set in role creation and passed into the database type's functions. +// TODO: Add a way of setting defaults here. type Statements struct { CreationStatements string `json:"creation_statments" mapstructure:"creation_statements" structs:"creation_statments"` RevocationStatements string `json:"revocation_statements" mapstructure:"revocation_statements" structs:"revocation_statements"`