v2

package
v0.29.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIncorrectProtocol = fmt.Errorf("version 2 protocol requires a ed25519+jwt based security system")
)
View Source
var (
	ErrInvalidJSON = errors.New("supplied JSON document does not pass schema validation")
)

Functions

func NewRemoteSignedSecureRequest added in v0.26.2

func NewRemoteSignedSecureRequest(ctx context.Context, request protocol.Request, security inter.SecurityProvider) (protocol.SecureRequest, error)

NewRemoteSignedSecureRequest is a NewSecureRequest that delegates the signing to a remote signer like aaasvc

func NewReply

func NewReply(request protocol.Request, sender string) (protocol.Reply, error)

NewReply creates a io.choria.protocol.v2.request based on a previous Request

func NewReplyFromSecureReply added in v0.26.2

func NewReplyFromSecureReply(sr protocol.SecureReply) (protocol.Reply, error)

NewReplyFromSecureReply create a choria:reply:1 based on the data contained in a SecureReply

func NewRequest

func NewRequest(agent string, sender string, caller string, ttl int, id string, collective string) (protocol.Request, error)

NewRequest creates a io.choria.protocol.v2.request

func NewRequestFromSecureRequest added in v0.26.2

func NewRequestFromSecureRequest(sr protocol.SecureRequest) (protocol.Request, error)

NewRequestFromSecureRequest creates a io.choria.protocol.v2.request based on the data contained in a SecureRequest

func NewSecureReply added in v0.26.2

func NewSecureReply(reply protocol.Reply, security inter.SecurityProvider) (protocol.SecureReply, error)

NewSecureReply creates a io.choria.protocol.v2.secure_reply

func NewSecureReplyFromTransport added in v0.26.2

func NewSecureReplyFromTransport(message protocol.TransportMessage, security inter.SecurityProvider, skipvalidate bool) (protocol.SecureReply, error)

NewSecureReplyFromTransport creates a new io.choria.protocol.v2.secure_reply from the data contained in a Transport message

func NewSecureRequest added in v0.26.2

func NewSecureRequest(request protocol.Request, security inter.SecurityProvider) (protocol.SecureRequest, error)

NewSecureRequest creates a choria:secure:request:1

func NewSecureRequestFromTransport added in v0.26.2

func NewSecureRequestFromTransport(message protocol.TransportMessage, security inter.SecurityProvider, skipvalidate bool) (protocol.SecureRequest, error)

NewSecureRequestFromTransport creates a new choria:secure:request:1 from the data contained in a Transport message

func NewTransportFromJSON added in v0.26.2

func NewTransportFromJSON(data []byte) (message protocol.TransportMessage, err error)

NewTransportFromJSON creates a new TransportMessage from JSON

func NewTransportMessage added in v0.26.2

func NewTransportMessage(sender string) (message protocol.TransportMessage, err error)

NewTransportMessage creates a io.choria.protocol.v2.transport

Types

type FederationTransportHeader added in v0.26.2

type FederationTransportHeader struct {
	// The request ID a federated message belongs to
	RequestID string `json:"request,omitempty"`
	// The original `reply` before federation
	ReplyTo string `json:"reply,omitempty"`
	// The identities who the federated message is for
	Targets []string `json:"targets,omitempty"`
}

type Reply added in v0.26.2

type Reply struct {
	// The protocol version for this transport `io.choria.protocol.v2.reply` / protocol.ReplyV2
	Protocol protocol.ProtocolVersion `json:"protocol"`
	// The arbitrary data contained in the reply - like a RPC reply
	MessageBody []byte `json:"message"`
	// The ID of the request this reply relates to
	Request string `json:"request"`
	// The host sending the reply
	Sender string `json:"sender"`
	// The agent the reply originates from
	SendingAgent string `json:"agent"`
	// The unix nano time the request was created
	TimeStamp int64 `json:"time"`
	// contains filtered or unexported fields
}

func (*Reply) Agent added in v0.26.2

func (r *Reply) Agent() string

Agent retrieves the agent name that sent this reply

func (*Reply) FederationReplyTo added in v0.26.2

func (r *Reply) FederationReplyTo() (replyto string, federated bool)

FederationReplyTo retrieves the reply to string set by the federation broker

func (*Reply) FederationRequestID added in v0.26.2

func (r *Reply) FederationRequestID() (id string, federated bool)

FederationRequestID retrieves the federation specific requestid

func (*Reply) FederationTargets added in v0.26.2

func (r *Reply) FederationTargets() (targets []string, federated bool)

FederationTargets retrieves the list of targets this message is destined for

func (*Reply) IsFederated added in v0.26.2

func (r *Reply) IsFederated() bool

IsFederated determines if this message is federated

func (*Reply) IsValidJSON added in v0.26.2

func (r *Reply) IsValidJSON(data []byte) (err error)

IsValidJSON validates the given JSON data against the schema

func (*Reply) JSON added in v0.26.2

func (r *Reply) JSON() ([]byte, error)

JSON creates a JSON encoded reply

func (*Reply) Message added in v0.26.2

func (r *Reply) Message() (msg []byte)

Message retrieves the JSON encoded message set using SetMessage

func (*Reply) NetworkHops added in v0.26.2

func (r *Reply) NetworkHops() [][3]string

NetworkHops returns a list of tuples this messaged traveled through

func (*Reply) RecordNetworkHop added in v0.26.2

func (r *Reply) RecordNetworkHop(in string, processor string, out string)

RecordNetworkHop appends a hop onto the list of those who processed this message

func (*Reply) RequestID added in v0.26.2

func (r *Reply) RequestID() string

RequestID retrieves the unique request id

func (*Reply) SenderID added in v0.26.2

func (r *Reply) SenderID() string

SenderID retrieves the identity of the sending node

func (*Reply) SetFederationReplyTo added in v0.26.2

func (r *Reply) SetFederationReplyTo(reply string)

SetFederationReplyTo stores the original reply-to destination in the federation headers

func (*Reply) SetFederationRequestID added in v0.26.2

func (r *Reply) SetFederationRequestID(id string)

SetFederationRequestID sets the request ID for federation purposes

func (*Reply) SetFederationTargets added in v0.26.2

func (r *Reply) SetFederationTargets(targets []string)

SetFederationTargets sets the list of hosts this message should go to.

Federation brokers will duplicate the message and send one for each target

func (*Reply) SetMessage added in v0.26.2

func (r *Reply) SetMessage(message []byte)

SetMessage sets the data to be stored in the Reply

func (*Reply) SetUnfederated added in v0.26.2

func (r *Reply) SetUnfederated()

SetUnfederated removes any federation information from the message

func (*Reply) Time added in v0.26.2

func (r *Reply) Time() time.Time

Time retrieves the time stamp that this message was made

func (*Reply) Version added in v0.26.2

func (r *Reply) Version() protocol.ProtocolVersion

Version retrieves the protocol version for this message

type ReqEnvelope added in v0.26.2

type ReqEnvelope struct {
	RequestID  string           `json:"id"`
	SenderID   string           `json:"sender"`
	CallerID   string           `json:"caller"`
	Collective string           `json:"collective"`
	Agent      string           `json:"agent"`
	TTL        int              `json:"ttl"`
	Time       int64            `json:"time"`
	Filter     *protocol.Filter `json:"filter,omitempty"`
	// contains filtered or unexported fields
}

type Request added in v0.26.2

type Request struct {
	Protocol    protocol.ProtocolVersion `json:"protocol"`
	MessageBody []byte                   `json:"message"`

	ReqEnvelope
	// contains filtered or unexported fields
}

func (*Request) Agent added in v0.26.2

func (r *Request) Agent() string

Agent retrieves the agent name this message is for

func (*Request) CallerID added in v0.26.2

func (r *Request) CallerID() string

CallerID retrieves the caller id that sent the message

func (*Request) CallerPublicData added in v0.27.0

func (r *Request) CallerPublicData() string

CallerPublicData is the JWT validated by the Secure Request, only set when a request is created from a SecureRequest

func (*Request) Collective added in v0.26.2

func (r *Request) Collective() string

Collective retrieves the name of the sub collective this message is aimed at

func (*Request) FederationReplyTo added in v0.26.2

func (r *Request) FederationReplyTo() (replyTo string, federated bool)

FederationReplyTo retrieves the reply to string set by the federation broker

func (*Request) FederationRequestID added in v0.26.2

func (r *Request) FederationRequestID() (id string, federated bool)

FederationRequestID retrieves the federation specific requestid

func (*Request) FederationTargets added in v0.26.2

func (r *Request) FederationTargets() (targets []string, federated bool)

FederationTargets retrieves the list of targets this message is destined for

func (*Request) Filter added in v0.26.2

func (r *Request) Filter() (filter *protocol.Filter, filtered bool)

Filter retrieves the filter for the message. The boolean is true when the filter is not empty

func (*Request) IsFederated added in v0.26.2

func (r *Request) IsFederated() bool

IsFederated determines if this message is federated

func (*Request) IsValidJSON added in v0.26.2

func (r *Request) IsValidJSON(data []byte) error

IsValidJSON validates the given JSON data against the schema

func (*Request) JSON added in v0.26.2

func (r *Request) JSON() ([]byte, error)

JSON creates a JSON encoded request

func (*Request) Message added in v0.26.2

func (r *Request) Message() []byte

Message retrieves the Message body

func (*Request) NetworkHops added in v0.26.2

func (r *Request) NetworkHops() [][3]string

NetworkHops returns a list of tuples this messaged traveled through

func (*Request) NewFilter added in v0.26.2

func (r *Request) NewFilter() *protocol.Filter

NewFilter creates a new empty filter and sets it

func (*Request) RecordNetworkHop added in v0.26.2

func (r *Request) RecordNetworkHop(in string, processor string, out string)

RecordNetworkHop appends a hop onto the list of those who processed this message

func (*Request) RequestID added in v0.26.2

func (r *Request) RequestID() string

RequestID retrieves the unique request ID

func (*Request) SenderID added in v0.26.2

func (r *Request) SenderID() string

SenderID retrieves the sender id that sent the message

func (*Request) SetAgent added in v0.26.2

func (r *Request) SetAgent(agent string)

SetAgent sets the agent this requires is created for

func (*Request) SetCallerID added in v0.26.2

func (r *Request) SetCallerID(id string)

SetCallerID sets the caller id for this request

func (*Request) SetCollective added in v0.26.2

func (r *Request) SetCollective(collective string)

SetCollective sets the collective this request is directed at

func (*Request) SetFederationReplyTo added in v0.26.2

func (r *Request) SetFederationReplyTo(reply string)

SetFederationReplyTo stores the original reply-to destination in the federation headers

func (*Request) SetFederationRequestID added in v0.26.2

func (r *Request) SetFederationRequestID(id string)

SetFederationRequestID sets the request ID for federation purposes

func (*Request) SetFederationTargets added in v0.26.2

func (r *Request) SetFederationTargets(targets []string)

SetFederationTargets sets the list of hosts this message should go to.

Federation brokers will duplicate the message and send one for each target

func (*Request) SetFilter added in v0.26.2

func (r *Request) SetFilter(filter *protocol.Filter)

SetFilter sets and overwrites the filter for a message with a new one

func (*Request) SetMessage added in v0.26.2

func (r *Request) SetMessage(message []byte)

SetMessage set the message body that's contained in this request

func (*Request) SetRequestID added in v0.26.2

func (r *Request) SetRequestID(id string)

SetRequestID sets the request ID for this message

func (*Request) SetTTL added in v0.26.2

func (r *Request) SetTTL(ttl int)

SetTTL sets the validity period for this message

func (*Request) SetUnfederated added in v0.26.2

func (r *Request) SetUnfederated()

SetUnfederated removes any federation information from the message

func (*Request) SignerPublicData added in v0.27.0

func (r *Request) SignerPublicData() string

SignerPublicData is the JWT of the request signer validated by the Secure Request, only set when a request is created from a SecureRequest

func (*Request) TTL added in v0.26.2

func (r *Request) TTL() int

TTL retrieves the maximum allow lifetime of this message

func (*Request) Time added in v0.26.2

func (r *Request) Time() time.Time

Time retrieves the time this message was first made

func (*Request) Version added in v0.26.2

func (r *Request) Version() protocol.ProtocolVersion

Version retrieves the protocol version for this message

type SecureReply added in v0.26.2

type SecureReply struct {
	// The protocol version for this secure reply `io.choria.protocol.v2.secure_reply` / protocol.SecureReplyV2
	Protocol protocol.ProtocolVersion `json:"protocol"`
	// The reply held in the Secure Request
	MessageBody []byte `json:"reply"`
	// A sha256 of the reply
	Hash string `json:"hash"`
	// A signature made using the ed25519 seed of the sender
	Signature []byte `json:"signature,omitempty"`
	// The JWT of the sending host
	SenderJWT string `json:"sender,omitempty"`
	// contains filtered or unexported fields
}

SecureReply contains 1 serialized Reply hashed

func (*SecureReply) IsValidJSON added in v0.26.2

func (r *SecureReply) IsValidJSON(data []byte) error

func (*SecureReply) JSON added in v0.26.2

func (r *SecureReply) JSON() ([]byte, error)

func (*SecureReply) Message added in v0.26.2

func (r *SecureReply) Message() []byte

func (*SecureReply) SetMessage added in v0.26.2

func (r *SecureReply) SetMessage(reply protocol.Reply) error

func (*SecureReply) Valid added in v0.26.2

func (r *SecureReply) Valid() bool

func (*SecureReply) Version added in v0.26.2

func (r *SecureReply) Version() protocol.ProtocolVersion

type SecureRequest added in v0.26.2

type SecureRequest struct {
	// The protocol version for this secure request `io.choria.protocol.v2.secure_request` / protocol.SecureRequestV2
	Protocol protocol.ProtocolVersion `json:"protocol"`
	// The request held in the Secure Request
	MessageBody []byte `json:"request"`
	// A signature made using the ed25519 seed of the caller or signer
	Signature []byte `json:"signature"`
	// The JWT of the caller
	CallerJWT string `json:"caller"`
	// The JWT of the delegated signer, present when the AAA server is used
	SignerJWT string `json:"signer,omitempty"`
	// contains filtered or unexported fields
}

SecureRequest contains 1 serialized Request signed and with the related JWTs attached

func (*SecureRequest) CallerPublicData added in v0.27.0

func (r *SecureRequest) CallerPublicData() string

func (*SecureRequest) IsValidJSON added in v0.26.2

func (r *SecureRequest) IsValidJSON(data []byte) error

func (*SecureRequest) JSON added in v0.26.2

func (r *SecureRequest) JSON() ([]byte, error)

func (*SecureRequest) Message added in v0.26.2

func (r *SecureRequest) Message() []byte

func (*SecureRequest) SetMessage added in v0.26.2

func (r *SecureRequest) SetMessage(request protocol.Request) error

func (*SecureRequest) SetSigner added in v0.27.0

func (r *SecureRequest) SetSigner(signer []byte) error

func (*SecureRequest) Valid added in v0.26.2

func (r *SecureRequest) Valid() bool

func (*SecureRequest) Version added in v0.26.2

func (r *SecureRequest) Version() protocol.ProtocolVersion

type TransportHeaders added in v0.26.2

type TransportHeaders struct {
	// A transport specific response channel for this message, used in requests
	ReplyTo string `json:"reply,omitempty"`
	// The host that sent this message
	Sender string `json:"sender,omitempty"`
	// A trace of host/broker pairs that the message traversed
	SeenBy [][3]string `json:"trace,omitempty"`
	// Headers to assist federation
	Federation *FederationTransportHeader `json:"federation,omitempty"`
}

type TransportMessage added in v0.26.2

type TransportMessage struct {
	// The protocol version for this transport `io.choria.protocol.v2.transport` / protocol.TransportV2
	Protocol protocol.ProtocolVersion `json:"protocol"`
	// The payload to be transport, a Secure Request or Secure Reply
	Data []byte `json:"data"`
	// Optional headers
	Headers *TransportHeaders `json:"headers,omitempty"`
	// contains filtered or unexported fields
}

func (*TransportMessage) FederationReplyTo added in v0.26.2

func (m *TransportMessage) FederationReplyTo() (string, bool)

func (*TransportMessage) FederationRequestID added in v0.26.2

func (m *TransportMessage) FederationRequestID() (string, bool)

func (*TransportMessage) FederationTargets added in v0.26.2

func (m *TransportMessage) FederationTargets() ([]string, bool)

func (*TransportMessage) IsFederated added in v0.26.2

func (m *TransportMessage) IsFederated() bool

func (*TransportMessage) IsValidJSON added in v0.26.2

func (m *TransportMessage) IsValidJSON(data []byte) error

func (*TransportMessage) JSON added in v0.26.2

func (m *TransportMessage) JSON() ([]byte, error)

func (*TransportMessage) Message added in v0.26.2

func (m *TransportMessage) Message() ([]byte, error)

func (*TransportMessage) NetworkHops added in v0.26.2

func (m *TransportMessage) NetworkHops() [][3]string

func (*TransportMessage) RecordNetworkHop added in v0.26.2

func (m *TransportMessage) RecordNetworkHop(in string, processor string, out string)

func (*TransportMessage) ReplyTo added in v0.26.2

func (m *TransportMessage) ReplyTo() string

func (*TransportMessage) SeenBy added in v0.26.2

func (m *TransportMessage) SeenBy() [][3]string

func (*TransportMessage) SenderID added in v0.26.2

func (m *TransportMessage) SenderID() string

func (*TransportMessage) SetFederationReplyTo added in v0.26.2

func (m *TransportMessage) SetFederationReplyTo(reply string)

func (*TransportMessage) SetFederationRequestID added in v0.26.2

func (m *TransportMessage) SetFederationRequestID(id string)

func (*TransportMessage) SetFederationTargets added in v0.26.2

func (m *TransportMessage) SetFederationTargets(targets []string)

func (*TransportMessage) SetReplyData added in v0.26.2

func (m *TransportMessage) SetReplyData(reply protocol.SecureReply) error

func (*TransportMessage) SetReplyTo added in v0.26.2

func (m *TransportMessage) SetReplyTo(reply string)

func (*TransportMessage) SetRequestData added in v0.26.2

func (m *TransportMessage) SetRequestData(request protocol.SecureRequest) error

func (*TransportMessage) SetSender added in v0.26.2

func (m *TransportMessage) SetSender(sender string)

func (*TransportMessage) SetUnfederated added in v0.26.2

func (m *TransportMessage) SetUnfederated()

func (*TransportMessage) Version added in v0.26.2

Jump to

Keyboard shortcuts

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