Skip to content
Snippets Groups Projects
Commit 41c922af authored by Josh Brooks's avatar Josh Brooks
Browse files

Refactor permissioning to client registration

parent f647a221
No related branches found
No related tags found
1 merge request!23Release
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
"gitlab.com/elixxir/client/interfaces/user" "gitlab.com/elixxir/client/interfaces/user"
"gitlab.com/elixxir/client/keyExchange" "gitlab.com/elixxir/client/keyExchange"
"gitlab.com/elixxir/client/network" "gitlab.com/elixxir/client/network"
"gitlab.com/elixxir/client/permissioning" "gitlab.com/elixxir/client/registration"
"gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/switchboard" "gitlab.com/elixxir/client/switchboard"
...@@ -55,7 +55,7 @@ type Client struct { ...@@ -55,7 +55,7 @@ type Client struct {
// loop // loop
network interfaces.NetworkManager network interfaces.NetworkManager
//object used to register and communicate with permissioning //object used to register and communicate with permissioning
permissioning *permissioning.Permissioning permissioning *registration.Registration
//object containing auth interactions //object containing auth interactions
auth *auth.Manager auth *auth.Manager
...@@ -220,10 +220,10 @@ func Login(storageDir string, password []byte, parameters params.Network) (*Clie ...@@ -220,10 +220,10 @@ func Login(storageDir string, password []byte, parameters params.Network) (*Clie
return nil, err return nil, err
} }
//get the NDF to pass into permissioning and the network manager //get the NDF to pass into registration and the network manager
def := c.storage.GetNDF() def := c.storage.GetNDF()
//initialize permissioning //initialize registration
if def.Registration.Address != "" { if def.Registration.Address != "" {
err = c.initPermissioning(def) err = c.initPermissioning(def)
if err != nil { if err != nil {
...@@ -292,7 +292,7 @@ func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte, ...@@ -292,7 +292,7 @@ func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte,
//store the updated base NDF //store the updated base NDF
c.storage.SetNDF(def) c.storage.SetNDF(def)
//initialize permissioning //initialize registration
if def.Registration.Address != "" { if def.Registration.Address != "" {
err = c.initPermissioning(def) err = c.initPermissioning(def)
if err != nil { if err != nil {
...@@ -337,14 +337,14 @@ func (c *Client) initComms() error { ...@@ -337,14 +337,14 @@ func (c *Client) initComms() error {
func (c *Client) initPermissioning(def *ndf.NetworkDefinition) error { func (c *Client) initPermissioning(def *ndf.NetworkDefinition) error {
var err error var err error
//initialize permissioning //initialize registration
c.permissioning, err = permissioning.Init(c.comms, def) c.permissioning, err = registration.Init(c.comms, def)
if err != nil { if err != nil {
return errors.WithMessage(err, "failed to init "+ return errors.WithMessage(err, "failed to init "+
"permissioning handler") "permissioning handler")
} }
//register with permissioning if necessary //register with registration if necessary
if c.storage.GetRegistrationStatus() == storage.KeyGenComplete { if c.storage.GetRegistrationStatus() == storage.KeyGenComplete {
jww.INFO.Printf("Client has not registered yet, attempting registration") jww.INFO.Printf("Client has not registered yet, attempting registration")
err = c.registerWithPermissioning() err = c.registerWithPermissioning()
...@@ -646,7 +646,7 @@ func checkVersionAndSetupStorage(def *ndf.NetworkDefinition, storageDir string, ...@@ -646,7 +646,7 @@ func checkVersionAndSetupStorage(def *ndf.NetworkDefinition, storageDir string,
//move the registration state to keys generated //move the registration state to keys generated
err = storageSess.ForwardRegistrationStatus(storage.KeyGenComplete) err = storageSess.ForwardRegistrationStatus(storage.KeyGenComplete)
} else { } else {
//move the registration state to indicate registered with permissioning //move the registration state to indicate registered with registration
err = storageSess.ForwardRegistrationStatus(storage.PermissioningComplete) err = storageSess.ForwardRegistrationStatus(storage.PermissioningComplete)
} }
......
...@@ -26,7 +26,7 @@ func (c *Client) registerWithPermissioning() error { ...@@ -26,7 +26,7 @@ func (c *Client) registerWithPermissioning() error {
"permissioning") "permissioning")
} }
//register with permissioning //register with registration
transmissionRegValidationSignature, receptionRegValidationSignature, transmissionRegValidationSignature, receptionRegValidationSignature,
registrationTimestamp, err := c.permissioning.Register(transmissionPubKey, receptionPubKey, regCode) registrationTimestamp, err := c.permissioning.Register(transmissionPubKey, receptionPubKey, regCode)
if err != nil { if err != nil {
......
...@@ -110,7 +110,7 @@ func init() { ...@@ -110,7 +110,7 @@ func init() {
viper.BindPFlag("gwhost", viper.BindPFlag("gwhost",
getNDFCmd.Flags().Lookup("gwhost")) getNDFCmd.Flags().Lookup("gwhost"))
getNDFCmd.Flags().StringP("permhost", "", "", getNDFCmd.Flags().StringP("permhost", "", "",
"Poll this permissioning host:port for the NDF") "Poll this registration host:port for the NDF")
viper.BindPFlag("permhost", viper.BindPFlag("permhost",
getNDFCmd.Flags().Lookup("permhost")) getNDFCmd.Flags().Lookup("permhost"))
......
...@@ -23,7 +23,7 @@ require ( ...@@ -23,7 +23,7 @@ require (
gitlab.com/elixxir/primitives v0.0.3-0.20210623165125-c395ff3484cc gitlab.com/elixxir/primitives v0.0.3-0.20210623165125-c395ff3484cc
gitlab.com/xx_network/comms v0.0.4-0.20210623165053-57910d8f01ee gitlab.com/xx_network/comms v0.0.4-0.20210623165053-57910d8f01ee
gitlab.com/xx_network/crypto v0.0.5-0.20210623164949-495cf892172d gitlab.com/xx_network/crypto v0.0.5-0.20210623164949-495cf892172d
gitlab.com/xx_network/primitives v0.0.4-0.20210617180018-6472489fd418 gitlab.com/xx_network/primitives v0.0.4-0.20210713195422-75afe18c5339
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 golang.org/x/net v0.0.0-20210525063256-abc453219eb5
google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect
......
...@@ -277,6 +277,10 @@ gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da/go.mod h1:OK ...@@ -277,6 +277,10 @@ gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da/go.mod h1:OK
gitlab.com/xx_network/primitives v0.0.2/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc= gitlab.com/xx_network/primitives v0.0.2/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc=
gitlab.com/xx_network/primitives v0.0.4-0.20210617180018-6472489fd418 h1:F52R0wvFobjkmB8YaPNHZIu0VYqwjesMBCb9T14ygW8= gitlab.com/xx_network/primitives v0.0.4-0.20210617180018-6472489fd418 h1:F52R0wvFobjkmB8YaPNHZIu0VYqwjesMBCb9T14ygW8=
gitlab.com/xx_network/primitives v0.0.4-0.20210617180018-6472489fd418/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= gitlab.com/xx_network/primitives v0.0.4-0.20210617180018-6472489fd418/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/primitives v0.0.4-0.20210713171905-8ecf768fc2c6 h1:HiW49jzA1MnLG3IIStc0ljQUAcy5jamLzDPqZrbpg8w=
gitlab.com/xx_network/primitives v0.0.4-0.20210713171905-8ecf768fc2c6/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/primitives v0.0.4-0.20210713195422-75afe18c5339 h1:uSwcCFCSQU0P2gO0y+YpD3BUh5zBq+FKrPrI67jBCDg=
gitlab.com/xx_network/primitives v0.0.4-0.20210713195422-75afe18c5339/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5 h1:FY+4Rh1Q2rgLyv10aKJjhWApuKRCR/054XhreudfAvw= gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5 h1:FY+4Rh1Q2rgLyv10aKJjhWApuKRCR/054XhreudfAvw=
gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM= gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
......
...@@ -60,7 +60,7 @@ func registerNodes(sender *gateway.Sender, session *storage.Session, ...@@ -60,7 +60,7 @@ func registerNodes(sender *gateway.Sender, session *storage.Session,
stop *stoppable.Single, c chan network.NodeGateway) { stop *stoppable.Single, c chan network.NodeGateway) {
u := session.User() u := session.User()
regSignature := u.GetTransmissionRegistrationValidationSignature() regSignature := u.GetTransmissionRegistrationValidationSignature()
// Timestamp in which user has registered with permissioning // Timestamp in which user has registered with registration
regTimestamp := u.GetRegistrationTimestamp().UnixNano() regTimestamp := u.GetRegistrationTimestamp().UnixNano()
uci := u.GetCryptographicIdentity() uci := u.GetCryptographicIdentity()
cmix := session.Cmix() cmix := session.Cmix()
...@@ -190,7 +190,7 @@ func requestNonce(sender *gateway.Sender, comms RegisterNodeCommsInterface, gwId ...@@ -190,7 +190,7 @@ func requestNonce(sender *gateway.Sender, comms RegisterNodeCommsInterface, gwId
Signature: clientSig, Signature: clientSig,
}, },
Target: gwId.Marshal(), Target: gwId.Marshal(),
// Timestamp in which user has registered with permissioning // Timestamp in which user has registered with registration
TimeStamp: registrationTimestampNano, TimeStamp: registrationTimestampNano,
}) })
if err != nil { if err != nil {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// LICENSE file // // LICENSE file //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
package permissioning package registration
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
...@@ -17,29 +17,29 @@ import ( ...@@ -17,29 +17,29 @@ import (
"time" "time"
) )
type Permissioning struct { type Registration struct {
host *connect.Host host *connect.Host
comms *client.Comms comms *client.Comms
} }
func Init(comms *client.Comms, def *ndf.NetworkDefinition) (*Permissioning, error) { func Init(comms *client.Comms, def *ndf.NetworkDefinition) (*Registration, error) {
perm := Permissioning{ perm := Registration{
host: nil, host: nil,
comms: comms, comms: comms,
} }
var err error var err error
//add the permissioning host to comms //add the registration host to comms
hParam := connect.GetDefaultHostParams() hParam := connect.GetDefaultHostParams()
hParam.AuthEnabled = false hParam.AuthEnabled = false
// Client will not send KeepAlive packets // Client will not send KeepAlive packets
hParam.KaClientOpts.Time = time.Duration(math.MaxInt64) hParam.KaClientOpts.Time = time.Duration(math.MaxInt64)
perm.host, err = comms.AddHost(&id.Permissioning, def.Registration.Address, perm.host, err = comms.AddHost(&id.ClientRegistration, def.ClientRegistration.Address,
[]byte(def.Registration.TlsCertificate), hParam) []byte(def.ClientRegistration.TlsCertificate), hParam)
if err != nil { if err != nil {
return nil, errors.WithMessage(err, "failed to create permissioning") return nil, errors.WithMessage(err, "failed to create registration")
} }
return &perm, nil return &perm, nil
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// LICENSE file // // LICENSE file //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
package permissioning package registration
import ( import (
"gitlab.com/elixxir/comms/client" "gitlab.com/elixxir/comms/client"
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
"testing" "testing"
) )
// Init should create a valid Permissioning communications struct // Init should create a valid Registration communications struct
func TestInit(t *testing.T) { func TestInit(t *testing.T) {
// Create dummy comms and ndf // Create dummy comms and ndf
comms, err := client.NewClientComms(id.NewIdFromUInt(100, id.User, t), nil, nil, nil) comms, err := client.NewClientComms(id.NewIdFromUInt(100, id.User, t), nil, nil, nil)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// LICENSE file // // LICENSE file //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
package permissioning package registration
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
"gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
) )
func (perm *Permissioning) Register(transmissionPublicKey, receptionPublicKey *rsa.PublicKey, func (perm *Registration) Register(transmissionPublicKey, receptionPublicKey *rsa.PublicKey,
registrationCode string) ([]byte, []byte, int64, error) { registrationCode string) ([]byte, []byte, int64, error) {
return register(perm.comms, perm.host, transmissionPublicKey, receptionPublicKey, registrationCode) return register(perm.comms, perm.host, transmissionPublicKey, receptionPublicKey, registrationCode)
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// LICENSE file // // LICENSE file //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
package permissioning package registration
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
...@@ -51,7 +51,7 @@ func (s *MockRegistrationSender) GetHost(*id.ID) (*connect.Host, bool) { ...@@ -51,7 +51,7 @@ func (s *MockRegistrationSender) GetHost(*id.ID) (*connect.Host, bool) {
} }
// Shows that we get expected result from happy path // Shows that we get expected result from happy path
// Shows that permissioning gets RPCs with the correct parameters // Shows that registration gets RPCs with the correct parameters
func TestRegisterWithPermissioning(t *testing.T) { func TestRegisterWithPermissioning(t *testing.T) {
rng := csprng.NewSystemRNG() rng := csprng.NewSystemRNG()
key, err := rsa.GenerateKey(rng, 256) key, err := rsa.GenerateKey(rng, 256)
...@@ -94,7 +94,7 @@ func TestRegisterWithPermissioning(t *testing.T) { ...@@ -94,7 +94,7 @@ func TestRegisterWithPermissioning(t *testing.T) {
} }
} }
// Shows that returning an error from the permissioning server results in an // Shows that returning an error from the registration server results in an
// error from register // error from register
func TestRegisterWithPermissioning_ResponseErr(t *testing.T) { func TestRegisterWithPermissioning_ResponseErr(t *testing.T) {
rng := csprng.NewSystemRNG() rng := csprng.NewSystemRNG()
...@@ -104,10 +104,10 @@ func TestRegisterWithPermissioning_ResponseErr(t *testing.T) { ...@@ -104,10 +104,10 @@ func TestRegisterWithPermissioning_ResponseErr(t *testing.T) {
} }
var sender MockRegistrationSender var sender MockRegistrationSender
sender.succeedGetHost = true sender.succeedGetHost = true
sender.errInReply = "failure occurred on permissioning" sender.errInReply = "failure occurred on registration"
_, _, _, err = register(&sender, nil, key.GetPublic(), key.GetPublic(), "") _, _, _, err = register(&sender, nil, key.GetPublic(), key.GetPublic(), "")
if err == nil { if err == nil {
t.Error("no error if registration fails on permissioning") t.Error("no error if registration fails on registration")
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment