Skip to content

Commit f942bcb

Browse files
committed
🔒 Make /profile API authenticated.
1 parent 7465729 commit f942bcb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clientapi/clientapi_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ func TestSetDisplayname(t *testing.T) {
447447
// check profile after initial account creation
448448
rec := httptest.NewRecorder()
449449
req := httptest.NewRequest(http.MethodGet, "/_matrix/client/v3/profile/"+tc.user.ID, strings.NewReader(""))
450+
req.Header.Set("Authorization", "Bearer "+accessTokens[tc.user].accessToken)
450451
t.Logf("%s", req.URL.String())
451452
routers.Client.ServeHTTP(rec, req)
452453

@@ -559,6 +560,7 @@ func TestSetAvatarURL(t *testing.T) {
559560
// check profile after initial account creation
560561
rec := httptest.NewRecorder()
561562
req := httptest.NewRequest(http.MethodGet, "/_matrix/client/v3/profile/"+tc.user.ID, strings.NewReader(""))
563+
req.Header.Set("Authorization", "Bearer "+accessTokens[tc.user].accessToken)
562564
t.Logf("%s", req.URL.String())
563565
routers.Client.ServeHTTP(rec, req)
564566

clientapi/routing/routing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,9 +888,9 @@ func Setup(
888888
).Methods(http.MethodPut)
889889

890890
// Element user settings
891-
891+
// GK-CUSTOMIZATION: Make /profile endpoints authenticated
892892
v3mux.Handle("/profile/{userID}",
893-
httputil.MakeExternalAPI("profile", func(req *http.Request) util.JSONResponse {
893+
httputil.MakeAuthAPI("profile", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
894894
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
895895
if err != nil {
896896
return util.ErrorResponse(err)

0 commit comments

Comments
 (0)