diff --git a/CHANGELOG.md b/CHANGELOG.md index 170ca6529..e9bb4c3b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ # Change Log +## 2025-03-18 - Runtime 0.17.4 + +- fix: dgraph connection should ignore key for localhost [#793](https://github.com/hypermodeinc/modus/pull/793) + ## 2025-03-13 - CLI 0.17.1 - chore: cleanup unused dependencies and update remaining [#790](https://github.com/hypermodeinc/modus/pull/790) diff --git a/runtime/dgraphclient/registry.go b/runtime/dgraphclient/registry.go index 37a8604b0..260151d08 100644 --- a/runtime/dgraphclient/registry.go +++ b/runtime/dgraphclient/registry.go @@ -106,23 +106,11 @@ func createConnector(ctx context.Context, dgName string) (*dgraphConnector, erro } var opts []grpc.DialOption - - if connection.Key != "" { - conKey, err := secrets.ApplySecretsToString(ctx, info, connection.Key) - if err != nil { - return nil, err - } - - pool, err := x509.SystemCertPool() - if err != nil { - return nil, err - } - creds := credentials.NewClientTLSFromCert(pool, "") + if strings.Split(connection.GrpcTarget, ":")[0] == "localhost" { opts = []grpc.DialOption{ - grpc.WithTransportCredentials(creds), - grpc.WithPerRPCCredentials(&authCreds{conKey}), + grpc.WithTransportCredentials(insecure.NewCredentials()), } - } else if strings.Split(connection.GrpcTarget, ":")[0] != "localhost" { + } else { pool, err := x509.SystemCertPool() if err != nil { return nil, err @@ -131,9 +119,12 @@ func createConnector(ctx context.Context, dgName string) (*dgraphConnector, erro opts = []grpc.DialOption{ grpc.WithTransportCredentials(creds), } - } else { - opts = []grpc.DialOption{ - grpc.WithTransportCredentials(insecure.NewCredentials()), + if connection.Key != "" { + if conKey, err := secrets.ApplySecretsToString(ctx, info, connection.Key); err != nil { + return nil, err + } else if conKey != "" { + opts = append(opts, grpc.WithPerRPCCredentials(&authCreds{conKey})) + } } }