mirror of
https://github.com/edgelesssys/constellation.git
synced 2026-01-03 08:45:30 -05:00
add KMS to multi-coordinator (#68)
This commit is contained in:
parent
2d9b64df14
commit
938beec2ef
7 changed files with 66 additions and 84 deletions
|
|
@ -3,6 +3,7 @@ package pubapi
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/edgelesssys/constellation/coordinator/kms"
|
||||
"github.com/edgelesssys/constellation/coordinator/peer"
|
||||
"github.com/edgelesssys/constellation/coordinator/role"
|
||||
"github.com/edgelesssys/constellation/coordinator/state"
|
||||
|
|
@ -20,6 +21,7 @@ type Core interface {
|
|||
GetIDs(masterSecret []byte) (ownerID []byte, clusterID []byte, err error)
|
||||
PersistNodeState(role role.Role, ownerID []byte, clusterID []byte) error
|
||||
SetUpKMS(ctx context.Context, storageURI, kmsURI, kekID string, useExisting bool) error
|
||||
GetKMSInfo() (kms.KMSInformation, error)
|
||||
GetDataKey(ctx context.Context, keyID string, length int) ([]byte, error)
|
||||
|
||||
GetState() state.State
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"net/netip"
|
||||
|
||||
"github.com/edgelesssys/constellation/coordinator/kms"
|
||||
"github.com/edgelesssys/constellation/coordinator/peer"
|
||||
"github.com/edgelesssys/constellation/coordinator/role"
|
||||
"github.com/edgelesssys/constellation/coordinator/state"
|
||||
|
|
@ -137,6 +138,10 @@ func (c *fakeCore) SetUpKMS(ctx context.Context, storageURI, kmsURI, kekID strin
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *fakeCore) GetKMSInfo() (kms.KMSInformation, error) {
|
||||
return kms.KMSInformation{}, nil
|
||||
}
|
||||
|
||||
func (c *fakeCore) GetDataKey(ctx context.Context, keyID string, length int) ([]byte, error) {
|
||||
return c.dataKey, c.getDataKeyErr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,6 @@ func (a *API) ActivateAsAdditionalCoordinator(ctx context.Context, in *pubproto.
|
|||
if err := a.core.AdvanceState(state.ActivatingNodes, in.OwnerId, in.ClusterId); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "advance state to ActivatingNodes: %v", err)
|
||||
}
|
||||
|
||||
// TODO: add KMS functions
|
||||
|
||||
// add one coordinator to the VPN
|
||||
if err := a.core.SetVPNIP(in.AssignedVpnIp); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "set vpn IP address: %v", err)
|
||||
|
|
@ -69,8 +66,13 @@ func (a *API) ActivateAsAdditionalCoordinator(ctx context.Context, in *pubproto.
|
|||
}
|
||||
a.logger.Info("Transition to persistent store successful")
|
||||
|
||||
// regularly get (peer) updates from etcd
|
||||
// start update before manual peer add to omit race conditions when multiple coordinator are activating nodes
|
||||
kmsData, err := a.core.GetKMSInfo()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "%v", err)
|
||||
}
|
||||
if err := a.core.SetUpKMS(ctx, kmsData.StorageUri, kmsData.KmsUri, kmsData.KeyEncryptionKeyID, false); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "%v", err)
|
||||
}
|
||||
|
||||
thisPeer, err := a.assemblePeerStruct(in.AssignedVpnIp, role.Coordinator)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue