@@ -141,15 +141,15 @@ 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
+ . authorise_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 ( web:: post ( ) . to ( ingest:: post_event) . authorise ( Action :: Ingest ) )
148
148
// DELETE "/logstream/{logstream}" ==> Delete log stream
149
149
. route (
150
150
web:: delete ( )
151
151
. to ( logstream:: delete)
152
- . auth_stream ( Action :: DeleteStream ) ,
152
+ . authorise_for_stream ( Action :: DeleteStream ) ,
153
153
)
154
154
. app_data ( web:: PayloadConfig :: default ( ) . limit ( MAX_EVENT_PAYLOAD_SIZE ) ) ,
155
155
)
@@ -159,29 +159,29 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
159
159
. route (
160
160
web:: put ( )
161
161
. to ( logstream:: put_alert)
162
- . auth_stream ( Action :: PutAlert ) ,
162
+ . authorise_for_stream ( Action :: PutAlert ) ,
163
163
)
164
164
// GET "/logstream/{logstream}/alert" ==> Get alert for given log stream
165
165
. route (
166
166
web:: get ( )
167
167
. to ( logstream:: get_alert)
168
- . auth_stream ( Action :: GetAlert ) ,
168
+ . authorise_for_stream ( Action :: GetAlert ) ,
169
169
) ,
170
170
)
171
171
. service (
172
172
// GET "/logstream/{logstream}/schema" ==> Get schema for given log stream
173
173
web:: resource ( "/schema" ) . route (
174
174
web:: get ( )
175
175
. to ( logstream:: schema)
176
- . auth_stream ( Action :: GetSchema ) ,
176
+ . authorise_for_stream ( Action :: GetSchema ) ,
177
177
) ,
178
178
)
179
179
. service (
180
180
// GET "/logstream/{logstream}/stats" ==> Get stats for given log stream
181
181
web:: resource ( "/stats" ) . route (
182
182
web:: get ( )
183
183
. to ( logstream:: get_stats)
184
- . auth_stream ( Action :: GetStats ) ,
184
+ . authorise_for_stream ( Action :: GetStats ) ,
185
185
) ,
186
186
)
187
187
. service (
@@ -190,13 +190,13 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
190
190
. route (
191
191
web:: put ( )
192
192
. to ( logstream:: put_retention)
193
- . auth_stream ( Action :: PutRetention ) ,
193
+ . authorise_for_stream ( Action :: PutRetention ) ,
194
194
)
195
195
// GET "/logstream/{logstream}/retention" ==> Get retention for given logstream
196
196
. route (
197
197
web:: get ( )
198
198
. to ( logstream:: get_retention)
199
- . auth_stream ( Action :: GetRetention ) ,
199
+ . authorise_for_stream ( Action :: GetRetention ) ,
200
200
) ,
201
201
) ;
202
202
@@ -205,15 +205,19 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
205
205
. service (
206
206
web:: resource ( "/{username}" )
207
207
// PUT /user/{username} => Create a new user
208
- . route ( web:: put ( ) . to ( rbac:: put_user) . auth ( Action :: PutUser ) )
208
+ . route ( web:: put ( ) . to ( rbac:: put_user) . authorise ( Action :: PutUser ) )
209
209
// 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 ) ) ,
210
+ . route (
211
+ web:: delete ( )
212
+ . to ( rbac:: delete_user)
213
+ . authorise ( Action :: DeleteUser ) ,
214
+ )
215
+ . route ( web:: put ( ) . to ( rbac:: put_roles) . authorise ( Action :: PutUser ) ) ,
212
216
)
213
217
. service (
214
218
web:: resource ( "/{username}/roles" )
215
219
// PUT /user/{username}/roles => Put roles for user
216
- . route ( web:: put ( ) . to ( rbac:: put_roles) . auth ( Action :: PutRoles ) ) ,
220
+ . route ( web:: put ( ) . to ( rbac:: put_roles) . authorise ( Action :: PutRoles ) ) ,
217
221
)
218
222
. wrap_fn ( |req, srv| {
219
223
// The credentials set in the env vars (P_USERNAME & P_PASSWORD) are treated
@@ -236,13 +240,16 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
236
240
web:: scope ( & base_path ( ) )
237
241
// POST "/query" ==> Get results of the SQL query passed in request body
238
242
. service (
239
- web:: resource ( "/query" )
240
- . route ( web:: post ( ) . to ( query:: query) . auth_stream ( Action :: Query ) ) ,
243
+ web:: resource ( "/query" ) . route (
244
+ web:: post ( )
245
+ . to ( query:: query)
246
+ . authorise_for_stream ( Action :: Query ) ,
247
+ ) ,
241
248
)
242
249
// POST "/ingest" ==> Post logs to given log stream based on header
243
250
. service (
244
251
web:: resource ( "/ingest" )
245
- . route ( web:: post ( ) . to ( ingest:: ingest) . auth ( Action :: Ingest ) )
252
+ . route ( web:: post ( ) . to ( ingest:: ingest) . authorise ( Action :: Ingest ) )
246
253
. app_data ( web:: PayloadConfig :: default ( ) . limit ( MAX_EVENT_PAYLOAD_SIZE ) ) ,
247
254
)
248
255
// 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 +261,7 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
254
261
. service (
255
262
// GET "/logstream" ==> Get list of all Log Streams on the server
256
263
web:: resource ( "" )
257
- . route ( web:: get ( ) . to ( logstream:: list) . auth ( Action :: ListStream ) ) ,
264
+ . route ( web:: get ( ) . to ( logstream:: list) . authorise ( Action :: ListStream ) ) ,
258
265
)
259
266
. service (
260
267
// logstream API
@@ -277,19 +284,19 @@ pub fn metrics_path() -> String {
277
284
}
278
285
279
286
trait RouteExt {
280
- fn auth ( self , action : Action ) -> Self ;
281
- fn auth_stream ( self , action : Action ) -> Self ;
287
+ fn authorise ( self , action : Action ) -> Self ;
288
+ fn authorise_for_stream ( self , action : Action ) -> Self ;
282
289
}
283
290
284
291
impl RouteExt for Route {
285
- fn auth ( self , action : Action ) -> Self {
292
+ fn authorise ( self , action : Action ) -> Self {
286
293
self . wrap ( Authorization {
287
294
action,
288
295
stream : false ,
289
296
} )
290
297
}
291
298
292
- fn auth_stream ( self , action : Action ) -> Self {
299
+ fn authorise_for_stream ( self , action : Action ) -> Self {
293
300
self . wrap ( Authorization {
294
301
action,
295
302
stream : true ,
0 commit comments