mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 16:59:22 +02:00
registry: implement redis backend (#2179)
This commit is contained in:
parent
28155314e9
commit
a54d43b937
21 changed files with 772 additions and 64 deletions
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/pomerium/pomerium/internal/version"
|
||||
"github.com/pomerium/pomerium/pkg/cryptutil"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/registry"
|
||||
"github.com/pomerium/pomerium/pkg/grpcutil"
|
||||
)
|
||||
|
||||
|
@ -116,6 +117,7 @@ func (c *DataBroker) OnConfigChange(ctx context.Context, cfg *config.Config) {
|
|||
func (c *DataBroker) Register(grpcServer *grpc.Server) {
|
||||
databroker.RegisterDataBrokerServiceServer(grpcServer, c.dataBrokerServer)
|
||||
directory.RegisterDirectoryServiceServer(grpcServer, c)
|
||||
registry.RegisterRegistryServer(grpcServer, c.dataBrokerServer)
|
||||
}
|
||||
|
||||
// Run runs the databroker components.
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/pomerium/pomerium/config"
|
||||
"github.com/pomerium/pomerium/internal/databroker"
|
||||
databrokerpb "github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||
registrypb "github.com/pomerium/pomerium/pkg/grpc/registry"
|
||||
"github.com/pomerium/pomerium/pkg/grpcutil"
|
||||
)
|
||||
|
||||
|
@ -51,6 +52,8 @@ func (srv *dataBrokerServer) setKey(cfg *config.Config) {
|
|||
srv.sharedKey.Store(bs)
|
||||
}
|
||||
|
||||
// Databroker functions
|
||||
|
||||
func (srv *dataBrokerServer) Get(ctx context.Context, req *databrokerpb.GetRequest) (*databrokerpb.GetResponse, error) {
|
||||
if err := grpcutil.RequireSignedJWT(ctx, srv.sharedKey.Load().([]byte)); err != nil {
|
||||
return nil, err
|
||||
|
@ -92,3 +95,26 @@ func (srv *dataBrokerServer) SyncLatest(req *databrokerpb.SyncLatestRequest, str
|
|||
}
|
||||
return srv.server.SyncLatest(req, stream)
|
||||
}
|
||||
|
||||
// Registry functions
|
||||
|
||||
func (srv *dataBrokerServer) Report(ctx context.Context, req *registrypb.RegisterRequest) (*registrypb.RegisterResponse, error) {
|
||||
if err := grpcutil.RequireSignedJWT(ctx, srv.sharedKey.Load().([]byte)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return srv.server.Report(ctx, req)
|
||||
}
|
||||
|
||||
func (srv *dataBrokerServer) List(ctx context.Context, req *registrypb.ListRequest) (*registrypb.ServiceList, error) {
|
||||
if err := grpcutil.RequireSignedJWT(ctx, srv.sharedKey.Load().([]byte)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return srv.server.List(ctx, req)
|
||||
}
|
||||
|
||||
func (srv *dataBrokerServer) Watch(req *registrypb.ListRequest, stream registrypb.Registry_WatchServer) error {
|
||||
if err := grpcutil.RequireSignedJWT(stream.Context(), srv.sharedKey.Load().([]byte)); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.server.Watch(req, stream)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue