mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-29 18:41:10 +02:00
* 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
37 lines
800 B
Go
37 lines
800 B
Go
package mongodb
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
uuid "github.com/hashicorp/go-uuid"
|
|
)
|
|
|
|
// mongoDBCredentialsProducer implements CredentialsProducer and provides an
|
|
// interface for databases to generate user information.
|
|
type mongoDBCredentialsProducer struct{}
|
|
|
|
func (cp *mongoDBCredentialsProducer) GenerateUsername(displayName string) (string, error) {
|
|
userUUID, err := uuid.GenerateUUID()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
username := fmt.Sprintf("vault-%s-%s", displayName, userUUID)
|
|
|
|
return username, nil
|
|
}
|
|
|
|
func (cp *mongoDBCredentialsProducer) GeneratePassword() (string, error) {
|
|
password, err := uuid.GenerateUUID()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return password, nil
|
|
}
|
|
|
|
func (cp *mongoDBCredentialsProducer) GenerateExpiration(ttl time.Time) (string, error) {
|
|
return "", nil
|
|
}
|