Add multihop auth support (#32)
This commit is contained in:
1 parent
8579a248d4
commit
ab4d542fad
10 files changed
+91
-13
No files matched your search
@@ -38,7 +38,7 @@ import (
|
||||
"github.com/hashicorp/go-secure-stdlib/pluginutil/v2"
|
||||
"github.com/hashicorp/nodeenrollment/noderegistration"
|
||||
nodeefile "github.com/hashicorp/nodeenrollment/nodestorage/file"
|
||||
"github.com/hashicorp/nodeenrollment/nodetypes"
|
||||
"github.com/hashicorp/nodeenrollment/rotation"
|
||||
ua "go.uber.org/atomic"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@@ -322,7 +322,7 @@ func (c *Controller) Start() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = nodetypes.RotateRootCertificates(c.baseContext, c.NodeeFileStorage)
|
||||
_, err = rotation.RotateRootCertificates(c.baseContext, c.NodeeFileStorage)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -573,12 +573,24 @@ func handleNodes(c *Controller) http.Handler {
|
||||
}
|
||||
var err error
|
||||
var currVals vals
|
||||
currVals.WaitingNodes, err = c.NodeeFileStorage.List(c.baseContext, (*nodetypes.NodeInformation)(nil))
|
||||
waitingNodes, err := c.NodeeFileStorage.List(c.baseContext, (*nodetypes.NodeInformation)(nil))
|
||||
if err != nil {
|
||||
_, _ = w.Write([]byte(err.Error()))
|
||||
w.WriteHeader(500)
|
||||
return
|
||||
}
|
||||
for _, keyId := range waitingNodes {
|
||||
ni, err := nodetypes.LoadNodeInformation(c.baseContext, c.NodeeFileStorage, keyId)
|
||||
if err != nil {
|
||||
_, _ = w.Write([]byte(err.Error()))
|
||||
w.WriteHeader(500)
|
||||
return
|
||||
}
|
||||
if ni.Authorized {
|
||||
continue
|
||||
}
|
||||
currVals.WaitingNodes = append(currVals.WaitingNodes, keyId)
|
||||
}
|
||||
ret, err := json.Marshal(currVals)
|
||||
if err != nil {
|
||||
_, _ = w.Write([]byte(err.Error()))
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
pbs "github.com/hashicorp/nodeenrollment/multihop"
|
||||
"github.com/hashicorp/nodeenrollment/nodeauth"
|
||||
"github.com/hashicorp/nodeenrollment/noderegistration"
|
||||
"github.com/hashicorp/nodeenrollment/nodetls"
|
||||
"github.com/hashicorp/nodeenrollment/nodetypes"
|
||||
)
|
||||
|
||||
@@ -41,5 +42,5 @@ func (m *multihopServiceServer) GenerateServerCertificates(ctx context.Context,
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: error getting current parameters: %w", op, err)
|
||||
}
|
||||
return noderegistration.GenerateServerCertificates(ctx, storage, req, opt...)
|
||||
return nodetls.GenerateServerCertificates(ctx, storage, req, opt...)
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package workers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync/atomic"
|
||||
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
)
|
||||
|
||||
type workerProxyServiceServer struct {
|
||||
pbs.UnimplementedServerCoordinationServiceServer
|
||||
pbs.UnimplementedSessionServiceServer
|
||||
|
||||
scsClient *atomic.Value
|
||||
ssClient *atomic.Value
|
||||
}
|
||||
|
||||
func NewWorkerProxyServiceServer(
|
||||
scsClient *atomic.Value,
|
||||
ssClient *atomic.Value,
|
||||
) *workerProxyServiceServer {
|
||||
return &workerProxyServiceServer{
|
||||
scsClient: scsClient,
|
||||
ssClient: ssClient,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
_ pbs.ServerCoordinationServiceServer = &workerProxyServiceServer{}
|
||||
_ pbs.SessionServiceServer = &workerProxyServiceServer{}
|
||||
)
|
||||
|
||||
func (ws *workerProxyServiceServer) Status(ctx context.Context, req *pbs.StatusRequest) (*pbs.StatusResponse, error) {
|
||||
return ws.scsClient.Load().(pbs.ServerCoordinationServiceClient).Status(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) LookupSession(ctx context.Context, req *pbs.LookupSessionRequest) (*pbs.LookupSessionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).LookupSession(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) CancelSession(ctx context.Context, req *pbs.CancelSessionRequest) (*pbs.CancelSessionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).CancelSession(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) ActivateSession(ctx context.Context, req *pbs.ActivateSessionRequest) (*pbs.ActivateSessionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).ActivateSession(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) AuthorizeConnection(ctx context.Context, req *pbs.AuthorizeConnectionRequest) (*pbs.AuthorizeConnectionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).AuthorizeConnection(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) ConnectConnection(ctx context.Context, req *pbs.ConnectConnectionRequest) (*pbs.ConnectConnectionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).ConnectConnection(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) CloseConnection(ctx context.Context, req *pbs.CloseConnectionRequest) (*pbs.CloseConnectionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).CloseConnection(ctx, req)
|
||||
}
|
||||
Reference in new issue
Block a user