Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
d13cec97
Commit
d13cec97
authored
2 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
implemented basic API improvemt for auth callbacks
parent
3ac50c3a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!510
Release
,
!252
Auth callbacks change
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/callbacks.go
+6
-8
6 additions, 8 deletions
cmd/callbacks.go
cmd/root.go
+1
-3
1 addition, 3 deletions
cmd/root.go
xxdk/e2e.go
+52
-14
52 additions, 14 deletions
xxdk/e2e.go
with
59 additions
and
25 deletions
cmd/callbacks.go
+
6
−
8
View file @
d13cec97
...
...
@@ -26,20 +26,18 @@ import (
type
authCallbacks
struct
{
autoConfirm
bool
confCh
chan
*
id
.
ID
client
*
xxdk
.
E2e
}
func
makeAuthCallbacks
(
client
*
xxdk
.
E2e
,
autoConfirm
bool
)
*
authCallbacks
{
func
makeAuthCallbacks
(
autoConfirm
bool
)
*
authCallbacks
{
return
&
authCallbacks
{
autoConfirm
:
autoConfirm
,
confCh
:
make
(
chan
*
id
.
ID
,
10
),
client
:
client
,
}
}
func
(
a
*
authCallbacks
)
Request
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
round
rounds
.
Round
,
client
*
xxdk
.
E2e
)
{
msg
:=
fmt
.
Sprintf
(
"Authentication channel request from: %s
\n
"
,
requestor
.
ID
)
jww
.
INFO
.
Printf
(
msg
)
...
...
@@ -48,9 +46,9 @@ func (a *authCallbacks) Request(requestor contact.Contact,
jww
.
INFO
.
Printf
(
"Channel Request: %s"
,
requestor
.
ID
)
if
viper
.
GetBool
(
"verify-sends"
)
{
// Verify message sends were successful
acceptChannelVerified
(
a
.
client
,
requestor
.
ID
)
acceptChannelVerified
(
client
,
requestor
.
ID
)
}
else
{
acceptChannel
(
a
.
client
,
requestor
.
ID
)
acceptChannel
(
client
,
requestor
.
ID
)
}
a
.
confCh
<-
requestor
.
ID
...
...
@@ -60,14 +58,14 @@ func (a *authCallbacks) Request(requestor contact.Contact,
func
(
a
*
authCallbacks
)
Confirm
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
round
rounds
.
Round
,
client
*
xxdk
.
E2e
)
{
jww
.
INFO
.
Printf
(
"Channel Confirmed: %s"
,
requestor
.
ID
)
a
.
confCh
<-
requestor
.
ID
}
func
(
a
*
authCallbacks
)
Reset
(
requestor
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
round
rounds
.
Round
,
client
*
xxdk
.
E2e
)
{
msg
:=
fmt
.
Sprintf
(
"Authentication channel reset from: %s
\n
"
,
requestor
.
ID
)
jww
.
INFO
.
Printf
(
msg
)
...
...
This diff is collapsed.
Click to expand it.
cmd/root.go
+
1
−
3
View file @
d13cec97
...
...
@@ -670,7 +670,7 @@ func initClient() *xxdk.E2e {
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
authCbs
=
makeAuthCallbacks
(
nil
,
authCbs
=
makeAuthCallbacks
(
viper
.
GetBool
(
"unsafe-channel-creation"
))
client
,
err
:=
xxdk
.
LoginLegacy
(
baseclient
,
authCbs
)
...
...
@@ -678,8 +678,6 @@ func initClient() *xxdk.E2e {
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
authCbs
.
client
=
client
if
protoUser
:=
viper
.
GetString
(
"protoUserOut"
);
protoUser
!=
""
{
jsonBytes
,
err
:=
client
.
ConstructProtoUserFile
()
...
...
This diff is collapsed.
Click to expand it.
xxdk/e2e.go
+
52
−
14
View file @
d13cec97
...
...
@@ -12,10 +12,13 @@ import (
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/auth"
"gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/client/e2e/rekey"
"gitlab.com/elixxir/client/storage/user"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/contact"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/elixxir/ekv"
...
...
@@ -34,16 +37,25 @@ type E2e struct {
e2eIdentity
ReceptionIdentity
}
type
AuthCallbacks
interface
{
Request
(
partner
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
,
e2e
*
E2e
)
Confirm
(
partner
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
,
e2e
*
E2e
)
Reset
(
partner
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
,
e2e
*
E2e
)
}
// Login creates a new E2e backed by the xxdk.Cmix persistent versioned.KV
// It bundles a Cmix object with a ReceptionIdentity object
// and initializes the auth.State and e2e.Handler objects
func
Login
(
client
*
Cmix
,
callbacks
a
uth
.
Callbacks
,
func
Login
(
client
*
Cmix
,
callbacks
A
uthCallbacks
,
identity
ReceptionIdentity
)
(
m
*
E2e
,
err
error
)
{
return
login
(
client
,
callbacks
,
identity
,
client
.
GetStorage
()
.
GetKV
())
}
// LoginEphemeral creates a new E2e backed by a totally ephemeral versioned.KV
func
LoginEphemeral
(
client
*
Cmix
,
callbacks
a
uth
.
Callbacks
,
func
LoginEphemeral
(
client
*
Cmix
,
callbacks
A
uthCallbacks
,
identity
ReceptionIdentity
)
(
m
*
E2e
,
err
error
)
{
return
login
(
client
,
callbacks
,
identity
,
versioned
.
NewKV
(
ekv
.
MakeMemstore
()))
}
...
...
@@ -52,7 +64,7 @@ func LoginEphemeral(client *Cmix, callbacks auth.Callbacks,
// Uses the pre-generated transmission ID used by xxdk.Cmix.
// This function is designed to maintain backwards compatibility with previous
// xx messenger designs and should not be used for other purposes.
func
LoginLegacy
(
client
*
Cmix
,
callbacks
a
uth
.
Callbacks
)
(
m
*
E2e
,
err
error
)
{
func
LoginLegacy
(
client
*
Cmix
,
callbacks
A
uthCallbacks
)
(
m
*
E2e
,
err
error
)
{
m
=
&
E2e
{
Cmix
:
client
,
backup
:
&
Container
{},
...
...
@@ -70,9 +82,14 @@ func LoginLegacy(client *Cmix, callbacks auth.Callbacks) (m *E2e, err error) {
"the e2e processies"
)
}
acw
:=
&
authCallbacksAdapter
{
ac
:
callbacks
,
e2e
:
m
,
}
m
.
auth
,
err
=
auth
.
NewState
(
client
.
GetStorage
()
.
GetKV
(),
client
.
GetCmix
(),
m
.
e2e
,
client
.
GetRng
(),
client
.
GetEventReporter
(),
auth
.
GetDefaultParams
(),
callbacks
,
m
.
backup
.
TriggerBackup
)
auth
.
GetDefaultParams
(),
acw
,
m
.
backup
.
TriggerBackup
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -131,7 +148,7 @@ func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte,
// JSON containing the cryptographic primitives. This is designed for
// some specific deployment procedures and is generally unsafe.
func
LoginWithProtoClient
(
storageDir
string
,
password
[]
byte
,
protoClientJSON
[]
byte
,
newBaseNdf
string
,
protoClientJSON
[]
byte
,
newBaseNdf
string
,
callbacks
AuthCallbacks
,
params
Params
)
(
*
E2e
,
error
)
{
jww
.
INFO
.
Printf
(
"LoginWithProtoClient()"
)
...
...
@@ -166,18 +183,12 @@ func LoginWithProtoClient(storageDir string, password []byte,
c
.
network
.
AddIdentity
(
c
.
GetUser
()
.
ReceptionID
,
time
.
Time
{},
true
)
// FIXME: The callbacks need to be set, so I suppose we would need to
// either set them via a special type or add them
// to the login call?
if
err
!=
nil
{
return
nil
,
err
}
err
=
c
.
registerFollower
()
if
err
!=
nil
{
return
nil
,
err
}
return
Login
(
c
,
nil
,
ReceptionIdentity
{
return
Login
(
c
,
callbacks
,
ReceptionIdentity
{
ID
:
protoUser
.
ReceptionID
,
RSAPrivatePem
:
protoUser
.
ReceptionRSA
,
Salt
:
protoUser
.
ReceptionSalt
,
...
...
@@ -186,7 +197,7 @@ func LoginWithProtoClient(storageDir string, password []byte,
}
// login creates a new xxdk.E2e backed by the given versioned.KV
func
login
(
client
*
Cmix
,
callbacks
a
uth
.
Callbacks
,
func
login
(
client
*
Cmix
,
callbacks
A
uthCallbacks
,
identity
ReceptionIdentity
,
kv
*
versioned
.
KV
)
(
m
*
E2e
,
err
error
)
{
// Verify the passed-in ReceptionIdentity matches its properties
...
...
@@ -228,9 +239,14 @@ func login(client *Cmix, callbacks auth.Callbacks,
"the e2e processies"
)
}
acw
:=
&
authCallbacksAdapter
{
ac
:
callbacks
,
e2e
:
m
,
}
m
.
auth
,
err
=
auth
.
NewState
(
kv
,
client
.
GetCmix
(),
m
.
e2e
,
client
.
GetRng
(),
client
.
GetEventReporter
(),
auth
.
GetDefaultTemporaryParams
(),
callbacks
,
m
.
backup
.
TriggerBackup
)
auth
.
GetDefaultTemporaryParams
(),
acw
,
m
.
backup
.
TriggerBackup
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -396,3 +412,25 @@ func (m *E2e) DeleteContact(partnerId *id.ID) error {
return
nil
}
// Adapter type to make the xxdk auth callbacks type compatible with the
// auth.callbacks
type
authCallbacksAdapter
struct
{
ac
AuthCallbacks
e2e
*
E2e
}
func
(
aca
*
authCallbacksAdapter
)
Request
(
partner
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
aca
.
ac
.
Request
(
partner
,
receptionID
,
round
,
aca
.
e2e
)
}
func
(
aca
*
authCallbacksAdapter
)
Confirm
(
partner
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
aca
.
ac
.
Confirm
(
partner
,
receptionID
,
round
,
aca
.
e2e
)
}
func
(
aca
*
authCallbacksAdapter
)
Reset
(
partner
contact
.
Contact
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
aca
.
ac
.
Reset
(
partner
,
receptionID
,
round
,
aca
.
e2e
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment