Update secrets fields

This commit is contained in:
Brian Kassouf 2017-03-08 14:46:53 -08:00
parent 2fb6bf9882
commit b7128f8370
3 changed files with 22 additions and 27 deletions

View File

@ -2,6 +2,7 @@ package dbs
import (
"database/sql"
"fmt"
"strings"
"github.com/hashicorp/vault/helper/strutil"
@ -41,6 +42,10 @@ func (m *MySQL) CreateUser(statements Statements, username, password, expiration
return err
}
if statements.CreationStatements == "" {
return fmt.Errorf("Empty creation statements")
}
// Start a transaction
tx, err := db.Begin()
if err != nil {

View File

@ -197,22 +197,22 @@ func (b *databaseBackend) pathConnectionWrite(req *logical.Request, data *framew
b.connections[name] = db
}
/*
// Don't check the connection_url if verification is disabled
verifyConnection := data.Get("verify_connection").(bool)
if verifyConnection {
// Verify the string
db, err := sql.Open("postgres", connURL)
if 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
}
/* TODO:
// Don't check the connection_url if verification is disabled
verifyConnection := data.Get("verify_connection").(bool)
if verifyConnection {
// Verify the string
db, err := sql.Open("postgres", connURL)
if 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

View File

@ -11,18 +11,8 @@ const SecretCredsType = "creds"
func secretCreds(b *databaseBackend) *framework.Secret {
return &framework.Secret{
Type: SecretCredsType,
Fields: map[string]*framework.FieldSchema{
"username": &framework.FieldSchema{
Type: framework.TypeString,
Description: "Username",
},
"password": &framework.FieldSchema{
Type: framework.TypeString,
Description: "Password",
},
},
Type: SecretCredsType,
Fields: map[string]*framework.FieldSchema{},
Renew: b.secretCredsRenew,
Revoke: b.secretCredsRevoke,