From 27ca2da7562b1a567a536e75a0943724421de884 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 9 Nov 2021 11:41:19 +0000 Subject: [PATCH] Revert "Signed event copies should be complete" This reverts commit cef7db04697c80a3448e762e8d9f5c9181f5ac06. --- federationapi/routing/invite.go | 13 +++---------- federationapi/routing/join.go | 8 ++------ go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/federationapi/routing/invite.go b/federationapi/routing/invite.go index ee23e37b..46865965 100644 --- a/federationapi/routing/invite.go +++ b/federationapi/routing/invite.go @@ -161,16 +161,9 @@ func processInvite( } // Sign the event so that other servers will know that we have received the invite. - signedEvent, err := event.Sign( + signedEvent := event.Sign( string(cfg.Matrix.ServerName), cfg.Matrix.KeyID, cfg.Matrix.PrivateKey, ) - if err != nil { - util.GetLogger(ctx).WithError(err).Error("event.Sign failed") - return util.JSONResponse{ - Code: http.StatusInternalServerError, - JSON: jsonerror.InternalServerError(), - } - } // Add the invite event to the roomserver. err = api.SendInvite( @@ -185,12 +178,12 @@ func processInvite( if isInviteV2 { return util.JSONResponse{ Code: http.StatusOK, - JSON: gomatrixserverlib.RespInviteV2{Event: signedEvent}, + JSON: gomatrixserverlib.RespInviteV2{Event: &signedEvent}, } } else { return util.JSONResponse{ Code: http.StatusOK, - JSON: gomatrixserverlib.RespInvite{Event: signedEvent}, + JSON: gomatrixserverlib.RespInvite{Event: &signedEvent}, } } default: diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go index 5d2a8bec..0f213048 100644 --- a/federationapi/routing/join.go +++ b/federationapi/routing/join.go @@ -296,15 +296,11 @@ func attemptMakeJoinForRestrictedMembership( // other servers can use to verify that the user we put into the // `join_authorised_via_users_server` field was actually checked // and found by us. - signed, err := event.Sign(string(cfg.Matrix.ServerName), cfg.Matrix.KeyID, cfg.Matrix.PrivateKey) - if err != nil { - logger.WithError(err).Error("Failed to sign event") - return jsonerror.InternalServerError() - } + signed := event.Sign(string(cfg.Matrix.ServerName), cfg.Matrix.KeyID, cfg.Matrix.PrivateKey) // Now, see if the join is valid with the new changes. If it isn't // then something else is forbidding the join. - if err = gomatrixserverlib.Allowed(signed, &provider); err != nil { + if err = gomatrixserverlib.Allowed(&signed, &provider); err != nil { logger.WithError(err).Error("Join is not allowed") return util.JSONResponse{ Code: http.StatusForbidden, diff --git a/go.mod b/go.mod index 21422b32..00f90557 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4 github.com/matrix-org/go-sqlite3-js v0.0.0-20210709140738-b0d1ba599a6d github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16 - github.com/matrix-org/gomatrixserverlib v0.0.0-20211109112442-f6fc321412a1 + github.com/matrix-org/gomatrixserverlib v0.0.0-20211109110212-047177b8f01e github.com/matrix-org/naffka v0.0.0-20210623111924-14ff508b58e0 github.com/matrix-org/pinecone v0.0.0-20211022090602-08a50945ac89 github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 diff --git a/go.sum b/go.sum index 1c2bce55..bfa9e6a4 100644 --- a/go.sum +++ b/go.sum @@ -993,8 +993,8 @@ github.com/matrix-org/go-sqlite3-js v0.0.0-20210709140738-b0d1ba599a6d/go.mod h1 github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0= github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16 h1:ZtO5uywdd5dLDCud4r0r55eP4j9FuUNpl60Gmntcop4= github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s= -github.com/matrix-org/gomatrixserverlib v0.0.0-20211109112442-f6fc321412a1 h1:osaURnuwPB6vH13H4i6LesRphwvMat7XEFIstQQEl7U= -github.com/matrix-org/gomatrixserverlib v0.0.0-20211109112442-f6fc321412a1/go.mod h1:rB8tBUUUo1rzUqpzklRDSooxZ6YMhoaEPx4SO5fGeUc= +github.com/matrix-org/gomatrixserverlib v0.0.0-20211109110212-047177b8f01e h1:idj84HBPLdE9HMU7lzeb0CpQJkB81FSnk/JZQ0bvHmA= +github.com/matrix-org/gomatrixserverlib v0.0.0-20211109110212-047177b8f01e/go.mod h1:rB8tBUUUo1rzUqpzklRDSooxZ6YMhoaEPx4SO5fGeUc= github.com/matrix-org/naffka v0.0.0-20210623111924-14ff508b58e0 h1:HZCzy4oVzz55e+cOMiX/JtSF2UOY1evBl2raaE7ACcU= github.com/matrix-org/naffka v0.0.0-20210623111924-14ff508b58e0/go.mod h1:sjyPyRxKM5uw1nD2cJ6O2OxI6GOqyVBfNXqKjBZTBZE= github.com/matrix-org/pinecone v0.0.0-20211022090602-08a50945ac89 h1:6JkIymZ1vxfI0shSpg6gNPTJaF4/95Evy34slPVZGKM=