Skip to content

Commit 90a44d6

Browse files
authored
fix: allow only GET /logstream in query mode (#643)
Previously in Query Mode, All log stream endpoints were allowed. But is it better that only ingester is allowed to create streams. Fixes #641
1 parent 7b1e9dd commit 90a44d6

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

server/src/handlers/http/middleware.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,23 @@ where
299299
fn call(&self, req: ServiceRequest) -> Self::Future {
300300
let path = req.path();
301301
let mode = &CONFIG.parseable.mode;
302-
303302
// change error messages based on mode
304303
match mode {
305304
Mode::Query => {
306-
let cond = path.split('/').any(|x| x == "ingest");
307-
if cond {
305+
// In Query mode, only allows /ingest endpoint, and /logstream endpoint with GET method
306+
let base_cond = path.split('/').any(|x| x == "ingest");
307+
let logstream_cond =
308+
!(path.split('/').any(|x| x == "logstream") && req.method() == "GET");
309+
if base_cond {
310+
Box::pin(async {
311+
Err(actix_web::error::ErrorUnauthorized(
312+
"Ingestion API cannot be accessed in Query Mode",
313+
))
314+
})
315+
} else if logstream_cond {
308316
Box::pin(async {
309317
Err(actix_web::error::ErrorUnauthorized(
310-
"Ingest API cannot be accessed in Query Mode",
318+
"Logstream cannot be changed in Query Mode",
311319
))
312320
})
313321
} else {

0 commit comments

Comments
 (0)