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