Skip to content
Snippets Groups Projects
Commit 465e9fab authored by Jake Taylor's avatar Jake Taylor
Browse files

added default authcallbacks

parent e78effdb
No related branches found
No related tags found
2 merge requests!510Release,!238Hotfix/e2e client
......@@ -7,6 +7,10 @@
package auth
import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/crypto/contact"
"gitlab.com/xx_network/primitives/id"
"sync"
)
......@@ -40,3 +44,25 @@ func (p *partnerCallbacks) DeletePartnerCallback(partnerId *id.ID) {
func (p *partnerCallbacks) getPartnerCallback(partnerId *id.ID) Callbacks {
return p.callbacks[*partnerId]
}
// DefaultAuthCallbacks is a simple structure for providing a default Callbacks implementation
// It should generally not be used.
type DefaultAuthCallbacks struct{}
// Confirm will be called when an auth Confirm message is processed.
func (a DefaultAuthCallbacks) Confirm(requestor contact.Contact,
receptionID receptionID.EphemeralIdentity, round rounds.Round) {
jww.ERROR.Printf("No valid auth callback assigned!")
}
// Request will be called when an auth Request message is processed.
func (a DefaultAuthCallbacks) Request(requestor contact.Contact,
receptionID receptionID.EphemeralIdentity, round rounds.Round) {
jww.ERROR.Printf("No valid auth callback assigned!")
}
// Reset will be called when an auth Reset operation occurs.
func (a DefaultAuthCallbacks) Reset(requestor contact.Contact,
receptionID receptionID.EphemeralIdentity, round rounds.Round) {
jww.ERROR.Printf("No valid auth callback assigned!")
}
......@@ -7,6 +7,7 @@
package bindings
import (
"gitlab.com/elixxir/client/auth"
"gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/xxdk"
......@@ -27,10 +28,9 @@ type E2e struct {
id int
}
// Login creates and returns a new E2e object
// and adds it to the e2eTrackerSingleton
// identity can be left nil such that a new
// TransmissionIdentity will be created automatically
// Login creates and returns a new E2e object and adds it to the e2eTrackerSingleton
// identity can be left nil such that a new TransmissionIdentity will be created automatically
// callbacks can be left nil and a default will be used
func (e *E2e) Login(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error) {
cmix, err := cmixTrackerSingleton.get(cmixId)
if err != nil {
......@@ -47,12 +47,21 @@ func (e *E2e) Login(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e,
}
}
authCallbacks := authCallback{bindingsCbs: callbacks}
newE2e, err := xxdk.Login(cmix.api, authCallbacks, newIdentity)
if err != nil {
return nil, err
if callbacks == nil {
authCallbacks := auth.DefaultAuthCallbacks{}
newE2e, err := xxdk.Login(cmix.api, authCallbacks, newIdentity)
if err != nil {
return nil, err
}
return e2eTrackerSingleton.make(newE2e), nil
} else {
authCallbacks := authCallback{bindingsCbs: callbacks}
newE2e, err := xxdk.Login(cmix.api, authCallbacks, newIdentity)
if err != nil {
return nil, err
}
return e2eTrackerSingleton.make(newE2e), nil
}
return e2eTrackerSingleton.make(newE2e), nil
}
// AuthCallbacks is the bindings-specific interface for auth.Callbacks methods.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment