@@ -1147,64 +1147,74 @@ func New(options *Options) *API {
1147
1147
r .Get ("/" , api .AssignableSiteRoles )
1148
1148
})
1149
1149
r .Route ("/{user}" , func (r chi.Router ) {
1150
- r .Use (httpmw .ExtractUserParam (options .Database ))
1151
- r .Post ("/convert-login" , api .postConvertLoginType )
1152
- r .Delete ("/" , api .deleteUser )
1153
- r .Get ("/" , api .userByName )
1154
- r .Get ("/autofill-parameters" , api .userAutofillParameters )
1155
- r .Get ("/login-type" , api .userLoginType )
1156
- r .Put ("/profile" , api .putUserProfile )
1157
- r .Route ("/status" , func (r chi.Router ) {
1158
- r .Put ("/suspend" , api .putSuspendUserAccount ())
1159
- r .Put ("/activate" , api .putActivateUserAccount ())
1150
+ r .Group (func (r chi.Router ) {
1151
+ r .Use (httpmw .ExtractUserParamOptional (options .Database ))
1152
+ // Creating workspaces does not require permissions on the user, only the
1153
+ // organization member. This endpoint should match the authz story of
1154
+ // postWorkspacesByOrganization
1155
+ r .Post ("/workspaces" , api .postUserWorkspaces )
1160
1156
})
1161
- r .Get ("/appearance" , api .userAppearanceSettings )
1162
- r .Put ("/appearance" , api .putUserAppearanceSettings )
1163
- r .Route ("/password" , func (r chi.Router ) {
1164
- r .Use (httpmw .RateLimit (options .LoginRateLimit , time .Minute ))
1165
- r .Put ("/" , api .putUserPassword )
1166
- })
1167
- // These roles apply to the site wide permissions.
1168
- r .Put ("/roles" , api .putUserRoles )
1169
- r .Get ("/roles" , api .userRoles )
1170
-
1171
- r .Route ("/keys" , func (r chi.Router ) {
1172
- r .Post ("/" , api .postAPIKey )
1173
- r .Route ("/tokens" , func (r chi.Router ) {
1174
- r .Post ("/" , api .postToken )
1175
- r .Get ("/" , api .tokens )
1176
- r .Get ("/tokenconfig" , api .tokenConfig )
1177
- r .Route ("/{keyname}" , func (r chi.Router ) {
1178
- r .Get ("/" , api .apiKeyByName )
1179
- })
1157
+
1158
+ r .Group (func (r chi.Router ) {
1159
+ r .Use (httpmw .ExtractUserParam (options .Database ))
1160
+
1161
+ r .Post ("/convert-login" , api .postConvertLoginType )
1162
+ r .Delete ("/" , api .deleteUser )
1163
+ r .Get ("/" , api .userByName )
1164
+ r .Get ("/autofill-parameters" , api .userAutofillParameters )
1165
+ r .Get ("/login-type" , api .userLoginType )
1166
+ r .Put ("/profile" , api .putUserProfile )
1167
+ r .Route ("/status" , func (r chi.Router ) {
1168
+ r .Put ("/suspend" , api .putSuspendUserAccount ())
1169
+ r .Put ("/activate" , api .putActivateUserAccount ())
1180
1170
})
1181
- r .Route ("/{keyid}" , func (r chi.Router ) {
1182
- r .Get ("/" , api .apiKeyByID )
1183
- r .Delete ("/" , api .deleteAPIKey )
1171
+ r .Get ("/appearance" , api .userAppearanceSettings )
1172
+ r .Put ("/appearance" , api .putUserAppearanceSettings )
1173
+ r .Route ("/password" , func (r chi.Router ) {
1174
+ r .Use (httpmw .RateLimit (options .LoginRateLimit , time .Minute ))
1175
+ r .Put ("/" , api .putUserPassword )
1176
+ })
1177
+ // These roles apply to the site wide permissions.
1178
+ r .Put ("/roles" , api .putUserRoles )
1179
+ r .Get ("/roles" , api .userRoles )
1180
+
1181
+ r .Route ("/keys" , func (r chi.Router ) {
1182
+ r .Post ("/" , api .postAPIKey )
1183
+ r .Route ("/tokens" , func (r chi.Router ) {
1184
+ r .Post ("/" , api .postToken )
1185
+ r .Get ("/" , api .tokens )
1186
+ r .Get ("/tokenconfig" , api .tokenConfig )
1187
+ r .Route ("/{keyname}" , func (r chi.Router ) {
1188
+ r .Get ("/" , api .apiKeyByName )
1189
+ })
1190
+ })
1191
+ r .Route ("/{keyid}" , func (r chi.Router ) {
1192
+ r .Get ("/" , api .apiKeyByID )
1193
+ r .Delete ("/" , api .deleteAPIKey )
1194
+ })
1184
1195
})
1185
- })
1186
1196
1187
- r .Route ("/organizations" , func (r chi.Router ) {
1188
- r .Get ("/" , api .organizationsByUser )
1189
- r .Get ("/{organizationname}" , api .organizationByUserAndName )
1190
- })
1191
- r .Post ("/workspaces" , api .postUserWorkspaces )
1192
- r .Route ("/workspace/{workspacename}" , func (r chi.Router ) {
1193
- r .Get ("/" , api .workspaceByOwnerAndName )
1194
- r .Get ("/builds/{buildnumber}" , api .workspaceBuildByBuildNumber )
1195
- })
1196
- r .Get ("/gitsshkey" , api .gitSSHKey )
1197
- r .Put ("/gitsshkey" , api .regenerateGitSSHKey )
1198
- r .Route ("/notifications" , func (r chi.Router ) {
1199
- r .Route ("/preferences" , func (r chi.Router ) {
1200
- r .Get ("/" , api .userNotificationPreferences )
1201
- r .Put ("/" , api .putUserNotificationPreferences )
1197
+ r .Route ("/organizations" , func (r chi.Router ) {
1198
+ r .Get ("/" , api .organizationsByUser )
1199
+ r .Get ("/{organizationname}" , api .organizationByUserAndName )
1200
+ })
1201
+ r .Route ("/workspace/{workspacename}" , func (r chi.Router ) {
1202
+ r .Get ("/" , api .workspaceByOwnerAndName )
1203
+ r .Get ("/builds/{buildnumber}" , api .workspaceBuildByBuildNumber )
1204
+ })
1205
+ r .Get ("/gitsshkey" , api .gitSSHKey )
1206
+ r .Put ("/gitsshkey" , api .regenerateGitSSHKey )
1207
+ r .Route ("/notifications" , func (r chi.Router ) {
1208
+ r .Route ("/preferences" , func (r chi.Router ) {
1209
+ r .Get ("/" , api .userNotificationPreferences )
1210
+ r .Put ("/" , api .putUserNotificationPreferences )
1211
+ })
1212
+ })
1213
+ r .Route ("/webpush" , func (r chi.Router ) {
1214
+ r .Post ("/subscription" , api .postUserWebpushSubscription )
1215
+ r .Delete ("/subscription" , api .deleteUserWebpushSubscription )
1216
+ r .Post ("/test" , api .postUserPushNotificationTest )
1202
1217
})
1203
- })
1204
- r .Route ("/webpush" , func (r chi.Router ) {
1205
- r .Post ("/subscription" , api .postUserWebpushSubscription )
1206
- r .Delete ("/subscription" , api .deleteUserWebpushSubscription )
1207
- r .Post ("/test" , api .postUserPushNotificationTest )
1208
1218
})
1209
1219
})
1210
1220
})
0 commit comments