mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 12:26:34 +02:00
secrets/db: fix structpb conversion for external plugins using alternative cred types (#15801)
This commit is contained in:
parent
47a43ab8ac
commit
4ac2b575fa
@ -79,7 +79,7 @@ const SupportedCredentialTypesKey = "supported_credential_types"
|
||||
// supported by the database plugin. It can be used by database plugins
|
||||
// to communicate what CredentialType values it supports managing.
|
||||
func (ir InitializeResponse) SetSupportedCredentialTypes(credTypes []CredentialType) {
|
||||
sct := make([]string, 0, len(credTypes))
|
||||
sct := make([]interface{}, 0, len(credTypes))
|
||||
for _, t := range credTypes {
|
||||
sct = append(sct, t.String())
|
||||
}
|
||||
|
||||
@ -81,8 +81,17 @@ func (c gRPCClient) NewUser(ctx context.Context, req NewUserRequest) (NewUserRes
|
||||
}
|
||||
|
||||
func newUserReqToProto(req NewUserRequest) (*proto.NewUserRequest, error) {
|
||||
if req.Password == "" {
|
||||
return nil, fmt.Errorf("missing password")
|
||||
switch req.CredentialType {
|
||||
case CredentialTypePassword:
|
||||
if req.Password == "" {
|
||||
return nil, fmt.Errorf("missing password credential")
|
||||
}
|
||||
case CredentialTypeRSAPrivateKey:
|
||||
if len(req.PublicKey) == 0 {
|
||||
return nil, fmt.Errorf("missing public key credential")
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown credential type")
|
||||
}
|
||||
|
||||
expiration, err := ptypes.TimestampProto(req.Expiration)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user