Update secrets fields
This commit is contained in:
parent
2fb6bf9882
commit
b7128f8370
|
@ -2,6 +2,7 @@ package dbs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/helper/strutil"
|
"github.com/hashicorp/vault/helper/strutil"
|
||||||
|
@ -41,6 +42,10 @@ func (m *MySQL) CreateUser(statements Statements, username, password, expiration
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if statements.CreationStatements == "" {
|
||||||
|
return fmt.Errorf("Empty creation statements")
|
||||||
|
}
|
||||||
|
|
||||||
// Start a transaction
|
// Start a transaction
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -197,22 +197,22 @@ func (b *databaseBackend) pathConnectionWrite(req *logical.Request, data *framew
|
||||||
b.connections[name] = db
|
b.connections[name] = db
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* TODO:
|
||||||
// Don't check the connection_url if verification is disabled
|
// Don't check the connection_url if verification is disabled
|
||||||
verifyConnection := data.Get("verify_connection").(bool)
|
verifyConnection := data.Get("verify_connection").(bool)
|
||||||
if verifyConnection {
|
if verifyConnection {
|
||||||
// Verify the string
|
// Verify the string
|
||||||
db, err := sql.Open("postgres", connURL)
|
db, err := sql.Open("postgres", connURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return logical.ErrorResponse(fmt.Sprintf(
|
return logical.ErrorResponse(fmt.Sprintf(
|
||||||
"Error validating connection info: %s", err)), nil
|
"Error validating connection info: %s", err)), nil
|
||||||
}
|
|
||||||
defer db.Close()
|
|
||||||
if err := db.Ping(); err != nil {
|
|
||||||
return logical.ErrorResponse(fmt.Sprintf(
|
|
||||||
"Error validating connection info: %s", err)), nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
defer db.Close()
|
||||||
|
if err := db.Ping(); err != nil {
|
||||||
|
return logical.ErrorResponse(fmt.Sprintf(
|
||||||
|
"Error validating connection info: %s", err)), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Store it
|
// Store it
|
||||||
|
|
|
@ -11,18 +11,8 @@ const SecretCredsType = "creds"
|
||||||
|
|
||||||
func secretCreds(b *databaseBackend) *framework.Secret {
|
func secretCreds(b *databaseBackend) *framework.Secret {
|
||||||
return &framework.Secret{
|
return &framework.Secret{
|
||||||
Type: SecretCredsType,
|
Type: SecretCredsType,
|
||||||
Fields: map[string]*framework.FieldSchema{
|
Fields: map[string]*framework.FieldSchema{},
|
||||||
"username": &framework.FieldSchema{
|
|
||||||
Type: framework.TypeString,
|
|
||||||
Description: "Username",
|
|
||||||
},
|
|
||||||
|
|
||||||
"password": &framework.FieldSchema{
|
|
||||||
Type: framework.TypeString,
|
|
||||||
Description: "Password",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
Renew: b.secretCredsRenew,
|
Renew: b.secretCredsRenew,
|
||||||
Revoke: b.secretCredsRevoke,
|
Revoke: b.secretCredsRevoke,
|
||||||
|
|
Loading…
Reference in a new issue