Migrate some credential bits around (#3864)
This commit is contained in:
1 parent
a601316efd
commit
eb20b80c71
26 files changed
+291
-259
No files matched your search
@@ -7,7 +7,7 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/hashicorp/boundary/api/targets"
|
||||
"github.com/hashicorp/boundary/internal/credential"
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
@@ -65,8 +65,8 @@ func parseCredentials(creds []*targets.SessionCredential) (credentials, error) {
|
||||
|
||||
var upCred usernamePassword
|
||||
var spkCred sshPrivateKey
|
||||
switch credential.Type(cred.CredentialSource.CredentialType) {
|
||||
case credential.UsernamePasswordType:
|
||||
switch globals.CredentialType(cred.CredentialSource.CredentialType) {
|
||||
case globals.UsernamePasswordCredentialType:
|
||||
// Decode attributes from credential struct
|
||||
if err := mapstructure.Decode(cred.Credential, &upCred); err != nil {
|
||||
return credentials{}, err
|
||||
@@ -78,7 +78,7 @@ func parseCredentials(creds []*targets.SessionCredential) (credentials, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
case credential.SshPrivateKeyType:
|
||||
case globals.SshPrivateKeyCredentialType:
|
||||
// Decode attributes from credential struct
|
||||
if err := mapstructure.Decode(cred.Credential, &spkCred); err != nil {
|
||||
return credentials{}, err
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/boundary/api/targets"
|
||||
"github.com/hashicorp/boundary/internal/credential"
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/credential/static"
|
||||
"github.com/hashicorp/boundary/internal/credential/vault"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
var (
|
||||
typedUsernamePassword = &targets.SessionCredential{
|
||||
CredentialSource: &targets.CredentialSource{
|
||||
CredentialType: string(credential.UsernamePasswordType),
|
||||
CredentialType: string(globals.UsernamePasswordCredentialType),
|
||||
},
|
||||
Credential: map[string]any{
|
||||
"username": "user",
|
||||
@@ -27,7 +27,7 @@ var (
|
||||
|
||||
typedSshPrivateKey = &targets.SessionCredential{
|
||||
CredentialSource: &targets.CredentialSource{
|
||||
CredentialType: string(credential.SshPrivateKeyType),
|
||||
CredentialType: string(globals.SshPrivateKeyCredentialType),
|
||||
},
|
||||
Credential: map[string]any{
|
||||
"username": "user",
|
||||
|
||||
Reference in new issue
Block a user