udb

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comms

type Comms struct {
	*connect.ProtoComms

	// has all the functions called by endpoint.go
	*pb.UnimplementedUDBServer
	*messages.UnimplementedGenericServer
	// contains filtered or unexported fields
}

Registration object used to implement endpoints and top-level comms functionality

func StartServer

func StartServer(id *id.ID, localServer string, handler Handler,
	certPEMblock, keyPEMblock []byte) *Comms

StartServer starts a new server on the address:port specified by localServer and a callback interface for server operations with given path to public and private key for TLS connection

func (*Comms) AuthenticateToken

func (u *Comms) AuthenticateToken(ctx context.Context,
	msg *messages.AuthenticatedMessage) (*messages.Ack, error)

Handles validation of reverse-authentication tokens

func (*Comms) ConfirmFact

func (u *Comms) ConfirmFact(ctx context.Context, msg *pb.FactConfirmRequest) (*messages.Ack, error)

func (*Comms) RegisterFact

func (u *Comms) RegisterFact(ctx context.Context, msg *pb.FactRegisterRequest) (*pb.FactRegisterResponse, error)

func (*Comms) RegisterUser

func (u *Comms) RegisterUser(ctx context.Context, msg *pb.UDBUserRegistration) (*messages.Ack, error)

func (*Comms) RemoveFact

func (u *Comms) RemoveFact(ctx context.Context, msg *pb.FactRemovalRequest) (*messages.Ack, error)

func (*Comms) RemoveUser

func (u *Comms) RemoveUser(ctx context.Context, msg *pb.FactRemovalRequest) (*messages.Ack, error)

func (*Comms) RequestChannelLease

func (u *Comms) RequestChannelLease(ctx context.Context, msg *pb.ChannelLeaseRequest) (*pb.ChannelLeaseResponse, error)

func (*Comms) RequestNdf

func (u *Comms) RequestNdf(host *connect.Host) (*pb.NDF, error)

RequestNdf is used by User Discovery to Request a NDF from permissioning

func (*Comms) RequestToken

func (u *Comms) RequestToken(context.Context, *messages.Ping) (*messages.AssignToken, error)

Handles reception of reverse-authentication token requests

func (*Comms) ValidateUsername

func (u *Comms) ValidateUsername(
	ctx context.Context, request *pb.UsernameValidationRequest) (*pb.UsernameValidation, error)

ValidateUsername validates that a user owns a username by signing the contents of the mixmessages.UsernameValidationRequest.

type Handler

type Handler interface {
	// RegisterUser handles registering a user into the database
	RegisterUser(registration *pb.UDBUserRegistration) (*messages.Ack, error)
	// RemoveUser deletes this user registration and blocks anyone from ever
	// registering under that username again.
	// The fact removal request must be for the username or it will not work.
	RemoveUser(request *pb.FactRemovalRequest) (*messages.Ack, error)
	// RegisterFact handles registering a fact into the database
	RegisterFact(msg *pb.FactRegisterRequest) (*pb.FactRegisterResponse, error)
	// ConfirmFact checks a Fact against the Fact database
	ConfirmFact(msg *pb.FactConfirmRequest) (*messages.Ack, error)
	// RemoveFact deletes a fact from its associated ID.
	// You cannot RemoveFact on a username. Callers must RemoveUser and reregister.
	RemoveFact(request *pb.FactRemovalRequest) (*messages.Ack, error)
	// RequestChannelLease requests a signature & lease on a user's ed25519 public key from user discovery for use in channels
	RequestChannelLease(request *pb.ChannelLeaseRequest) (*pb.ChannelLeaseResponse, error)
	// ValidateUsername validates that a user owns a username by signing the contents of the
	// mixmessages.UsernameValidationRequest.
	ValidateUsername(request *pb.UsernameValidationRequest) (*pb.UsernameValidation, error)
}

Handler is the interface udb has to implement to integrate with the comms library properly.

type Implementation

type Implementation struct {
	Functions implementationFunctions
}

Implementation allows users of the client library to set the functions that implement the node functions

func NewImplementation

func NewImplementation() *Implementation

NewImplementation returns a Implementation struct with all of the function pointers returning nothing and printing an error. Inside UDB, you would call this, then set all functions to your own UDB version of the function.

func (*Implementation) ConfirmFact

func (s *Implementation) ConfirmFact(request *pb.FactConfirmRequest) (*messages.Ack, error)

ConfirmFact is called by the ConfirmFact in endpoint.go. It calls the corresponding function in the interface.

func (*Implementation) RegisterFact

func (s *Implementation) RegisterFact(request *pb.FactRegisterRequest) (*pb.FactRegisterResponse, error)

RegisterFact is called by the RegisterFact in endpoint.go. It calls the corresponding function in the interface.

func (*Implementation) RegisterUser

func (s *Implementation) RegisterUser(registration *pb.UDBUserRegistration) (*messages.Ack, error)

RegisterUser is called by the RegisterUser in endpoint.go. It calls the corresponding function in the interface.

func (*Implementation) RemoveFact

func (s *Implementation) RemoveFact(request *pb.FactRemovalRequest) (*messages.Ack, error)

RemoveFact is called by the RemoveFact in endpoint.go. It calls the corresponding function in the interface.

func (*Implementation) RemoveUser

func (s *Implementation) RemoveUser(request *pb.FactRemovalRequest) (*messages.Ack, error)

RemoveUser is called by the RemoveUser in endpoint.go. It calls the corresponding function in the interface.

func (*Implementation) RequestChannelLease

func (s *Implementation) RequestChannelLease(request *pb.ChannelLeaseRequest) (*pb.ChannelLeaseResponse, error)

RequestChannelLease is called by the RequestChannelAuthentication in endpoint.go. It calls the corresponding function in the interface

func (*Implementation) ValidateUsername

func (s *Implementation) ValidateUsername(request *pb.UsernameValidationRequest) (*pb.UsernameValidation, error)

ValidateUsername validates that a user owns a username by signing the contents of the mixmessages.UsernameValidationRequest.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL