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