diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index 8849388ef..fdc7cf9f4 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -25,7 +25,6 @@ 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" ) @@ -117,13 +116,7 @@ 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 + serverName := pk.config.Matrix.ServerName // Check signature to verify message was not tempered _, err = message.Verify(pk.Signature, (*string)(&serverName), nil, nil) diff --git a/clientapi/auth/login_publickey_ethereum_test.go b/clientapi/auth/login_publickey_ethereum_test.go index d90cd5f49..5e7788416 100644 --- a/clientapi/auth/login_publickey_ethereum_test.go +++ b/clientapi/auth/login_publickey_ethereum_test.go @@ -27,6 +27,7 @@ import ( "github.com/matrix-org/dendrite/setup/config" testutil "github.com/matrix-org/dendrite/test" uapi "github.com/matrix-org/dendrite/userapi/api" + "github.com/matrix-org/gomatrixserverlib" "github.com/stretchr/testify/assert" ) @@ -37,7 +38,10 @@ type loginContext struct { func createLoginContext(_ *testing.T) *loginContext { cfg := &config.ClientAPI{ - Matrix: &config.Global{}, + Matrix: &config.Global{SigningIdentity: gomatrixserverlib.SigningIdentity{ + ServerName: gomatrixserverlib.ServerName("localhost"), + }, + }, Derived: &config.Derived{}, PasswordAuthenticationDisabled: true, PublicKeyAuthentication: config.PublicKeyAuthentication{ diff --git a/clientapi/routing/register_publickey_test.go b/clientapi/routing/register_publickey_test.go index 19960ed22..e58878ef7 100644 --- a/clientapi/routing/register_publickey_test.go +++ b/clientapi/routing/register_publickey_test.go @@ -29,6 +29,7 @@ import ( "github.com/matrix-org/dendrite/setup/config" testutil "github.com/matrix-org/dendrite/test" uapi "github.com/matrix-org/dendrite/userapi/api" + "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" "github.com/stretchr/testify/assert" ) @@ -42,7 +43,9 @@ type registerContext struct { func createRegisterContext(_ *testing.T) *registerContext { cfg := &config.ClientAPI{ - Matrix: &config.Global{}, + Matrix: &config.Global{SigningIdentity: gomatrixserverlib.SigningIdentity{ + ServerName: gomatrixserverlib.ServerName("localhost"), + }}, Derived: &config.Derived{}, PasswordAuthenticationDisabled: true, PublicKeyAuthentication: config.PublicKeyAuthentication{ @@ -264,6 +267,7 @@ func TestRegisterEthereum(t *testing.T) { // Asserts assert := assert.New(t) assert.NotNil(response, "response actual: nil, expected: not nil") + fmt.Println(response.JSON) registerRes := response.JSON.(registerResponse) assert.Truef( registerRes.UserID == wallet.Eip155UserId,