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,