Signed event copies should be complete

This commit is contained in:
Neil Alexander 2021-11-09 11:27:48 +00:00
parent 35bc2e98e6
commit cef7db0469
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 19 additions and 8 deletions

View file

@ -161,9 +161,16 @@ func processInvite(
}
// Sign the event so that other servers will know that we have received the invite.
signedEvent := event.Sign(
signedEvent, err := 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(
@ -178,12 +185,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:

View file

@ -296,11 +296,15 @@ 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 := event.Sign(string(cfg.Matrix.ServerName), cfg.Matrix.KeyID, cfg.Matrix.PrivateKey)
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()
}
// 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,

2
go.mod
View file

@ -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-20211109110212-047177b8f01e
github.com/matrix-org/gomatrixserverlib v0.0.0-20211109112442-f6fc321412a1
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

4
go.sum
View file

@ -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-20211109110212-047177b8f01e h1:idj84HBPLdE9HMU7lzeb0CpQJkB81FSnk/JZQ0bvHmA=
github.com/matrix-org/gomatrixserverlib v0.0.0-20211109110212-047177b8f01e/go.mod h1:rB8tBUUUo1rzUqpzklRDSooxZ6YMhoaEPx4SO5fGeUc=
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/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=