Documentation
¶
Index ¶
- Constants
- Variables
- func AddBinding(coreContext *core.Ctx) func(context.Context, string, string, string) (signedjson.Message, error)
- func AssociationFromMap(m map[string]interface{}) (*models.Association, error)
- func Bind(coreContext *core.Ctx, m Metric) echo.HandlerFunc
- func BulkLookup(coreContext *core.Ctx, m Metric) echo.HandlerFunc
- func CORS() middleware.CORSConfig
- func EmailRequestCode(coreContext *core.Ctx, m Metric) echo.HandlerFunc
- func EphemeralIsValid(coreContext *core.Ctx) echo.HandlerFunc
- func GetEmailValidatedCode(coreContext *core.Ctx, m Metric) echo.HandlerFunc
- func GetPublicKey(coreContext *core.Ctx) echo.HandlerFunc
- func GetReplicationURLFromPeer(cfg *config.Matrix, peer *models.Peer) string
- func GetValidated3PID(coreContext *core.Ctx, mx Metric) echo.HandlerFunc
- func GetVerifyKeyFromPeer(p *models.Peer) (*signedjson.Key, error)
- func InternalError(ctx echo.Context) error
- func LocalPusher(coreContext *core.Ctx) func(context.Context) error
- func Lookup(coreContext *core.Ctx, m Metric) echo.HandlerFunc
- func PostEmailValidatedCode(coreContext *core.Ctx, m Metric) echo.HandlerFunc
- func PublicKeyIsValid(coreContext *core.Ctx) echo.HandlerFunc
- func PushToRemotePeer(cfg *config.Matrix, peer *models.Peer, replica config.HTTPClient, ...) error
- func RemoveBinding(coreContext *core.Ctx) func(context.Context, *models.Association) error
- func Replicate(coreContext *core.Ctx, m Metric) echo.HandlerFunc
- func RequestEmailToken(ctx context.Context, coreContext *core.Ctx, req *TokenRequest) (int64, error)
- func RequestError(lg logger.Logger, req *http.Request, err error)
- func Service(opts *core.Ctx, m Metric) *echo.Echo
- func SessionWithToken(ctx context.Context, coreContext *core.Ctx, sid int64, ...) error
- func SignED25519(coreContext *core.Ctx, m Metric) echo.HandlerFunc
- func Signer(coreContext *core.Ctx) func(*models.Association) (signedjson.Message, error)
- func StoreInvite(coreContext *core.Ctx, m Metric) echo.HandlerFunc
- func Unbind(coreContext *core.Ctx, fedClient config.HTTPClient) echo.HandlerFunc
- func VerifySignedAssociation(ctx context.Context, key *signedjson.Key, serverName string, ...) error
- func Version(ctx echo.Context) error
- type Association
- type Key
- type Metric
- type MetricApi
- type Payload
- type Peer
- type PushFunc
- type ServerKeys
- type TokenRequest
- type UnbindOption
Constants ¶
const DefaultReplicationPort = 1001
const HandlerLabel = "handler"
const IdentityReplicationPush = "/_matrix/identity/replicate/v1/push"
const SIGNING_KEY_ALGORITHM = "ed25519"
Variables ¶
var ErrMissingThreepid = models.NewError( models.ErrMissingParam, "missing threepids in request body", )
var ErrNoMatchingSignature = errors.New("no matching signatures found")
ErrNoMatchingSignature is returned when there is no signatures for this server found in a signed association object.
var ErrNoSignature = errors.New("no signatures found")
ErrNoSignature is returned when there is no signatures field in a signed message object.
var ErrPublicKeyNotFound = models.NewError( models.ErrNotFound, "The public key was not found", )
ErrPublicKeyNotFound shortcut for the error object returned when there is no public key found.
var ErrThreepidNotAList = models.NewError( models.ErrInvalidParam, "threepids must be a list", )
Functions ¶
func AddBinding ¶
func AssociationFromMap ¶
func AssociationFromMap(m map[string]interface{}) (*models.Association, error)
func Bind ¶
func Bind(coreContext *core.Ctx, m Metric) echo.HandlerFunc
Bind returns a handler that binds third party id to matrix id. You can think of this in the following terms.
Say, you own an email address foo@example.com . The server running this handler is serving requests on bar.com. Now, you want to use bar.com for identification with people you want to chat with in the matrix multiverse.
So you tell bar.com that you are the owner of foo@example.com , bar.com will send you a verification email to make sure you are you, after verifying the email now bar.com knows who you are, so it gives you another id which is recognized by other applications running in the multiverse example @foo:bar.com.
You will become @foo:bar.com to the rest of the matrix multiverse and foo@example.com to bar.com only.
This handler takes care of the binding of foo@example.com => @foo:bar.com. Note that, verification of who you are is done by another handler, this just make sure this server remembers who you really are and assignment of your matrix id.
func BulkLookup ¶
func BulkLookup(coreContext *core.Ctx, m Metric) echo.HandlerFunc
func CORS ¶
func CORS() middleware.CORSConfig
CORS configures echo middleware for identity service cors.
func EmailRequestCode ¶
func EmailRequestCode(coreContext *core.Ctx, m Metric) echo.HandlerFunc
func EphemeralIsValid ¶
func EphemeralIsValid(coreContext *core.Ctx) echo.HandlerFunc
EphemeralIsValid checks if a short term public key is valid.
func GetEmailValidatedCode ¶
func GetEmailValidatedCode(coreContext *core.Ctx, m Metric) echo.HandlerFunc
func GetPublicKey ¶
func GetPublicKey(coreContext *core.Ctx) echo.HandlerFunc
GetPublicKey uses key id to search for a stored public key pinned by this server.
func GetReplicationURLFromPeer ¶
GetReplicationURLFromPeer returns a url string for replication on peer.
func GetValidated3PID ¶
func GetValidated3PID(coreContext *core.Ctx, mx Metric) echo.HandlerFunc
func GetVerifyKeyFromPeer ¶
func GetVerifyKeyFromPeer(p *models.Peer) (*signedjson.Key, error)
GetVerifyKeyFromPeer returns the verification key for peer.
func InternalError ¶
InternalError renders json for internal server errors. We don't divulge reasons for internal errors
func Lookup ¶
func Lookup(coreContext *core.Ctx, m Metric) echo.HandlerFunc
Lookup gets a 3pid bound to a matrix user id.
func PostEmailValidatedCode ¶
func PostEmailValidatedCode(coreContext *core.Ctx, m Metric) echo.HandlerFunc
func PublicKeyIsValid ¶
func PublicKeyIsValid(coreContext *core.Ctx) echo.HandlerFunc
PublicKeyIsValid checks if a public key is valid.
func PushToRemotePeer ¶
func PushToRemotePeer(cfg *config.Matrix, peer *models.Peer, replica config.HTTPClient, as []Association) error
PushToRemotePeer pushes signed associations to a remote identity service peer.
replica is the client used for replication.
func RemoveBinding ¶
func RequestEmailToken ¶
func RequestError ¶
RequestError logs an error that occurred during request processing. Fields of interest are url Path and Method.
func SessionWithToken ¶
func SignED25519 ¶
func SignED25519(coreContext *core.Ctx, m Metric) echo.HandlerFunc
func Signer ¶
func Signer(coreContext *core.Ctx) func(*models.Association) (signedjson.Message, error)
func StoreInvite ¶
func StoreInvite(coreContext *core.Ctx, m Metric) echo.HandlerFunc
func Unbind ¶
func Unbind(coreContext *core.Ctx, fedClient config.HTTPClient) echo.HandlerFunc
func VerifySignedAssociation ¶
func VerifySignedAssociation(ctx context.Context, key *signedjson.Key, serverName string, msg signedjson.Message) error
Types ¶
type Association ¶
type Association struct { OriginID int64 SignedAssociation signedjson.Message }
Association defines association tuple that is shared during replication.
type Metric ¶
type Metric interface { // CountError returns collector for error counts in an handler. By error counts // it means an occupance of if err!=nil expression in the handler body. This is // to allow high quality code as the API is already final and cover small // surface area. // // We hope to achieve 0 runtime errors for this service deployments. CountError(handler string) prometheus.Counter }
type MetricApi ¶
type MetricApi struct { ErrorCount *prometheus.CounterVec // contains filtered or unexported fields }
func (MetricApi) CountError ¶
func (m MetricApi) CountError(handler string) prometheus.Counter
type Payload ¶
type Payload struct {
SignedAssociations []Association `json:"sgAssocs,omitempty"`
}
type Peer ¶
type Peer interface {
PushUpdates(context.Context, []Association) error
}
Peer is an interface for replicating messages across matrix peers.
type PushFunc ¶
type PushFunc func(context.Context, []Association) error
PushFunc defines a function that implements Peer interface.
func PushLocal ¶
PushLocal pushes associations within the same host/instance. This copies associations from local table to the global association table.
func (PushFunc) PushUpdates ¶
func (pf PushFunc) PushUpdates(ctx context.Context, as []Association) error
PushUpdates wrapper for implementing Peer interface on pf.
type ServerKeys ¶
type ServerKeys struct { Name string `json:"server_name"` VerifyKeys map[string]Key `json:"verify_keys"` OldVerifyKeys map[string]Key `json:"old_verify_keys"` Signatures map[string]map[string]string `json:"signatures"` ValidUntil int64 `json:"valid_until_ts"` }
ServerKeys is an object returned when asking for verification keys on a matrix server
type TokenRequest ¶
type UnbindOption ¶
type UnbindOption struct { Threepid *models.Association `json:"threepid,omitempty"` MatrixID string `json:"mxid"` }