Skip to content

Commit f6be255

Browse files
committed
Add RBAC
1 parent 30b8f15 commit f6be255

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

coderd/coderd.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ func New(options *Options) (http.Handler, func()) {
240240
r.Get("/", api.userByName)
241241
r.Put("/profile", api.putUserProfile)
242242
r.Put("/suspend", api.putUserSuspend)
243-
r.Put("/password", api.putUserPassword)
243+
r.Route("/password", func(r chi.Router) {
244+
r.Use(httpmw.WithRBACObject(rbac.ResourceUserPasswordRole))
245+
r.Put("/password", authorize(api.putUserPassword, rbac.ActionUpdate))
246+
})
244247
r.Get("/organizations", api.organizationsByUser)
245248
r.Post("/organizations", api.postOrganizationsByUser)
246249
// These roles apply to the site wide permissions.

coderd/rbac/object.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ var (
2424
Type: "user_role",
2525
}
2626

27+
ResourceUserPasswordRole = Object{
28+
Type: "user_password",
29+
}
30+
2731
// ResourceWildcard represents all resource types
2832
ResourceWildcard = Object{
2933
Type: WildcardSymbol,

0 commit comments

Comments
 (0)