From c0f0882d935a128991f9f5106245613718178c48 Mon Sep 17 00:00:00 2001 From: josh <josh@elixxir.io> Date: Thu, 25 Feb 2021 11:01:12 -0800 Subject: [PATCH] Turn on auth for gateway to gateway connections --- network/instance.go | 11 ++++++++++- network/instance_test.go | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/network/instance.go b/network/instance.go index 2891bed0..b2ea243b 100644 --- a/network/instance.go +++ b/network/instance.go @@ -587,6 +587,10 @@ func (i *Instance) GetPermissioningId() *id.ID { } +func (i *Instance) connectGatewayToGateway() { + +} + // Update host helper func (i *Instance) updateConns(def *ndf.NetworkDefinition, isGateway, isNode bool) error { if isGateway { @@ -608,8 +612,13 @@ func (i *Instance) updateConns(def *ndf.NetworkDefinition, isGateway, isNode boo return errors.Errorf("Gateway ID invalid, collides with a "+ "hard coded ID. Invalid ID: %v", gwid.Marshal()) } + + // If this entity is a gateway, other gateway hosts + // should have auth enabled. Otherwise, disable auth gwParams := connect.GetDefaultHostParams() - gwParams.AuthEnabled = false + if i.comm.Id.GetType() != id.Gateway { + gwParams.AuthEnabled = false + } _, err := i.comm.AddHost(gwid, addr, []byte(gateway.TlsCertificate), gwParams) if err != nil { return errors.WithMessagef(err, "Could not add gateway host %s", gwid) diff --git a/network/instance_test.go b/network/instance_test.go index a5c9d5fa..f2095690 100644 --- a/network/instance_test.go +++ b/network/instance_test.go @@ -202,6 +202,7 @@ func setupComm(t *testing.T) (*Instance, *mixmessages.NDF) { err = signature.Sign(f, privKey) testManager := connect.NewManagerTesting(t) pc := &connect.ProtoComms{ + Id:id.NewIdFromString("User", id.User, t), Manager: testManager, } i, err := NewInstance(pc, baseNDF, baseNDF, nil) @@ -363,6 +364,7 @@ func TestInstance_UpdateGatewayConnections(t *testing.T) { secured, _ := NewSecuredNdf(testutils.NDF) testManager := connect.NewManagerTesting(t) pc := &connect.ProtoComms{ + Id:id.NewIdFromString("User", id.User, t), Manager: testManager, } i := Instance{ -- GitLab