@@ -186,31 +186,18 @@ func fetchAndQuery[ObjectType rbac.Objecter, ArgumentType any,
186
186
}
187
187
}
188
188
189
- func fetch [ObjectType rbac.Objecter , ArgumentType any ,
190
- Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error )](
191
- // Arguments
192
- logger slog.Logger ,
193
- authorizer rbac.Authorizer ,
194
- fetchFunc Fetch ) Fetch {
195
- return authorizedQuery (logger , authorizer , rbac .ActionRead , fetchFunc )
196
- }
197
-
198
- // authorizedQuery is a generic function that wraps a database
189
+ // fetch is a generic function that wraps a database
199
190
// query function (returns an object and an error) with authorization. The
200
191
// returned function has the same arguments as the database function.
201
192
//
202
193
// The database query function will **ALWAYS** hit the database, even if the
203
194
// user cannot read the resource. This is because the resource details are
204
195
// required to run a proper authorization check.
205
- //
206
- // An optimized version of this could be written if the object's authz
207
- // subject properties are known by the caller.
208
- func authorizedQuery [ArgumentType any , ObjectType rbac.Objecter ,
196
+ func fetch [ArgumentType any , ObjectType rbac.Objecter ,
209
197
DatabaseFunc func (ctx context.Context , arg ArgumentType ) (ObjectType , error )](
210
198
// Arguments
211
199
logger slog.Logger ,
212
200
authorizer rbac.Authorizer ,
213
- action rbac.Action ,
214
201
f DatabaseFunc ) DatabaseFunc {
215
202
return func (ctx context.Context , arg ArgumentType ) (empty ObjectType , err error ) {
216
203
// Fetch the rbac subject
@@ -226,7 +213,7 @@ func authorizedQuery[ArgumentType any, ObjectType rbac.Objecter,
226
213
}
227
214
228
215
// Authorize the action
229
- err = authorizer .Authorize (ctx , act , action , object .RBACObject ())
216
+ err = authorizer .Authorize (ctx , act , rbac . ActionRead , object .RBACObject ())
230
217
if err != nil {
231
218
return empty , LogNotAuthorizedError (ctx , logger , err )
232
219
}
0 commit comments