fix(coderd): fetch workspace agent scripts and log sources using system auth ctx (#10043)

* add failing unit test
* fetch log sources and agent scripts using system auth ctx
This commit is contained in:
Cian Johnston
2023-10-04 15:50:51 +01:00
committed by GitHub
parent 8e44dce5b3
commit 2c2e98cc39
2 changed files with 10 additions and 6 deletions
+4 -2
View File
@@ -68,11 +68,13 @@ func (api *API) workspaceAgent(rw http.ResponseWriter, r *http.Request) {
return err
})
eg.Go(func() (err error) {
scripts, err = api.Database.GetWorkspaceAgentScriptsByAgentIDs(ctx, []uuid.UUID{workspaceAgent.ID})
//nolint:gocritic // TODO: can we make this not require system restricted?
scripts, err = api.Database.GetWorkspaceAgentScriptsByAgentIDs(dbauthz.AsSystemRestricted(ctx), []uuid.UUID{workspaceAgent.ID})
return err
})
eg.Go(func() (err error) {
logSources, err = api.Database.GetWorkspaceAgentLogSourcesByAgentIDs(ctx, []uuid.UUID{workspaceAgent.ID})
//nolint:gocritic // TODO: can we make this not require system restricted?
logSources, err = api.Database.GetWorkspaceAgentLogSourcesByAgentIDs(dbauthz.AsSystemRestricted(ctx), []uuid.UUID{workspaceAgent.ID})
return err
})
err := eg.Wait()