Skip to content

Commit 6f40cf6

Browse files
committed
fix: add dbauthz.AsSystemRestricted in updatecheck, when creating first user, and when registering InMemoryProvisionerd
1 parent a11fed5 commit 6f40cf6

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ func (api *API) CreateInMemoryProvisionerDaemon(ctx context.Context, debounce ti
795795
}()
796796

797797
name := namesgenerator.GetRandomName(1)
798-
daemon, err := api.Database.InsertProvisionerDaemon(ctx, database.InsertProvisionerDaemonParams{
798+
daemon, err := api.Database.InsertProvisionerDaemon(dbauthz.AsSystemRestricted(ctx), database.InsertProvisionerDaemonParams{
799799
ID: uuid.New(),
800800
CreatedAt: database.Now(),
801801
Name: name,

coderd/updatecheck/updatecheck.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"cdr.dev/slog"
2121

2222
"github.com/coder/coder/coderd/database"
23+
"github.com/coder/coder/coderd/database/dbauthz"
2324
)
2425

2526
const (
@@ -224,7 +225,7 @@ func (c *Checker) notifyIfNewer(prev, next Result) {
224225
}
225226

226227
func (c *Checker) lastUpdateCheck(ctx context.Context) (r Result, err error) {
227-
s, err := c.db.GetLastUpdateCheck(ctx)
228+
s, err := c.db.GetLastUpdateCheck(dbauthz.AsSystemRestricted(ctx))
228229
if err != nil {
229230
return r, err
230231
}

coderd/users.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
// @Router /users/first [get]
3838
func (api *API) firstUser(rw http.ResponseWriter, r *http.Request) {
3939
ctx := r.Context()
40-
userCount, err := api.Database.GetUserCount(ctx)
40+
userCount, err := api.Database.GetUserCount(dbauthz.AsSystemRestricted(ctx))
4141
if err != nil {
4242
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
4343
Message: "Internal error fetching user count.",
@@ -78,7 +78,7 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) {
7878
}
7979

8080
// This should only function for the first user.
81-
userCount, err := api.Database.GetUserCount(ctx)
81+
userCount, err := api.Database.GetUserCount(dbauthz.AsSystemRestricted(ctx))
8282
if err != nil {
8383
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
8484
Message: "Internal error fetching user count.",

0 commit comments

Comments
 (0)