fix databroker requiring signed jwt (#1538)

* add test, explicitly call RequireSignedJWT instead of using interceptor to handle combined gRPC server

* register handler, handle config changes

* fix nil error in tests

* unexport constructor
This commit is contained in:
Caleb Doxsey 2020-10-20 10:29:22 -06:00 committed by GitHub
parent a375f707f8
commit 1763f02620
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 184 additions and 22 deletions

10
cache/cache.go vendored
View file

@ -28,7 +28,7 @@ import (
// Cache represents the cache service. The cache service is a simple interface
// for storing keyed blobs (bytes) of unstructured data.
type Cache struct {
dataBrokerServer *DataBrokerServer
dataBrokerServer *dataBrokerServer
manager *manager.Manager
localListener net.Listener
@ -52,10 +52,7 @@ func New(cfg *config.Config) (*Cache, error) {
// No metrics handler because we have one in the control plane. Add one
// if we no longer register with that grpc Server
localGRPCServer := grpc.NewServer(
grpc.StreamInterceptor(grpcutil.StreamRequireSignedJWT(cfg.Options.SharedKey)),
grpc.UnaryInterceptor(grpcutil.UnaryRequireSignedJWT(cfg.Options.SharedKey)),
)
localGRPCServer := grpc.NewServer()
clientStatsHandler := telemetry.NewGRPCClientStatsHandler(cfg.Options.Services)
clientDialOptions := []grpc.DialOption{
@ -74,7 +71,7 @@ func New(cfg *config.Config) (*Cache, error) {
return nil, err
}
dataBrokerServer := NewDataBrokerServer(localGRPCServer, cfg)
dataBrokerServer := newDataBrokerServer(cfg)
c := &Cache{
dataBrokerServer: dataBrokerServer,
@ -84,6 +81,7 @@ func New(cfg *config.Config) (*Cache, error) {
deprecatedCacheClusterDomain: cfg.Options.GetDataBrokerURL().Hostname(),
dataBrokerStorageType: cfg.Options.DataBrokerStorageType,
}
c.Register(c.localGRPCServer)
err = c.update(cfg)
if err != nil {