Skip to content
Snippets Groups Projects
Commit 61a36abd authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

implemented api for request auth

parent 6bba99a9
Branches
Tags
No related merge requests found
package api package api
import ( import (
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/auth"
"gitlab.com/elixxir/client/interfaces/contact" "gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/xx_network/primitives/id" "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 // RequestAuthenticatedChannel sends a request to another party to establish an
// authenticated channel // authenticated channel
...@@ -25,14 +17,17 @@ func (c *Client) CreateAuthenticatedChannelUnsafe(recipient contact.Contact) err ...@@ -25,14 +17,17 @@ func (c *Client) CreateAuthenticatedChannelUnsafe(recipient contact.Contact) err
// already received, or if a request was already sent // already received, or if a request was already sent
// When a confirmation occurs, the channel will be created and the callback // When a confirmation occurs, the channel will be created and the callback
// will be called // 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) 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 auth.RequestAuth(recipient, me, message, c.rng.GetStream(),
return c.storage.E2e().AddPartner(recipient.ID, recipient.DhPubKey, c.storage, c.network)
c.storage.E2e().GetDHPrivateKey(), sesParam, sesParam)
} }
// RegisterAuthConfirmationCb registers a callback for channel // RegisterAuthConfirmationCb registers a callback for channel
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment