Skip to content

Commit

Permalink
backport of commit 4ac2b57 (#15804)
Browse files Browse the repository at this point in the history
Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
  • Loading branch information
1 parent 2f5c29c commit ad364b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sdk/database/dbplugin/v5/database.go
Expand Up @@ -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())
}
Expand Down
13 changes: 11 additions & 2 deletions sdk/database/dbplugin/v5/grpc_client.go
Expand Up @@ -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)
Expand Down

0 comments on commit ad364b6

Please sign in to comment.