@@ -665,10 +665,11 @@ func New(options *Options) *API {
665
665
api .Auditor .Store (& options .Auditor )
666
666
api .TailnetCoordinator .Store (& options .TailnetCoordinator )
667
667
dialer := & InmemTailnetDialer {
668
- CoordPtr : & api .TailnetCoordinator ,
669
- DERPFn : api .DERPMap ,
670
- Logger : options .Logger ,
671
- ClientID : uuid .New (),
668
+ CoordPtr : & api .TailnetCoordinator ,
669
+ DERPFn : api .DERPMap ,
670
+ Logger : options .Logger ,
671
+ ClientID : uuid .New (),
672
+ DatabaseHealthCheck : api .Database ,
672
673
}
673
674
stn , err := NewServerTailnet (api .ctx ,
674
675
options .Logger ,
@@ -1147,64 +1148,74 @@ func New(options *Options) *API {
1147
1148
r .Get ("/" , api .AssignableSiteRoles )
1148
1149
})
1149
1150
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 ())
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 )
1160
1157
})
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
- })
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 ())
1180
1171
})
1181
- r .Route ("/{keyid}" , func (r chi.Router ) {
1182
- r .Get ("/" , api .apiKeyByID )
1183
- 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
+ })
1184
1196
})
1185
- })
1186
1197
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 )
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 )
1202
1218
})
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
1219
})
1209
1220
})
1210
1221
})
0 commit comments