@@ -109,6 +109,11 @@ func (api *api) users(rw http.ResponseWriter, r *http.Request) {
109
109
statusFilter = r .URL .Query ().Get ("status" )
110
110
)
111
111
112
+ // Reading all users across the site
113
+ if ! api .Authorize (rw , r , rbac .ActionRead , rbac .ResourceUser ) {
114
+ return
115
+ }
116
+
112
117
paginationParams , ok := parsePagination (rw , r )
113
118
if ! ok {
114
119
return
@@ -175,6 +180,8 @@ func (api *api) postUser(rw http.ResponseWriter, r *http.Request) {
175
180
return
176
181
}
177
182
183
+ // TODO: @emyrk Authorize the organization create if the createUser will do that.
184
+
178
185
_ , err := api .Database .GetUserByEmailOrUsername (r .Context (), database.GetUserByEmailOrUsernameParams {
179
186
Username : createUser .Username ,
180
187
Email : createUser .Email ,
@@ -253,6 +260,10 @@ func (api *api) userByName(rw http.ResponseWriter, r *http.Request) {
253
260
func (api * api ) putUserProfile (rw http.ResponseWriter , r * http.Request ) {
254
261
user := httpmw .UserParam (r )
255
262
263
+ if ! api .Authorize (rw , r , rbac .ActionUpdate , rbac .ResourceUser .WithID (user .ID .String ())) {
264
+ return
265
+ }
266
+
256
267
var params codersdk.UpdateUserProfileRequest
257
268
if ! httpapi .Read (rw , r , & params ) {
258
269
return
@@ -318,6 +329,10 @@ func (api *api) putUserProfile(rw http.ResponseWriter, r *http.Request) {
318
329
func (api * api ) putUserSuspend (rw http.ResponseWriter , r * http.Request ) {
319
330
user := httpmw .UserParam (r )
320
331
332
+ if ! api .Authorize (rw , r , rbac .ActionUpdate , rbac .ResourceUser .WithID (user .ID .String ())) {
333
+ return
334
+ }
335
+
321
336
suspendedUser , err := api .Database .UpdateUserStatus (r .Context (), database.UpdateUserStatusParams {
322
337
ID : user .ID ,
323
338
Status : database .UserStatusSuspended ,
@@ -351,6 +366,10 @@ func (api *api) putUserPassword(rw http.ResponseWriter, r *http.Request) {
351
366
return
352
367
}
353
368
369
+ if ! api .Authorize (rw , r , rbac .ActionUpdate , rbac .ResourceUser .WithID (user .ID .String ())) {
370
+ return
371
+ }
372
+
354
373
hashedPassword , err := userpassword .Hash (params .Password )
355
374
if err != nil {
356
375
httpapi .Write (rw , http .StatusInternalServerError , httpapi.Response {
0 commit comments