mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-22 14:21:55 -06:00
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()},
|
||||
}
|
||||
}
|
||||
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 {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: spec.InternalServerError{Err: err.Error()},
|
||||
}
|
||||
util.GetLogger(req.Context()).WithError(err).Error("RedactEventJSON failed")
|
||||
continue
|
||||
}
|
||||
|
||||
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() {
|
||||
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")
|
||||
}
|
||||
|
||||
// TODO: cryptoIDs - Swap this out for only storing the public key
|
||||
key, keyErr := c.RSAPI.GetOrCreateUserRoomPrivateKey(ctx, userID, roomID)
|
||||
keyErr := c.RSAPI.StoreUserRoomPublicKey(ctx, senderID, userID, roomID)
|
||||
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()}
|
||||
}
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue