Skip to content

Commit 0fa147b

Browse files
committed
use sys context
1 parent 61e7d15 commit 0fa147b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

enterprise/coderd/idpsync.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ func (api *API) patchGroupIDPSyncSettings(rw http.ResponseWriter, r *http.Reques
9393
return
9494
}
9595

96-
existing, err := api.IDPSync.GroupSyncSettings(ctx, org.ID, api.Database)
96+
//nolint:gocritic // Requires system context to update runtime config
97+
sysCtx := dbauthz.AsSystemRestricted(ctx)
98+
existing, err := api.IDPSync.GroupSyncSettings(sysCtx, org.ID, api.Database)
9799
if err != nil {
98100
httpapi.InternalServerError(rw, err)
99101
return
100102
}
101103
aReq.Old = *existing
102104

103-
//nolint:gocritic // Requires system context to update runtime config
104-
sysCtx := dbauthz.AsSystemRestricted(ctx)
105105
err = api.IDPSync.UpdateGroupSettings(sysCtx, org.ID, api.Database, idpsync.GroupSyncSettings{
106106
Field: req.Field,
107107
Mapping: req.Mapping,
@@ -192,15 +192,15 @@ func (api *API) patchRoleIDPSyncSettings(rw http.ResponseWriter, r *http.Request
192192
return
193193
}
194194

195-
existing, err := api.IDPSync.RoleSyncSettings(ctx, org.ID, api.Database)
195+
//nolint:gocritic // Requires system context to update runtime config
196+
sysCtx := dbauthz.AsSystemRestricted(ctx)
197+
existing, err := api.IDPSync.RoleSyncSettings(sysCtx, org.ID, api.Database)
196198
if err != nil {
197199
httpapi.InternalServerError(rw, err)
198200
return
199201
}
200202
aReq.Old = *existing
201203

202-
//nolint:gocritic // Requires system context to update runtime config
203-
sysCtx := dbauthz.AsSystemRestricted(ctx)
204204
err = api.IDPSync.UpdateRoleSettings(sysCtx, org.ID, api.Database, idpsync.RoleSyncSettings{
205205
Field: req.Field,
206206
Mapping: req.Mapping,
@@ -278,20 +278,20 @@ func (api *API) patchOrganizationIDPSyncSettings(rw http.ResponseWriter, r *http
278278
return
279279
}
280280

281-
existing, err := api.IDPSync.OrganizationSyncSettings(ctx, api.Database)
282-
if err != nil {
283-
httpapi.InternalServerError(rw, err)
284-
return
285-
}
286-
aReq.Old = *existing
287-
288281
var req codersdk.OrganizationSyncSettings
289282
if !httpapi.Read(ctx, rw, r, &req) {
290283
return
291284
}
292285

293286
//nolint:gocritic // Requires system context to update runtime config
294287
sysCtx := dbauthz.AsSystemRestricted(ctx)
288+
existing, err := api.IDPSync.OrganizationSyncSettings(sysCtx, api.Database)
289+
if err != nil {
290+
httpapi.InternalServerError(rw, err)
291+
return
292+
}
293+
aReq.Old = *existing
294+
295295
err = api.IDPSync.UpdateOrganizationSettings(sysCtx, api.Database, idpsync.OrganizationSyncSettings{
296296
Field: req.Field,
297297
// We do not check if the mappings point to actual organizations.

0 commit comments

Comments
 (0)