credential/*: adhere to new API

This commit is contained in:
Mitchell Hashimoto 2015-04-17 09:40:28 -07:00
parent cd3fa3be92
commit 37af1683c6
3 changed files with 14 additions and 3 deletions

View File

@ -12,7 +12,7 @@ func Factory(map[string]string) (logical.Backend, error) {
func Backend() *framework.Backend {
var b backend
b.MapAppId = &framework.PolicyMap{
PathMap: &framework.PathMap{"app-id"},
PathMap: framework.PathMap{Name: "app-id"},
DefaultKey: "default",
}
b.MapUserId = &framework.PathMap{

View File

@ -1,6 +1,7 @@
package appId
import (
"fmt"
"strings"
"github.com/hashicorp/vault/logical"
@ -34,11 +35,21 @@ func (b *backend) pathLogin(
userId := data.Get("user_id").(string)
// Look up the apps that this user is allowed to access
apps, err := b.MapUserId.Get(req.Storage, userId)
appsMap, err := b.MapUserId.Get(req.Storage, userId)
if err != nil {
return nil, err
}
appsRaw, ok := appsMap["value"]
if !ok {
appsRaw = ""
}
apps, ok := appsRaw.(string)
if !ok {
return nil, fmt.Errorf("internal error: mapping is not a string")
}
// Verify that the app is in the list
found := false
for _, app := range strings.Split(apps, ",") {

View File

@ -16,7 +16,7 @@ func Factory(map[string]string) (logical.Backend, error) {
func Backend() *framework.Backend {
var b backend
b.Map = &framework.PolicyMap{
PathMap: &framework.PathMap{"teams"},
PathMap: framework.PathMap{Name: "teams"},
DefaultKey: "default",
}
b.Backend = &framework.Backend{