mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: remove site wide perms from creating a workspace (#17296)
Creating a workspace required `read` on site wide `user`. Only organization permissions should be required.
This commit is contained in:
114
coderd/coderd.go
114
coderd/coderd.go
@ -1146,64 +1146,74 @@ func New(options *Options) *API {
|
||||
r.Get("/", api.AssignableSiteRoles)
|
||||
})
|
||||
r.Route("/{user}", func(r chi.Router) {
|
||||
r.Use(httpmw.ExtractUserParam(options.Database))
|
||||
r.Post("/convert-login", api.postConvertLoginType)
|
||||
r.Delete("/", api.deleteUser)
|
||||
r.Get("/", api.userByName)
|
||||
r.Get("/autofill-parameters", api.userAutofillParameters)
|
||||
r.Get("/login-type", api.userLoginType)
|
||||
r.Put("/profile", api.putUserProfile)
|
||||
r.Route("/status", func(r chi.Router) {
|
||||
r.Put("/suspend", api.putSuspendUserAccount())
|
||||
r.Put("/activate", api.putActivateUserAccount())
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(httpmw.ExtractUserParamOptional(options.Database))
|
||||
// Creating workspaces does not require permissions on the user, only the
|
||||
// organization member. This endpoint should match the authz story of
|
||||
// postWorkspacesByOrganization
|
||||
r.Post("/workspaces", api.postUserWorkspaces)
|
||||
})
|
||||
r.Get("/appearance", api.userAppearanceSettings)
|
||||
r.Put("/appearance", api.putUserAppearanceSettings)
|
||||
r.Route("/password", func(r chi.Router) {
|
||||
r.Use(httpmw.RateLimit(options.LoginRateLimit, time.Minute))
|
||||
r.Put("/", api.putUserPassword)
|
||||
})
|
||||
// These roles apply to the site wide permissions.
|
||||
r.Put("/roles", api.putUserRoles)
|
||||
r.Get("/roles", api.userRoles)
|
||||
|
||||
r.Route("/keys", func(r chi.Router) {
|
||||
r.Post("/", api.postAPIKey)
|
||||
r.Route("/tokens", func(r chi.Router) {
|
||||
r.Post("/", api.postToken)
|
||||
r.Get("/", api.tokens)
|
||||
r.Get("/tokenconfig", api.tokenConfig)
|
||||
r.Route("/{keyname}", func(r chi.Router) {
|
||||
r.Get("/", api.apiKeyByName)
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(httpmw.ExtractUserParam(options.Database))
|
||||
|
||||
r.Post("/convert-login", api.postConvertLoginType)
|
||||
r.Delete("/", api.deleteUser)
|
||||
r.Get("/", api.userByName)
|
||||
r.Get("/autofill-parameters", api.userAutofillParameters)
|
||||
r.Get("/login-type", api.userLoginType)
|
||||
r.Put("/profile", api.putUserProfile)
|
||||
r.Route("/status", func(r chi.Router) {
|
||||
r.Put("/suspend", api.putSuspendUserAccount())
|
||||
r.Put("/activate", api.putActivateUserAccount())
|
||||
})
|
||||
r.Get("/appearance", api.userAppearanceSettings)
|
||||
r.Put("/appearance", api.putUserAppearanceSettings)
|
||||
r.Route("/password", func(r chi.Router) {
|
||||
r.Use(httpmw.RateLimit(options.LoginRateLimit, time.Minute))
|
||||
r.Put("/", api.putUserPassword)
|
||||
})
|
||||
// These roles apply to the site wide permissions.
|
||||
r.Put("/roles", api.putUserRoles)
|
||||
r.Get("/roles", api.userRoles)
|
||||
|
||||
r.Route("/keys", func(r chi.Router) {
|
||||
r.Post("/", api.postAPIKey)
|
||||
r.Route("/tokens", func(r chi.Router) {
|
||||
r.Post("/", api.postToken)
|
||||
r.Get("/", api.tokens)
|
||||
r.Get("/tokenconfig", api.tokenConfig)
|
||||
r.Route("/{keyname}", func(r chi.Router) {
|
||||
r.Get("/", api.apiKeyByName)
|
||||
})
|
||||
})
|
||||
r.Route("/{keyid}", func(r chi.Router) {
|
||||
r.Get("/", api.apiKeyByID)
|
||||
r.Delete("/", api.deleteAPIKey)
|
||||
})
|
||||
})
|
||||
r.Route("/{keyid}", func(r chi.Router) {
|
||||
r.Get("/", api.apiKeyByID)
|
||||
r.Delete("/", api.deleteAPIKey)
|
||||
})
|
||||
})
|
||||
|
||||
r.Route("/organizations", func(r chi.Router) {
|
||||
r.Get("/", api.organizationsByUser)
|
||||
r.Get("/{organizationname}", api.organizationByUserAndName)
|
||||
})
|
||||
r.Post("/workspaces", api.postUserWorkspaces)
|
||||
r.Route("/workspace/{workspacename}", func(r chi.Router) {
|
||||
r.Get("/", api.workspaceByOwnerAndName)
|
||||
r.Get("/builds/{buildnumber}", api.workspaceBuildByBuildNumber)
|
||||
})
|
||||
r.Get("/gitsshkey", api.gitSSHKey)
|
||||
r.Put("/gitsshkey", api.regenerateGitSSHKey)
|
||||
r.Route("/notifications", func(r chi.Router) {
|
||||
r.Route("/preferences", func(r chi.Router) {
|
||||
r.Get("/", api.userNotificationPreferences)
|
||||
r.Put("/", api.putUserNotificationPreferences)
|
||||
r.Route("/organizations", func(r chi.Router) {
|
||||
r.Get("/", api.organizationsByUser)
|
||||
r.Get("/{organizationname}", api.organizationByUserAndName)
|
||||
})
|
||||
r.Route("/workspace/{workspacename}", func(r chi.Router) {
|
||||
r.Get("/", api.workspaceByOwnerAndName)
|
||||
r.Get("/builds/{buildnumber}", api.workspaceBuildByBuildNumber)
|
||||
})
|
||||
r.Get("/gitsshkey", api.gitSSHKey)
|
||||
r.Put("/gitsshkey", api.regenerateGitSSHKey)
|
||||
r.Route("/notifications", func(r chi.Router) {
|
||||
r.Route("/preferences", func(r chi.Router) {
|
||||
r.Get("/", api.userNotificationPreferences)
|
||||
r.Put("/", api.putUserNotificationPreferences)
|
||||
})
|
||||
})
|
||||
r.Route("/webpush", func(r chi.Router) {
|
||||
r.Post("/subscription", api.postUserWebpushSubscription)
|
||||
r.Delete("/subscription", api.deleteUserWebpushSubscription)
|
||||
r.Post("/test", api.postUserPushNotificationTest)
|
||||
})
|
||||
})
|
||||
r.Route("/webpush", func(r chi.Router) {
|
||||
r.Post("/subscription", api.postUserWebpushSubscription)
|
||||
r.Delete("/subscription", api.deleteUserWebpushSubscription)
|
||||
r.Post("/test", api.postUserPushNotificationTest)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user