@@ -54,7 +54,7 @@ func LogNotAuthorizedError(ctx context.Context, logger slog.Logger, err error) e
54
54
}
55
55
}
56
56
57
- func authorizedInsert [ArgumentType any ,
57
+ func insert [ArgumentType any ,
58
58
Insert func (ctx context.Context , arg ArgumentType ) error ](
59
59
// Arguments
60
60
logger slog.Logger ,
@@ -63,14 +63,14 @@ func authorizedInsert[ArgumentType any,
63
63
object rbac.Objecter ,
64
64
insertFunc Insert ) Insert {
65
65
return func (ctx context.Context , arg ArgumentType ) error {
66
- _ , err := authorizedInsertWithReturn (logger , authorizer , action , object , func (ctx context.Context , arg ArgumentType ) (rbac.Objecter , error ) {
66
+ _ , err := insertWithReturn (logger , authorizer , action , object , func (ctx context.Context , arg ArgumentType ) (rbac.Objecter , error ) {
67
67
return rbac.Object {}, insertFunc (ctx , arg )
68
68
})(ctx , arg )
69
69
return err
70
70
}
71
71
}
72
72
73
- func authorizedInsertWithReturn [ObjectType any , ArgumentType any ,
73
+ func insertWithReturn [ObjectType any , ArgumentType any ,
74
74
Insert func (ctx context.Context , arg ArgumentType ) (ObjectType , error )](
75
75
// Arguments
76
76
logger slog.Logger ,
@@ -96,19 +96,19 @@ func authorizedInsertWithReturn[ObjectType any, ArgumentType any,
96
96
}
97
97
}
98
98
99
- func authorizedDelete [ObjectType rbac.Objecter , ArgumentType any ,
99
+ func delete [ObjectType rbac.Objecter , ArgumentType any ,
100
100
Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
101
101
Delete func (ctx context.Context , arg ArgumentType ) error ](
102
102
// Arguments
103
103
logger slog.Logger ,
104
104
authorizer rbac.Authorizer ,
105
105
fetchFunc Fetch ,
106
106
deleteFunc Delete ) Delete {
107
- return authorizedFetchAndExec (logger , authorizer ,
107
+ return fetchAndExec (logger , authorizer ,
108
108
rbac .ActionDelete , fetchFunc , deleteFunc )
109
109
}
110
110
111
- func authorizedUpdateWithReturn [ObjectType rbac.Objecter ,
111
+ func updateWithReturn [ObjectType rbac.Objecter ,
112
112
ArgumentType any ,
113
113
Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
114
114
UpdateQuery func (ctx context.Context , arg ArgumentType ) (ObjectType , error )](
@@ -117,10 +117,10 @@ func authorizedUpdateWithReturn[ObjectType rbac.Objecter,
117
117
authorizer rbac.Authorizer ,
118
118
fetchFunc Fetch ,
119
119
updateQuery UpdateQuery ) UpdateQuery {
120
- return authorizedFetchAndQuery (logger , authorizer , rbac .ActionUpdate , fetchFunc , updateQuery )
120
+ return fetchAndQuery (logger , authorizer , rbac .ActionUpdate , fetchFunc , updateQuery )
121
121
}
122
122
123
- func authorizedUpdate [ObjectType rbac.Objecter ,
123
+ func update [ObjectType rbac.Objecter ,
124
124
ArgumentType any ,
125
125
Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
126
126
Exec func (ctx context.Context , arg ArgumentType ) error ](
@@ -129,13 +129,13 @@ func authorizedUpdate[ObjectType rbac.Objecter,
129
129
authorizer rbac.Authorizer ,
130
130
fetchFunc Fetch ,
131
131
updateExec Exec ) Exec {
132
- return authorizedFetchAndExec (logger , authorizer , rbac .ActionUpdate , fetchFunc , updateExec )
132
+ return fetchAndExec (logger , authorizer , rbac .ActionUpdate , fetchFunc , updateExec )
133
133
}
134
134
135
135
// authorizedFetchAndExecWithConverter uses authorizedFetchAndQueryWithConverter but
136
136
// only cares about the error return type. SQL execs only return an error.
137
137
// See authorizedFetchAndQueryWithConverter for more details.
138
- func authorizedFetchAndExec [ObjectType rbac.Objecter ,
138
+ func fetchAndExec [ObjectType rbac.Objecter ,
139
139
ArgumentType any ,
140
140
Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
141
141
Exec func (ctx context.Context , arg ArgumentType ) error ](
@@ -145,7 +145,7 @@ func authorizedFetchAndExec[ObjectType rbac.Objecter,
145
145
action rbac.Action ,
146
146
fetchFunc Fetch ,
147
147
execFunc Exec ) Exec {
148
- f := authorizedFetchAndQuery (logger , authorizer , action , fetchFunc , func (ctx context.Context , arg ArgumentType ) (empty ObjectType , err error ) {
148
+ f := fetchAndQuery (logger , authorizer , action , fetchFunc , func (ctx context.Context , arg ArgumentType ) (empty ObjectType , err error ) {
149
149
return empty , execFunc (ctx , arg )
150
150
})
151
151
return func (ctx context.Context , arg ArgumentType ) error {
@@ -154,7 +154,7 @@ func authorizedFetchAndExec[ObjectType rbac.Objecter,
154
154
}
155
155
}
156
156
157
- func authorizedFetchAndQuery [ObjectType rbac.Objecter , ArgumentType any ,
157
+ func fetchAndQuery [ObjectType rbac.Objecter , ArgumentType any ,
158
158
Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
159
159
Query func (ctx context.Context , arg ArgumentType ) (ObjectType , error )](
160
160
// Arguments
@@ -186,7 +186,7 @@ func authorizedFetchAndQuery[ObjectType rbac.Objecter, ArgumentType any,
186
186
}
187
187
}
188
188
189
- func authorizedFetch [ObjectType rbac.Objecter , ArgumentType any ,
189
+ func fetch [ObjectType rbac.Objecter , ArgumentType any ,
190
190
Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error )](
191
191
// Arguments
192
192
logger slog.Logger ,
@@ -235,9 +235,9 @@ func authorizedQuery[ArgumentType any, ObjectType rbac.Objecter,
235
235
}
236
236
}
237
237
238
- // authorizedFetchSet is like authorizedFetch , but works with lists of objects.
238
+ // fetchSet is like fetch , but works with lists of objects.
239
239
// SQL filters are much more optimal.
240
- func authorizedFetchSet [ArgumentType any , ObjectType rbac.Objecter ,
240
+ func fetchSet [ArgumentType any , ObjectType rbac.Objecter ,
241
241
DatabaseFunc func (ctx context.Context , arg ArgumentType ) ([]ObjectType , error )](
242
242
// Arguments
243
243
authorizer rbac.Authorizer ,
@@ -260,13 +260,13 @@ func authorizedFetchSet[ArgumentType any, ObjectType rbac.Objecter,
260
260
}
261
261
}
262
262
263
- // authorizedQueryWithRelated performs the same function as authorizedQuery, except that
263
+ // queryWithRelated performs the same function as authorizedQuery, except that
264
264
// RBAC checks are performed on the result of relatedFunc() instead of the result of fetch().
265
265
// This is useful for cases where ObjectType does not implement RBACObjecter.
266
266
// For example, a TemplateVersion object does not implement RBACObjecter, but it is
267
267
// related to a Template object, which does. Thus, any operations on a TemplateVersion
268
268
// are predicated on the RBAC permissions of the related Template object.
269
- func authorizedQueryWithRelated [ObjectType any , ArgumentType any , Related rbac.Objecter ](
269
+ func queryWithRelated [ObjectType any , ArgumentType any , Related rbac.Objecter ](
270
270
// Arguments
271
271
_ slog.Logger ,
272
272
authorizer rbac.Authorizer ,
0 commit comments