Skip to content

Commit 8559d29

Browse files
committed
Fix
1 parent 83dca98 commit 8559d29

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

server/src/handlers/http.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
141141
.route(
142142
web::put()
143143
.to(logstream::put_stream)
144-
.auth_stream(Action::CreateStream),
144+
.authorise_for_stream(Action::CreateStream),
145145
)
146146
// 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))
148148
// DELETE "/logstream/{logstream}" ==> Delete log stream
149149
.route(
150150
web::delete()
151151
.to(logstream::delete)
152-
.auth_stream(Action::DeleteStream),
152+
.authorise_for_stream(Action::DeleteStream),
153153
)
154154
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE)),
155155
)
@@ -159,29 +159,29 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
159159
.route(
160160
web::put()
161161
.to(logstream::put_alert)
162-
.auth_stream(Action::PutAlert),
162+
.authorise_for_stream(Action::PutAlert),
163163
)
164164
// GET "/logstream/{logstream}/alert" ==> Get alert for given log stream
165165
.route(
166166
web::get()
167167
.to(logstream::get_alert)
168-
.auth_stream(Action::GetAlert),
168+
.authorise_for_stream(Action::GetAlert),
169169
),
170170
)
171171
.service(
172172
// GET "/logstream/{logstream}/schema" ==> Get schema for given log stream
173173
web::resource("/schema").route(
174174
web::get()
175175
.to(logstream::schema)
176-
.auth_stream(Action::GetSchema),
176+
.authorise_for_stream(Action::GetSchema),
177177
),
178178
)
179179
.service(
180180
// GET "/logstream/{logstream}/stats" ==> Get stats for given log stream
181181
web::resource("/stats").route(
182182
web::get()
183183
.to(logstream::get_stats)
184-
.auth_stream(Action::GetStats),
184+
.authorise_for_stream(Action::GetStats),
185185
),
186186
)
187187
.service(
@@ -190,13 +190,13 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
190190
.route(
191191
web::put()
192192
.to(logstream::put_retention)
193-
.auth_stream(Action::PutRetention),
193+
.authorise_for_stream(Action::PutRetention),
194194
)
195195
// GET "/logstream/{logstream}/retention" ==> Get retention for given logstream
196196
.route(
197197
web::get()
198198
.to(logstream::get_retention)
199-
.auth_stream(Action::GetRetention),
199+
.authorise_for_stream(Action::GetRetention),
200200
),
201201
);
202202

@@ -205,15 +205,19 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
205205
.service(
206206
web::resource("/{username}")
207207
// 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))
209209
// 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)),
212216
)
213217
.service(
214218
web::resource("/{username}/roles")
215219
// 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)),
217221
)
218222
.wrap_fn(|req, srv| {
219223
// 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) {
236240
web::scope(&base_path())
237241
// POST "/query" ==> Get results of the SQL query passed in request body
238242
.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+
),
241248
)
242249
// POST "/ingest" ==> Post logs to given log stream based on header
243250
.service(
244251
web::resource("/ingest")
245-
.route(web::post().to(ingest::ingest).auth(Action::Ingest))
252+
.route(web::post().to(ingest::ingest).authorise(Action::Ingest))
246253
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE)),
247254
)
248255
// 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) {
254261
.service(
255262
// GET "/logstream" ==> Get list of all Log Streams on the server
256263
web::resource("")
257-
.route(web::get().to(logstream::list).auth(Action::ListStream)),
264+
.route(web::get().to(logstream::list).authorise(Action::ListStream)),
258265
)
259266
.service(
260267
// logstream API
@@ -277,19 +284,19 @@ pub fn metrics_path() -> String {
277284
}
278285

279286
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;
282289
}
283290

284291
impl RouteExt for Route {
285-
fn auth(self, action: Action) -> Self {
292+
fn authorise(self, action: Action) -> Self {
286293
self.wrap(Authorization {
287294
action,
288295
stream: false,
289296
})
290297
}
291298

292-
fn auth_stream(self, action: Action) -> Self {
299+
fn authorise_for_stream(self, action: Action) -> Self {
293300
self.wrap(Authorization {
294301
action,
295302
stream: true,

0 commit comments

Comments
 (0)