diff --git a/src/github.com/matrix-org/dendrite/federationapi/routing/profile.go b/src/github.com/matrix-org/dendrite/federationapi/routing/profile.go index 67703931e..48f473669 100644 --- a/src/github.com/matrix-org/dendrite/federationapi/routing/profile.go +++ b/src/github.com/matrix-org/dendrite/federationapi/routing/profile.go @@ -21,6 +21,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/httputil" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/common" + "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" ) @@ -29,6 +30,7 @@ import ( func GetProfile( httpReq *http.Request, accountDB *accounts.Database, + cfg config.Dendrite, ) util.JSONResponse { userID, field := httpReq.FormValue("user_id"), httpReq.FormValue("field") @@ -40,11 +42,15 @@ func GetProfile( } } - localpart, _, err := gomatrixserverlib.SplitID('@', userID) + localpart, domain, err := gomatrixserverlib.SplitID('@', userID) if err != nil { return httputil.LogThenError(httpReq, err) } + if domain != cfg.Matrix.ServerName { + return httputil.LogThenError(httpReq, err) + } + profile, err := accountDB.GetProfileByLocalpart(httpReq.Context(), localpart) if err != nil { return httputil.LogThenError(httpReq, err) diff --git a/src/github.com/matrix-org/dendrite/federationapi/routing/routing.go b/src/github.com/matrix-org/dendrite/federationapi/routing/routing.go index d14e2192d..c50afd6e0 100644 --- a/src/github.com/matrix-org/dendrite/federationapi/routing/routing.go +++ b/src/github.com/matrix-org/dendrite/federationapi/routing/routing.go @@ -109,7 +109,7 @@ func Setup( "federation_query_profile", cfg.Matrix.ServerName, keys, func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse { return GetProfile( - httpReq, accountDB, + httpReq, accountDB, cfg, ) }, )).Methods("GET")