From 4b055ec0f63b1415a25eaee697b7735380454724 Mon Sep 17 00:00:00 2001 From: Satyam Singh Date: Tue, 12 Sep 2023 12:44:29 +0530 Subject: [PATCH] Assign perms for about and llm api --- server/src/handlers/http.rs | 7 +++++-- server/src/rbac/role.rs | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/server/src/handlers/http.rs b/server/src/handlers/http.rs index 1ccde0830..d809f883c 100644 --- a/server/src/handlers/http.rs +++ b/server/src/handlers/http.rs @@ -235,7 +235,7 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) { web::resource("").route( web::post() .to(llm::make_llm_request) - .authorize(Action::Query), + .authorize(Action::QueryLLM), ), ); @@ -263,7 +263,10 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) { // GET "/readiness" ==> Readiness check as per https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes .service(web::resource("/readiness").route(web::get().to(health_check::readiness))) // GET "/about" ==> Returns information about instance - .service(web::resource("/about").route(web::get().to(about::about))) + .service( + web::resource("/about") + .route(web::get().to(about::about).authorize(Action::GetAbout)), + ) .service( web::scope("/logstream") .service( diff --git a/server/src/rbac/role.rs b/server/src/rbac/role.rs index 786df8eeb..5420b0f7f 100644 --- a/server/src/rbac/role.rs +++ b/server/src/rbac/role.rs @@ -36,6 +36,8 @@ pub enum Action { DeleteUser, PutRoles, GetRole, + GetAbout, + QueryLLM, All, } @@ -91,6 +93,8 @@ impl RoleBuilder { Action::PutRoles => Permission::Unit(action), Action::GetRole => Permission::Unit(action), Action::DeleteUser => Permission::Unit(action), + Action::GetAbout => Permission::Unit(action), + Action::QueryLLM => Permission::Unit(action), Action::All => Permission::Stream(action, self.stream.clone().unwrap()), }; perms.push(perm); @@ -155,6 +159,8 @@ pub mod model { Action::PutRetention, Action::PutAlert, Action::GetAlert, + Action::GetAbout, + Action::QueryLLM, ], stream: Some("*".to_string()), tag: None, @@ -172,6 +178,8 @@ pub mod model { Action::GetRetention, Action::PutAlert, Action::GetAlert, + Action::GetAbout, + Action::QueryLLM, ], stream: None, tag: None, @@ -187,6 +195,8 @@ pub mod model { Action::GetStats, Action::GetRetention, Action::GetAlert, + Action::GetAbout, + Action::QueryLLM, ], stream: None, tag: None,