Use client pseudoid during create room
This commit is contained in:
parent
b7d320f8d1
commit
7f7ac0f4fe
|
@ -115,15 +115,32 @@ func SendPDUs(
|
||||||
JSON: spec.InternalServerError{Err: err.Error()},
|
JSON: spec.InternalServerError{Err: err.Error()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
key, err := rsAPI.GetOrCreateUserRoomPrivateKey(req.Context(), *userID, pdu.RoomID())
|
|
||||||
|
util.GetLogger(req.Context()).Infof("Processing %s event (%s): %s", pdu.Type(), pdu.EventID(), pdu.JSON())
|
||||||
|
|
||||||
|
// Check that the event is signed by the server sending the request.
|
||||||
|
redacted, err := verImpl.RedactEventJSON(pdu.JSON())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.JSONResponse{
|
util.GetLogger(req.Context()).WithError(err).Error("RedactEventJSON failed")
|
||||||
Code: http.StatusInternalServerError,
|
continue
|
||||||
JSON: spec.InternalServerError{Err: err.Error()},
|
}
|
||||||
}
|
|
||||||
|
verifier := gomatrixserverlib.JSONVerifierSelf{}
|
||||||
|
verifyRequests := []gomatrixserverlib.VerifyJSONRequest{{
|
||||||
|
ServerName: spec.ServerName(pdu.SenderID()),
|
||||||
|
Message: redacted,
|
||||||
|
AtTS: pdu.OriginServerTS(),
|
||||||
|
ValidityCheckingFunc: gomatrixserverlib.StrictValiditySignatureCheck,
|
||||||
|
}}
|
||||||
|
verifyResults, err := verifier.VerifyJSONs(req.Context(), verifyRequests)
|
||||||
|
if err != nil {
|
||||||
|
util.GetLogger(req.Context()).WithError(err).Error("keys.VerifyJSONs failed")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if verifyResults[0].Error != nil {
|
||||||
|
util.GetLogger(req.Context()).WithError(verifyResults[0].Error).Error("Signature check failed: ")
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
pdu = pdu.Sign(string(pdu.SenderID()), "ed25519:1", key)
|
|
||||||
util.GetLogger(req.Context()).Infof("Processing %s event (%s)", pdu.Type(), pdu.EventID())
|
|
||||||
|
|
||||||
switch pdu.Type() {
|
switch pdu.Type() {
|
||||||
case spec.MRoomCreate:
|
case spec.MRoomCreate:
|
||||||
|
|
|
@ -80,17 +80,11 @@ func (c *Creator) PerformCreateRoomCryptoIDs(ctx context.Context, userID spec.Us
|
||||||
return nil, spec.BadJSON("SenderID is not a valid ed25519 public key")
|
return nil, spec.BadJSON("SenderID is not a valid ed25519 public key")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: cryptoIDs - Swap this out for only storing the public key
|
keyErr := c.RSAPI.StoreUserRoomPublicKey(ctx, senderID, userID, roomID)
|
||||||
key, keyErr := c.RSAPI.GetOrCreateUserRoomPrivateKey(ctx, userID, roomID)
|
|
||||||
if keyErr != nil {
|
if keyErr != nil {
|
||||||
util.GetLogger(ctx).WithError(keyErr).Error("GetOrCreateUserRoomPrivateKey failed")
|
util.GetLogger(ctx).WithError(keyErr).Error("StoreUserRoomPublicKey failed")
|
||||||
return nil, spec.InternalServerError{Err: keyErr.Error()}
|
return nil, spec.InternalServerError{Err: keyErr.Error()}
|
||||||
}
|
}
|
||||||
senderID = spec.SenderIDFromPseudoIDKey(key)
|
|
||||||
//err := c.RSAPI.StoreUserRoomPublicKey(ctx, senderID, userID, roomID)
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, spec.InternalServerError{Err: err.Error()}
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createContent["creator"] = senderID
|
createContent["creator"] = senderID
|
||||||
|
|
Loading…
Reference in a new issue