Skip to content

Commit

Permalink
Merge pull request #86 from globekeeper/daniel/auth-profile-api
Browse files Browse the repository at this point in the history
🔒 Make /profile API authenticated.
  • Loading branch information
Danieloni1 authored May 22, 2024
2 parents 7465729 + f942bcb commit b23f241
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions clientapi/clientapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ func TestSetDisplayname(t *testing.T) {
// check profile after initial account creation
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/_matrix/client/v3/profile/"+tc.user.ID, strings.NewReader(""))
req.Header.Set("Authorization", "Bearer "+accessTokens[tc.user].accessToken)
t.Logf("%s", req.URL.String())
routers.Client.ServeHTTP(rec, req)

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

Expand Down
4 changes: 2 additions & 2 deletions clientapi/routing/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -888,9 +888,9 @@ func Setup(
).Methods(http.MethodPut)

// Element user settings

// GK-CUSTOMIZATION: Make /profile endpoints authenticated
v3mux.Handle("/profile/{userID}",
httputil.MakeExternalAPI("profile", func(req *http.Request) util.JSONResponse {
httputil.MakeAuthAPI("profile", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
if err != nil {
return util.ErrorResponse(err)
Expand Down

0 comments on commit b23f241

Please sign in to comment.