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
61a36abd
Commit
61a36abd
authored
4 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
implemented api for request auth
parent
6bba99a9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/authenticatedChannel.go
+10
-15
10 additions, 15 deletions
api/authenticatedChannel.go
with
10 additions
and
15 deletions
api/authenticatedChannel.go
+
10
−
15
View file @
61a36abd
package
api
import
(
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/auth"
"gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/xx_network/primitives/id"
)
// CreateAuthenticatedChannelUNSAFE creates a 1-way authenticated channel
// so this user can send messages to the desired recipient Contact.
// To receive confirmation from the remote user, clients must
// register a listener to do that.
func
(
c
*
Client
)
CreateAuthenticatedChannelUnsafe
(
recipient
contact
.
Contact
)
error
{
jww
.
INFO
.
Printf
(
"CreateAuthenticatedChannel(%v)"
,
recipient
)
sesParam
:=
e2e
.
GetDefaultSessionParams
()
return
c
.
storage
.
E2e
()
.
AddPartner
(
recipient
.
ID
,
recipient
.
DhPubKey
,
c
.
storage
.
E2e
()
.
GetDHPrivateKey
(),
sesParam
,
sesParam
)
}
// RequestAuthenticatedChannel sends a request to another party to establish an
// authenticated channel
...
...
@@ -25,14 +17,17 @@ func (c *Client) CreateAuthenticatedChannelUnsafe(recipient contact.Contact) err
// already received, or if a request was already sent
// When a confirmation occurs, the channel will be created and the callback
// will be called
func
(
c
*
Client
)
RequestAuthenticatedChannel
(
recipient
contact
.
Contact
)
error
{
func
(
c
*
Client
)
RequestAuthenticatedChannel
(
recipient
,
me
contact
.
Contact
,
message
string
)
error
{
jww
.
INFO
.
Printf
(
"RequestAuthenticatedChannel(%v)"
,
recipient
)
if
c
.
network
.
if
!
c
.
network
.
GetHealthTracker
()
.
IsHealthy
()
{
return
errors
.
New
(
"Cannot request authenticated channel "
+
"creation when the network is not healthy"
)
}
sesParam
:=
e2e
.
GetDefaultSessionParams
()
return
c
.
storage
.
E2e
()
.
AddPartner
(
recipient
.
ID
,
recipient
.
DhPubKey
,
c
.
storage
.
E2e
()
.
GetDHPrivateKey
(),
sesParam
,
sesParam
)
return
auth
.
RequestAuth
(
recipient
,
me
,
message
,
c
.
rng
.
GetStream
(),
c
.
storage
,
c
.
network
)
}
// RegisterAuthConfirmationCb registers a callback for channel
...
...
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