From 5d69e7da90ec8dd5719bb8e7cd2c66f5a6ae2830 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Tue, 30 Jun 2015 17:36:12 -0700 Subject: [PATCH] Updating for backend API change --- builtin/credential/app-id/backend.go | 6 +++++- builtin/credential/cert/backend.go | 2 +- builtin/credential/github/backend.go | 2 +- builtin/credential/ldap/backend.go | 5 ++--- builtin/credential/userpass/backend.go | 2 +- builtin/logical/aws/backend.go | 2 +- builtin/logical/cassandra/backend.go | 2 +- builtin/logical/consul/backend.go | 2 +- builtin/logical/mysql/backend.go | 2 +- builtin/logical/pki/backend.go | 2 +- builtin/logical/postgresql/backend.go | 2 +- builtin/logical/transit/backend.go | 2 +- logical/testing/testing.go | 2 +- 13 files changed, 18 insertions(+), 15 deletions(-) diff --git a/builtin/credential/app-id/backend.go b/builtin/credential/app-id/backend.go index 0425347b2..65bb477c9 100644 --- a/builtin/credential/app-id/backend.go +++ b/builtin/credential/app-id/backend.go @@ -1,19 +1,22 @@ package appId import ( + "github.com/hashicorp/vault/helper/salt" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } func Backend() *framework.Backend { + var salt *salt.Salt var b backend b.MapAppId = &framework.PolicyMap{ PathMap: framework.PathMap{ Name: "app-id", + Salt: salt, Schema: map[string]*framework.FieldSchema{ "display_name": &framework.FieldSchema{ Type: framework.TypeString, @@ -31,6 +34,7 @@ func Backend() *framework.Backend { b.MapUserId = &framework.PathMap{ Name: "user-id", + Salt: salt, Schema: map[string]*framework.FieldSchema{ "cidr_block": &framework.FieldSchema{ Type: framework.TypeString, diff --git a/builtin/credential/cert/backend.go b/builtin/credential/cert/backend.go index 88ddf5556..5137bd3b3 100644 --- a/builtin/credential/cert/backend.go +++ b/builtin/credential/cert/backend.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/vault/logical/framework" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/builtin/credential/github/backend.go b/builtin/credential/github/backend.go index 6a929056f..48bf17634 100644 --- a/builtin/credential/github/backend.go +++ b/builtin/credential/github/backend.go @@ -9,7 +9,7 @@ import ( "golang.org/x/oauth2" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/builtin/credential/ldap/backend.go b/builtin/credential/ldap/backend.go index 6af988bb9..b3f6c119c 100644 --- a/builtin/credential/ldap/backend.go +++ b/builtin/credential/ldap/backend.go @@ -3,12 +3,12 @@ package ldap import ( "fmt" + "github.com/go-ldap/ldap" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" - "github.com/go-ldap/ldap" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } @@ -93,7 +93,6 @@ func (b *backend) Login(req *logical.Request, username string, password string) return nil, logical.ErrorResponse(err.Error()), nil } - // Try to authenticate to the server using the provided credentials binddn := fmt.Sprintf("%s=%s,%s", cfg.UserAttr, EscapeLDAPValue(username), cfg.UserDN) if err = c.Bind(binddn, password); err != nil { diff --git a/builtin/credential/userpass/backend.go b/builtin/credential/userpass/backend.go index 2571a8305..dca810b0e 100644 --- a/builtin/credential/userpass/backend.go +++ b/builtin/credential/userpass/backend.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/vault/logical/framework" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/builtin/logical/aws/backend.go b/builtin/logical/aws/backend.go index dd471ee23..233b0ec5a 100644 --- a/builtin/logical/aws/backend.go +++ b/builtin/logical/aws/backend.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/vault/logical/framework" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/builtin/logical/cassandra/backend.go b/builtin/logical/cassandra/backend.go index 65480982f..fb4dce614 100644 --- a/builtin/logical/cassandra/backend.go +++ b/builtin/logical/cassandra/backend.go @@ -11,7 +11,7 @@ import ( ) // Factory creates a new backend -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/builtin/logical/consul/backend.go b/builtin/logical/consul/backend.go index f8070377e..0a19e395b 100644 --- a/builtin/logical/consul/backend.go +++ b/builtin/logical/consul/backend.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/vault/logical/framework" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/builtin/logical/mysql/backend.go b/builtin/logical/mysql/backend.go index 1d0222208..aa619fbc6 100644 --- a/builtin/logical/mysql/backend.go +++ b/builtin/logical/mysql/backend.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/vault/logical/framework" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/builtin/logical/pki/backend.go b/builtin/logical/pki/backend.go index cd16ac0d3..5f7abe32f 100644 --- a/builtin/logical/pki/backend.go +++ b/builtin/logical/pki/backend.go @@ -10,7 +10,7 @@ import ( ) // Factory creates a new backend implementing the logical.Backend interface -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/builtin/logical/postgresql/backend.go b/builtin/logical/postgresql/backend.go index d101c2e9e..9c138c7e6 100644 --- a/builtin/logical/postgresql/backend.go +++ b/builtin/logical/postgresql/backend.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/vault/logical/framework" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/builtin/logical/transit/backend.go b/builtin/logical/transit/backend.go index d719d42c6..8c8bc9d61 100644 --- a/builtin/logical/transit/backend.go +++ b/builtin/logical/transit/backend.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/vault/logical/framework" ) -func Factory(map[string]string) (logical.Backend, error) { +func Factory(*logical.BackendConfig) (logical.Backend, error) { return Backend(), nil } diff --git a/logical/testing/testing.go b/logical/testing/testing.go index fef447f4e..1f6bfda31 100644 --- a/logical/testing/testing.go +++ b/logical/testing/testing.go @@ -110,7 +110,7 @@ func Test(t TestT, c TestCase) { core, err := vault.NewCore(&vault.CoreConfig{ Physical: physical.NewInmem(), LogicalBackends: map[string]logical.Factory{ - "test": func(map[string]string) (logical.Backend, error) { + "test": func(*logical.BackendConfig) (logical.Backend, error) { return c.Backend, nil }, },