From d179b9f6f74f57d6c43ae8ed539005df52140e1e Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Tue, 7 Feb 2023 16:28:29 -0800 Subject: [PATCH] HArdcoding the server_name while debugging while it isn't loading from the config Signed-off-by: Brian Meek --- clientapi/auth/login_publickey_ethereum.go | 13 +++++++++++-- clientapi/routing/register_publickey_test.go | 1 - 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index 2ec11ed6b..8849388ef 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -25,6 +25,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/userutil" "github.com/matrix-org/dendrite/setup/config" userapi "github.com/matrix-org/dendrite/userapi/api" + "github.com/matrix-org/gomatrixserverlib" "github.com/spruceid/siwe-go" ) @@ -116,10 +117,18 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri return false, jsonerror.InvalidParam("auth.message") } + cfg := &config.Global{ + SigningIdentity: gomatrixserverlib.SigningIdentity{ + ServerName: gomatrixserverlib.ServerName("localhost"), + }, + } + + serverName := cfg.ServerName + // Check signature to verify message was not tempered - _, err = message.Verify(pk.Signature, (*string)(&pk.config.Matrix.ServerName), nil, nil) + _, err = message.Verify(pk.Signature, (*string)(&serverName), nil, nil) if err != nil { - return false, jsonerror.InvalidSignature(err.Error() + " signature:" + pk.Signature + " server_name:" + string(pk.config.Matrix.ServerName) + " messageDomain:" + message.GetDomain()) + return false, jsonerror.InvalidSignature(err.Error() + " signature:" + pk.Signature + " server_name:" + string(serverName) + " messageDomain:" + message.GetDomain()) } // Error if the user ID does not match the signed message. diff --git a/clientapi/routing/register_publickey_test.go b/clientapi/routing/register_publickey_test.go index 352327b21..19960ed22 100644 --- a/clientapi/routing/register_publickey_test.go +++ b/clientapi/routing/register_publickey_test.go @@ -264,7 +264,6 @@ func TestRegisterEthereum(t *testing.T) { // Asserts assert := assert.New(t) assert.NotNil(response, "response actual: nil, expected: not nil") - assert.Implements((*registerResponse)(nil), response.JSON, "response.JSON received: %v", response.JSON) registerRes := response.JSON.(registerResponse) assert.Truef( registerRes.UserID == wallet.Eip155UserId,