-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] go/coordinator: grpcserver supports mTLS (#1362)
## Description of changes *Summarize the changes made by this PR.* - New functionality - Adding mTLS support for coordinator grpcserver, because we need to make sure the connection & data transport between different component is secure when these components deployed in public cloud env. ## Test plan *How are these changes tested?* - [x] Tests pass locally with `pytest` for python, `yarn test` for js, `make test` for golang ## Documentation Changes *Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs repository](https://github.com/chroma-core/docs)?* --------- Signed-off-by: zhangjinpeng1987 <[email protected]> Co-authored-by: Ben Eggers <[email protected]>
- Loading branch information
1 parent
096e018
commit 85e52f1
Showing
5 changed files
with
93 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
go/coordinator/internal/grpccoordinator/grpcutils/config.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package grpcutils | ||
|
||
type GrpcConfig struct { | ||
// BindAddress is the address to bind the GRPC server to. | ||
BindAddress string | ||
|
||
// GRPC mTLS config | ||
CertPath string | ||
KeyPath string | ||
CAPath string | ||
} | ||
|
||
func (c *GrpcConfig) MTLSEnabled() bool { | ||
return c.CertPath != "" && c.KeyPath != "" && c.CAPath != "" | ||
} |
37 changes: 37 additions & 0 deletions
37
go/coordinator/internal/grpccoordinator/grpcutils/config_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package grpcutils | ||
|
||
import "testing" | ||
|
||
func TestGrpcConfig_TLSEnabled(t *testing.T) { | ||
// Create a list of configs and expected check result (true/false) | ||
cfgs := []*GrpcConfig{ | ||
{ | ||
CertPath: "cert", | ||
KeyPath: "key", | ||
CAPath: "ca", | ||
}, | ||
{ | ||
CertPath: "", | ||
KeyPath: "", | ||
CAPath: "", | ||
}, | ||
{ | ||
CertPath: "cert", | ||
KeyPath: "", | ||
CAPath: "ca", | ||
}, | ||
{ | ||
CertPath: "", | ||
KeyPath: "key", | ||
CAPath: "ca", | ||
}, | ||
} | ||
expected := []bool{true, false, false, false} | ||
|
||
// Iterate through the list of configs and check if the result matches the expected result | ||
for i, cfg := range cfgs { | ||
if cfg.MTLSEnabled() != expected[i] { | ||
t.Errorf("Expected %v, got %v", expected[i], cfg.MTLSEnabled()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters