feat: static json credentials (#2423)

This commit is contained in:
Damian Debkowski authored and GitHub committed 2022-09-16 15:00:04 -07:00
1 parent 8c53d931aa
commit 546c5dc5be
42 files changed
+3207 -165

No files matched your search

@@ -4,6 +4,7 @@ import (
"context"
"crypto/x509"
"encoding/base64"
"encoding/json"
"fmt"
"github.com/hashicorp/boundary/globals"
@@ -24,6 +25,7 @@ import (
"golang.org/x/crypto/ssh"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/wrapperspb"
)
@@ -32,12 +34,14 @@ const (
passwordField = "attributes.password"
privateKeyField = "attributes.private_key"
privateKeyPassphraseField = "attributes.private_key_passphrase"
objectField = "attributes.object"
domain = "credential"
)
var (
upMaskManager handlers.MaskManager
spkMaskManager handlers.MaskManager
upMaskManager handlers.MaskManager
spkMaskManager handlers.MaskManager
jsonMaskManager handlers.MaskManager
// IdActions contains the set of actions that can be performed on
// individual resources
@@ -66,6 +70,10 @@ func init() {
handlers.MaskSource{&pb.Credential{}, &pb.SshPrivateKeyAttributes{}}); err != nil {
panic(err)
}
if jsonMaskManager, err = handlers.NewMaskManager(handlers.MaskDestination{&store.JsonCredential{}},
handlers.MaskSource{&pb.Credential{}, &pb.JsonAttributes{}}); err != nil {
panic(err)
}
}
// Service handles request as described by the pbs.CredentialServiceServer interface.
@@ -360,6 +368,23 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Cred
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create credential but no error returned from repository.")
}
return out, nil
case credential.JsonSubtype.String():
cred, err := toJsonStorageCredential(ctx, item.GetCredentialStoreId(), item)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
repo, err := s.repoFn()
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
out, err := repo.CreateJsonCredential(ctx, scopeId, cred)
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("unable to create credential"))
}
if out == nil {
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create credential but no error returned from repository.")
}
return out, nil
default:
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, fmt.Sprintf("Unsupported credential type %q", item.GetType()))
}
@@ -435,6 +460,30 @@ func (s Service) updateInRepo(
}
return out, nil
case credential.JsonSubtype:
dbMasks = append(dbMasks, jsonMaskManager.Translate(masks, "attributes", "object")...)
if len(dbMasks) == 0 {
return nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."})
}
cred, err := toJsonStorageCredential(ctx, storeId, in)
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("unable to convert to json storage credential"))
}
cred.PublicId = id
repo, err := s.repoFn()
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
out, rowsUpdated, err := repo.UpdateJsonCredential(ctx, scopeId, cred, item.GetVersion(), dbMasks)
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("unable to update credential"))
}
if rowsUpdated == 0 {
return nil, handlers.NotFoundErrorf("Credential %q doesn't exist or incorrect version provided.", id)
}
return out, nil
default:
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, fmt.Sprintf("Unsupported credential type %q", item.GetType()))
@@ -527,6 +576,8 @@ func toProto(in credential.Static, opt ...handlers.Option) (*pb.Credential, erro
out.Type = credential.UsernamePasswordSubtype.String()
case *static.SshPrivateKeyCredential:
out.Type = credential.SshPrivateKeySubtype.String()
case *static.JsonCredential:
out.Type = credential.JsonSubtype.String()
}
}
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
@@ -571,6 +622,14 @@ func toProto(in credential.Static, opt ...handlers.Option) (*pb.Credential, erro
},
}
}
case *static.JsonCredential:
if outputFields.Has(globals.AttributesField) {
out.Attrs = &pb.Credential_JsonAttributes{
JsonAttributes: &pb.JsonAttributes{
ObjectHmac: base64.RawURLEncoding.EncodeToString(cred.GetObjectHmac()),
},
}
}
}
return &out, nil
}
@@ -625,6 +684,38 @@ func toSshPrivateKeyStorageCredential(ctx context.Context, storeId string, in *p
return cs, err
}
func toJsonStorageCredential(ctx context.Context, storeId string, in *pb.Credential) (out *static.JsonCredential, err error) {
const op = "credentials.toJsonStorageCredential"
var opts []static.Option
if in.GetName() != nil {
opts = append(opts, static.WithName(in.GetName().GetValue()))
}
if in.GetDescription() != nil {
opts = append(opts, static.WithDescription(in.GetDescription().GetValue()))
}
attrs := in.GetJsonAttributes()
object := attrs.GetObject()
if object == nil {
object, err = structpb.NewStruct(map[string]interface{}{})
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("unable to build credential"))
}
}
cs, err := static.NewJsonCredential(
ctx,
storeId,
credential.JsonObject{
*object,
},
opts...)
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("unable to build credential"))
}
return cs, err
}
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
// requirements on the structure of the request. They verify that:
// - The path passed in is correctly formatted
@@ -637,6 +728,7 @@ func validateGetRequest(req *pbs.GetCredentialRequest) error {
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix,
)
}
@@ -685,6 +777,18 @@ func validateCreateRequest(req *pbs.CreateCredentialRequest) error {
}
}
case credential.JsonSubtype.String():
object := req.GetItem().GetJsonAttributes().GetObject()
if object == nil && len(object.AsMap()) <= 0 {
badFields[objectField] = "Field required for creating a json credential."
}
objectBytes, err := json.Marshal(object)
if err != nil {
badFields[objectField] = "Unable to parse given json value"
} else if len(objectBytes) <= 0 {
badFields[objectField] = "Field required for creating a json credential."
}
default:
badFields[globals.TypeField] = fmt.Sprintf("Unsupported credential type %q", req.Item.GetType())
}
@@ -738,6 +842,21 @@ func validateUpdateRequest(req *pbs.UpdateCredentialRequest) error {
}
}
case credential.JsonSubtype:
object := req.GetItem().GetJsonAttributes().GetObject()
if object != nil {
objectBytes, err := json.Marshal(object.AsMap())
if err != nil {
badFields[objectField] = "Unable to parse given json value"
}
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), objectField) && len(objectBytes) <= 0 {
badFields[objectField] = "This is a required field and cannot be set to empty."
}
}
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), objectField) && object == nil {
badFields[objectField] = "This is a required field and cannot be set to empty."
}
default:
badFields[globals.IdField] = "Unknown credential type."
}
@@ -747,6 +866,7 @@ func validateUpdateRequest(req *pbs.UpdateCredentialRequest) error {
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix,
)
}
@@ -757,6 +877,7 @@ func validateDeleteRequest(req *pbs.DeleteCredentialRequest) error {
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix,
)
}
@@ -3,6 +3,7 @@ package credentials
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"strings"
"testing"
@@ -30,6 +31,7 @@ import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/fieldmaskpb"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)
@@ -100,6 +102,28 @@ func TestList(t *testing.T) {
},
},
})
obj, objBytes, err := static.TestJsonObject()
assert.NoError(t, err)
credJson := static.TestJsonCredential(t, conn, wrapper, store.GetPublicId(), prj.GetPublicId(), obj)
hm, err = crypto.HmacSha256(context.Background(), objBytes, databaseWrapper, []byte(store.GetPublicId()), nil)
require.NoError(t, err)
wantCreds = append(wantCreds, &pb.Credential{
Id: credJson.GetPublicId(),
CredentialStoreId: store.GetPublicId(),
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
CreatedTime: credJson.GetCreateTime().GetTimestamp(),
UpdatedTime: credJson.GetUpdateTime().GetTimestamp(),
Version: credJson.GetVersion(),
Type: credential.JsonSubtype.String(),
AuthorizedActions: testAuthorizedActions,
Attrs: &pb.Credential_JsonAttributes{
JsonAttributes: &pb.JsonAttributes{
ObjectHmac: base64.RawURLEncoding.EncodeToString([]byte(hm)),
},
},
})
}
cases := []struct {
@@ -129,8 +153,8 @@ func TestList(t *testing.T) {
},
{
name: "Filter on Attribute",
req: &pbs.ListCredentialsRequest{CredentialStoreId: store.GetPublicId(), Filter: fmt.Sprintf(`"/item/attributes/username"==%q`, wantCreds[2].GetUsernamePasswordAttributes().GetUsername().Value)},
res: &pbs.ListCredentialsResponse{Items: wantCreds[2:4]},
req: &pbs.ListCredentialsRequest{CredentialStoreId: store.GetPublicId(), Filter: fmt.Sprintf(`"/item/attributes/username"==%q`, wantCreds[3].GetUsernamePasswordAttributes().GetUsername().Value)},
res: &pbs.ListCredentialsResponse{Items: wantCreds[3:5]},
anonRes: &pbs.ListCredentialsResponse{}, // anonymous user does not have access to attributes
},
{
@@ -213,6 +237,12 @@ func TestGet(t *testing.T) {
spkWithPassHm, err := crypto.HmacSha256(context.Background(), []byte(testdata.PEMEncryptedKeys[0].PEMBytes), databaseWrapper, []byte(store.GetPublicId()), nil)
require.NoError(t, err)
passHm, err := crypto.HmacSha256(context.Background(), []byte(testdata.PEMEncryptedKeys[0].EncryptionKey), databaseWrapper, []byte(store.GetPublicId()), nil)
obj, objBytes, err := static.TestJsonObject()
assert.NoError(t, err)
jsonCred := static.TestJsonCredential(t, conn, wrapper, store.GetPublicId(), prj.GetPublicId(), obj)
objectHmac, err := crypto.HmacSha256(context.Background(), objBytes, databaseWrapper, []byte(store.GetPublicId()), nil)
require.NoError(t, err)
cases := []struct {
@@ -310,6 +340,27 @@ func TestGet(t *testing.T) {
},
},
},
{
name: "success-json",
id: jsonCred.GetPublicId(),
res: &pbs.GetCredentialResponse{
Item: &pb.Credential{
Id: jsonCred.GetPublicId(),
CredentialStoreId: jsonCred.GetStoreId(),
Scope: &scopepb.ScopeInfo{Id: store.GetProjectId(), Type: scope.Project.String(), ParentScopeId: prj.GetParentId()},
Type: credential.JsonSubtype.String(),
AuthorizedActions: testAuthorizedActions,
CreatedTime: jsonCred.CreateTime.GetTimestamp(),
UpdatedTime: jsonCred.UpdateTime.GetTimestamp(),
Version: 1,
Attrs: &pb.Credential_JsonAttributes{
JsonAttributes: &pb.JsonAttributes{
ObjectHmac: base64.RawURLEncoding.EncodeToString([]byte(objectHmac)),
},
},
},
},
},
{
name: "not found error",
id: fmt.Sprintf("%s_1234567890", credential.UsernamePasswordCredentialPrefix),
@@ -370,6 +421,11 @@ func TestDelete(t *testing.T) {
upCred := static.TestUsernamePasswordCredential(t, conn, wrapper, "user", "pass", store.GetPublicId(), prj.GetPublicId())
spkCred := static.TestSshPrivateKeyCredential(t, conn, wrapper, "user", static.TestSshPrivateKeyPem, store.GetPublicId(), prj.GetPublicId())
obj, _, err := static.TestJsonObject()
assert.NoError(t, err)
jsonCred := static.TestJsonCredential(t, conn, wrapper, store.GetPublicId(), prj.GetPublicId(), obj)
cases := []struct {
name string
id string
@@ -384,6 +440,10 @@ func TestDelete(t *testing.T) {
name: "success-spk",
id: spkCred.GetPublicId(),
},
{
name: "success-json",
id: jsonCred.GetPublicId(),
},
{
name: "not found error",
id: fmt.Sprintf("%s_1234567890", credential.UsernamePasswordCredentialPrefix),
@@ -429,6 +489,9 @@ func TestCreate(t *testing.T) {
_, prj := iam.TestScopes(t, iamRepo)
store := static.TestCredentialStore(t, conn, wrapper, prj.GetPublicId())
obj, objBytes, err := static.TestJsonObject()
assert.NoError(t, err)
cases := []struct {
name string
req *pbs.CreateCredentialRequest
@@ -555,6 +618,18 @@ func TestCreate(t *testing.T) {
res: nil,
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
},
{
name: "Must provide json secret",
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
CredentialStoreId: store.GetPublicId(),
Type: credential.JsonSubtype.String(),
Attrs: &pb.Credential_JsonAttributes{
JsonAttributes: &pb.JsonAttributes{},
},
}},
res: nil,
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
},
{
name: "valid-up",
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
@@ -637,6 +712,32 @@ func TestCreate(t *testing.T) {
},
},
},
{
name: "valid-json",
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
CredentialStoreId: store.GetPublicId(),
Type: credential.JsonSubtype.String(),
Attrs: &pb.Credential_JsonAttributes{
JsonAttributes: &pb.JsonAttributes{
Object: &obj.Struct,
},
},
}},
idPrefix: credential.JsonCredentialPrefix + "_",
res: &pbs.CreateCredentialResponse{
Uri: fmt.Sprintf("credentials/%s_", credential.JsonCredentialPrefix),
Item: &pb.Credential{
Id: store.GetPublicId(),
CredentialStoreId: store.GetPublicId(),
CreatedTime: store.GetCreateTime().GetTimestamp(),
UpdatedTime: store.GetUpdateTime().GetTimestamp(),
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
Version: 1,
Type: credential.JsonSubtype.String(),
AuthorizedActions: testAuthorizedActions,
},
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
@@ -702,6 +803,14 @@ func TestCreate(t *testing.T) {
assert.Empty(got.GetItem().GetSshPrivateKeyAttributes().GetPrivateKeyPassphrase())
}
case credential.JsonSubtype.String():
hm, err := crypto.HmacSha256(context.Background(), objBytes, databaseWrapper, []byte(store.GetPublicId()), nil)
require.NoError(err)
// Validate attributes equal
assert.Equal(base64.RawURLEncoding.EncodeToString([]byte(hm)), got.GetItem().GetJsonAttributes().GetObjectHmac())
assert.Empty(got.GetItem().GetJsonAttributes().GetObject())
default:
require.Fail("unknown type")
}
@@ -775,6 +884,28 @@ func TestUpdate(t *testing.T) {
return cred, clean
}
freshCredJson := func() (*static.JsonCredential, func()) {
t.Helper()
obj, _, err := static.TestJsonObject()
assert.NoError(t, err)
cred := static.TestJsonCredential(t, conn, wrapper, store.GetPublicId(), prj.GetPublicId(), obj)
clean := func() {
_, err := s.DeleteCredential(ctx, &pbs.DeleteCredentialRequest{Id: cred.GetPublicId()})
require.NoError(t, err)
}
return cred, clean
}
secondSecret := &structpb.Struct{
Fields: map[string]*structpb.Value{
"username": structpb.NewStringValue("new-user"),
"password": structpb.NewStringValue("new-password"),
"hash": structpb.NewStringValue("0123456789"),
},
}
secondSecretBytes, err := json.Marshal(secondSecret)
require.NoError(t, err)
databaseWrapper, err := kkms.GetWrapper(context.Background(), prj.GetPublicId(), kms.KeyPurposeDatabase)
require.NoError(t, err)
@@ -994,6 +1125,27 @@ func TestUpdate(t *testing.T) {
return out
},
},
{
name: "update-json",
req: &pbs.UpdateCredentialRequest{
UpdateMask: fieldmask("attributes.object.username", "attributes.object.password", "attributes.object.hash"),
Item: &pb.Credential{
Attrs: &pb.Credential_JsonAttributes{
JsonAttributes: &pb.JsonAttributes{
Object: secondSecret,
},
},
},
},
res: func(in *pb.Credential) *pb.Credential {
out := proto.Clone(in).(*pb.Credential)
hm, err := crypto.HmacSha256(context.Background(), secondSecretBytes, databaseWrapper, []byte(store.GetPublicId()), nil)
require.NoError(t, err)
out.GetJsonAttributes().ObjectHmac = base64.RawURLEncoding.EncodeToString([]byte(hm))
return out
},
},
{
name: "update-spk-with-bad-passphrase",
req: &pbs.UpdateCredentialRequest{
@@ -1043,6 +1195,7 @@ func TestUpdate(t *testing.T) {
require.NoError(t, err)
out.GetSshPrivateKeyAttributes().PrivateKeyHmac = base64.RawURLEncoding.EncodeToString([]byte(hm))
out.GetSshPrivateKeyAttributes().PrivateKeyPassphraseHmac = ""
return out
},
},
@@ -1053,10 +1206,12 @@ func TestUpdate(t *testing.T) {
assert, require := assert.New(t), require.New(t)
var cred credential.Static
var cleanup func()
switch {
case strings.Contains(tc.name, "spk"):
if strings.Contains(tc.name, "spk") {
cred, cleanup = freshCredSpk("user")
default:
} else if strings.Contains(tc.name, "json") {
cred, cleanup = freshCredJson()
} else {
cred, cleanup = freshCredUp("user", "pass")
}
defer cleanup()
@@ -1095,8 +1250,12 @@ func TestUpdate(t *testing.T) {
}
// cant update read only fields
cred, cleanupKv := freshCredUp("user", "pass")
defer cleanupKv()
credJson, cleanupJson := freshCredJson()
defer cleanupJson()
// cant update read only fields
credUp, cleanUp := freshCredUp("user", "pass")
defer cleanUp()
newStore := static.TestCredentialStore(t, conn, wrapper, prj.GetPublicId())
@@ -1129,11 +1288,11 @@ func TestUpdate(t *testing.T) {
for _, tc := range roCases {
t.Run(fmt.Sprintf("ReadOnlyField/%s", tc.path), func(t *testing.T) {
req := &pbs.UpdateCredentialRequest{
Id: cred.GetPublicId(),
Id: credUp.GetPublicId(),
Item: tc.item,
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{tc.path}},
}
req.Item.Version = cred.Version
req.Item.Version = credUp.Version
got, gErr := s.UpdateCredential(ctx, req)
assert.Error(t, gErr)
@@ -1145,6 +1304,24 @@ func TestUpdate(t *testing.T) {
}
matcher(t, gErr)
assert.Nil(t, got)
req = &pbs.UpdateCredentialRequest{
Id: credJson.GetPublicId(),
Item: tc.item,
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{tc.path}},
}
req.Item.Version = credJson.Version
got, gErr = s.UpdateCredential(ctx, req)
assert.Error(t, gErr)
matcher = tc.matcher
if matcher == nil {
matcher = func(t *testing.T, e error) {
assert.Truef(t, errors.Is(gErr, handlers.ApiErrorWithCode(codes.InvalidArgument)), "got error %v, wanted invalid argument", gErr)
}
}
matcher(t, gErr)
assert.Nil(t, got)
})
}
}
@@ -168,7 +168,7 @@ func staticToWorkerCredential(ctx context.Context, cred credential.Static) (sess
data, err := proto.Marshal(workerCred)
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("marshalling dynamic secret to proto"))
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("marshalling static secret to proto"))
}
return data, nil
}
@@ -218,6 +218,21 @@ func staticToSessionCredential(ctx context.Context, cred credential.Static) (*pb
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("creating proto struct for ssh private key credential"))
}
case *credstatic.JsonCredential:
var err error
credType = string(credential.JsonType)
object := map[string]interface{}{}
err = json.Unmarshal(c.GetObject(), &object)
if err != nil {
return nil, errors.New(ctx, errors.InvalidParameter, op, "unmarshalling json")
}
credData, err = structpb.NewStruct(object)
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("creating proto struct for json credential"))
}
secret = object
default:
return nil, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("unsupported credential %T", c))
}
@@ -1624,7 +1624,8 @@ func validateAddCredentialSourcesRequest(req *pbs.AddTargetCredentialSourcesRequ
vault.CredentialLibraryPrefix,
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix) {
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix) {
badFields[globals.ApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
break
}
@@ -1634,7 +1635,8 @@ func validateAddCredentialSourcesRequest(req *pbs.AddTargetCredentialSourcesRequ
vault.CredentialLibraryPrefix,
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix) {
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix) {
badFields[globals.BrokeredCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
break
}
@@ -1669,7 +1671,8 @@ func validateSetCredentialSourcesRequest(req *pbs.SetTargetCredentialSourcesRequ
vault.CredentialLibraryPrefix,
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix) {
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix) {
badFields[globals.ApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
break
}
@@ -1679,7 +1682,8 @@ func validateSetCredentialSourcesRequest(req *pbs.SetTargetCredentialSourcesRequ
vault.CredentialLibraryPrefix,
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix) {
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix) {
badFields[globals.BrokeredCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
break
}
@@ -1718,7 +1722,8 @@ func validateRemoveCredentialSourcesRequest(req *pbs.RemoveTargetCredentialSourc
vault.CredentialLibraryPrefix,
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix) {
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix) {
badFields[globals.ApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
break
}
@@ -1728,7 +1733,8 @@ func validateRemoveCredentialSourcesRequest(req *pbs.RemoveTargetCredentialSourc
vault.CredentialLibraryPrefix,
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix) {
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix) {
badFields[globals.BrokeredCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
break
}
@@ -1738,7 +1744,8 @@ func validateRemoveCredentialSourcesRequest(req *pbs.RemoveTargetCredentialSourc
vault.CredentialLibraryPrefix,
credential.UsernamePasswordCredentialPrefix,
credential.PreviousUsernamePasswordCredentialPrefix,
credential.SshPrivateKeyCredentialPrefix) {
credential.SshPrivateKeyCredentialPrefix,
credential.JsonCredentialPrefix) {
badFields[globals.InjectedApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
break
}