9fd39a0681
* WIP on mongodb plugin * Add mongodb plugin * Add tests * Update mongodb.CreateUser() comment * Update docs * Add missing docs * Fix mongodb docs * Minor comment and test updates * Fix imports * Fix dockertest import * Set c.Initialized at the end, check for empty CreationStmts first on CreateUser * Remove Initialized check on Connection() * Add back Initialized check * Update docs * Move connProducer and credsProducer into pkg for mongodb and cassandra * Chage parseMongoURL to be a private func * Default to admin if no db is provided in creation_statements * Update comments and docs
38 lines
909 B
Go
38 lines
909 B
Go
package cassandra
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
uuid "github.com/hashicorp/go-uuid"
|
|
)
|
|
|
|
// cassandraCredentialsProducer implements CredentialsProducer and provides an
|
|
// interface for cassandra databases to generate user information.
|
|
type cassandraCredentialsProducer struct{}
|
|
|
|
func (ccp *cassandraCredentialsProducer) GenerateUsername(displayName string) (string, error) {
|
|
userUUID, err := uuid.GenerateUUID()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
username := fmt.Sprintf("vault_%s_%s_%d", displayName, userUUID, time.Now().Unix())
|
|
username = strings.Replace(username, "-", "_", -1)
|
|
|
|
return username, nil
|
|
}
|
|
|
|
func (ccp *cassandraCredentialsProducer) GeneratePassword() (string, error) {
|
|
password, err := uuid.GenerateUUID()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return password, nil
|
|
}
|
|
|
|
func (ccp *cassandraCredentialsProducer) GenerateExpiration(ttl time.Time) (string, error) {
|
|
return "", nil
|
|
}
|