@@ -141,15 +141,19 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
141
141
. route (
142
142
web:: put ( )
143
143
. to ( logstream:: put_stream)
144
- . auth_stream ( Action :: CreateStream ) ,
144
+ . authorize_for_stream ( Action :: CreateStream ) ,
145
145
)
146
146
// POST "/logstream/{logstream}" ==> Post logs to given log stream
147
- . route ( web:: post ( ) . to ( ingest:: post_event) )
147
+ . route (
148
+ web:: post ( )
149
+ . to ( ingest:: post_event)
150
+ . authorize_for_stream ( Action :: Ingest ) ,
151
+ )
148
152
// DELETE "/logstream/{logstream}" ==> Delete log stream
149
153
. route (
150
154
web:: delete ( )
151
155
. to ( logstream:: delete)
152
- . auth_stream ( Action :: DeleteStream ) ,
156
+ . authorize_for_stream ( Action :: DeleteStream ) ,
153
157
)
154
158
. app_data ( web:: PayloadConfig :: default ( ) . limit ( MAX_EVENT_PAYLOAD_SIZE ) ) ,
155
159
)
@@ -159,29 +163,29 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
159
163
. route (
160
164
web:: put ( )
161
165
. to ( logstream:: put_alert)
162
- . auth_stream ( Action :: PutAlert ) ,
166
+ . authorize_for_stream ( Action :: PutAlert ) ,
163
167
)
164
168
// GET "/logstream/{logstream}/alert" ==> Get alert for given log stream
165
169
. route (
166
170
web:: get ( )
167
171
. to ( logstream:: get_alert)
168
- . auth_stream ( Action :: GetAlert ) ,
172
+ . authorize_for_stream ( Action :: GetAlert ) ,
169
173
) ,
170
174
)
171
175
. service (
172
176
// GET "/logstream/{logstream}/schema" ==> Get schema for given log stream
173
177
web:: resource ( "/schema" ) . route (
174
178
web:: get ( )
175
179
. to ( logstream:: schema)
176
- . auth_stream ( Action :: GetSchema ) ,
180
+ . authorize_for_stream ( Action :: GetSchema ) ,
177
181
) ,
178
182
)
179
183
. service (
180
184
// GET "/logstream/{logstream}/stats" ==> Get stats for given log stream
181
185
web:: resource ( "/stats" ) . route (
182
186
web:: get ( )
183
187
. to ( logstream:: get_stats)
184
- . auth_stream ( Action :: GetStats ) ,
188
+ . authorize_for_stream ( Action :: GetStats ) ,
185
189
) ,
186
190
)
187
191
. service (
@@ -190,13 +194,13 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
190
194
. route (
191
195
web:: put ( )
192
196
. to ( logstream:: put_retention)
193
- . auth_stream ( Action :: PutRetention ) ,
197
+ . authorize_for_stream ( Action :: PutRetention ) ,
194
198
)
195
199
// GET "/logstream/{logstream}/retention" ==> Get retention for given logstream
196
200
. route (
197
201
web:: get ( )
198
202
. to ( logstream:: get_retention)
199
- . auth_stream ( Action :: GetRetention ) ,
203
+ . authorize_for_stream ( Action :: GetRetention ) ,
200
204
) ,
201
205
) ;
202
206
@@ -205,15 +209,19 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
205
209
. service (
206
210
web:: resource ( "/{username}" )
207
211
// PUT /user/{username} => Create a new user
208
- . route ( web:: put ( ) . to ( rbac:: put_user) . auth ( Action :: PutUser ) )
212
+ . route ( web:: put ( ) . to ( rbac:: put_user) . authorize ( Action :: PutUser ) )
209
213
// DELETE /user/{username} => Delete a user
210
- . route ( web:: delete ( ) . to ( rbac:: delete_user) . auth ( Action :: DeleteUser ) )
211
- . route ( web:: put ( ) . to ( rbac:: put_roles) . auth ( Action :: PutUser ) ) ,
214
+ . route (
215
+ web:: delete ( )
216
+ . to ( rbac:: delete_user)
217
+ . authorize ( Action :: DeleteUser ) ,
218
+ )
219
+ . route ( web:: put ( ) . to ( rbac:: put_roles) . authorize ( Action :: PutUser ) ) ,
212
220
)
213
221
. service (
214
222
web:: resource ( "/{username}/roles" )
215
223
// PUT /user/{username}/roles => Put roles for user
216
- . route ( web:: put ( ) . to ( rbac:: put_roles) . auth ( Action :: PutRoles ) ) ,
224
+ . route ( web:: put ( ) . to ( rbac:: put_roles) . authorize ( Action :: PutRoles ) ) ,
217
225
)
218
226
. wrap_fn ( |req, srv| {
219
227
// The credentials set in the env vars (P_USERNAME & P_PASSWORD) are treated
@@ -236,13 +244,20 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
236
244
web:: scope ( & base_path ( ) )
237
245
// POST "/query" ==> Get results of the SQL query passed in request body
238
246
. service (
239
- web:: resource ( "/query" )
240
- . route ( web:: post ( ) . to ( query:: query) . auth_stream ( Action :: Query ) ) ,
247
+ web:: resource ( "/query" ) . route (
248
+ web:: post ( )
249
+ . to ( query:: query)
250
+ . authorize_for_stream ( Action :: Query ) ,
251
+ ) ,
241
252
)
242
253
// POST "/ingest" ==> Post logs to given log stream based on header
243
254
. service (
244
255
web:: resource ( "/ingest" )
245
- . route ( web:: post ( ) . to ( ingest:: ingest) . auth ( Action :: Ingest ) )
256
+ . route (
257
+ web:: post ( )
258
+ . to ( ingest:: ingest)
259
+ . authorize_for_stream ( Action :: Ingest ) ,
260
+ )
246
261
. app_data ( web:: PayloadConfig :: default ( ) . limit ( MAX_EVENT_PAYLOAD_SIZE ) ) ,
247
262
)
248
263
// GET "/liveness" ==> Liveness check as per https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-command
@@ -254,7 +269,7 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
254
269
. service (
255
270
// GET "/logstream" ==> Get list of all Log Streams on the server
256
271
web:: resource ( "" )
257
- . route ( web:: get ( ) . to ( logstream:: list) . auth ( Action :: ListStream ) ) ,
272
+ . route ( web:: get ( ) . to ( logstream:: list) . authorize ( Action :: ListStream ) ) ,
258
273
)
259
274
. service (
260
275
// logstream API
@@ -277,19 +292,19 @@ pub fn metrics_path() -> String {
277
292
}
278
293
279
294
trait RouteExt {
280
- fn auth ( self , action : Action ) -> Self ;
281
- fn auth_stream ( self , action : Action ) -> Self ;
295
+ fn authorize ( self , action : Action ) -> Self ;
296
+ fn authorize_for_stream ( self , action : Action ) -> Self ;
282
297
}
283
298
284
299
impl RouteExt for Route {
285
- fn auth ( self , action : Action ) -> Self {
300
+ fn authorize ( self , action : Action ) -> Self {
286
301
self . wrap ( Authorization {
287
302
action,
288
303
stream : false ,
289
304
} )
290
305
}
291
306
292
- fn auth_stream ( self , action : Action ) -> Self {
307
+ fn authorize_for_stream ( self , action : Action ) -> Self {
293
308
self . wrap ( Authorization {
294
309
action,
295
310
stream : true ,
0 commit comments