Skip to content

Commit 6ebe5bc

Browse files
authored
assign perms for about and llm api (#495)
This PR adds permissions to the new about API and the LLM call API.
1 parent 4e789b2 commit 6ebe5bc

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

server/src/handlers/http.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
235235
web::resource("").route(
236236
web::post()
237237
.to(llm::make_llm_request)
238-
.authorize(Action::Query),
238+
.authorize(Action::QueryLLM),
239239
),
240240
);
241241

@@ -263,7 +263,10 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
263263
// GET "/readiness" ==> Readiness check as per https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes
264264
.service(web::resource("/readiness").route(web::get().to(health_check::readiness)))
265265
// GET "/about" ==> Returns information about instance
266-
.service(web::resource("/about").route(web::get().to(about::about)))
266+
.service(
267+
web::resource("/about")
268+
.route(web::get().to(about::about).authorize(Action::GetAbout)),
269+
)
267270
.service(
268271
web::scope("/logstream")
269272
.service(

server/src/rbac/role.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ pub enum Action {
3636
DeleteUser,
3737
PutRoles,
3838
GetRole,
39+
GetAbout,
40+
QueryLLM,
3941
All,
4042
}
4143

@@ -91,6 +93,8 @@ impl RoleBuilder {
9193
Action::PutRoles => Permission::Unit(action),
9294
Action::GetRole => Permission::Unit(action),
9395
Action::DeleteUser => Permission::Unit(action),
96+
Action::GetAbout => Permission::Unit(action),
97+
Action::QueryLLM => Permission::Unit(action),
9498
Action::All => Permission::Stream(action, self.stream.clone().unwrap()),
9599
};
96100
perms.push(perm);
@@ -155,6 +159,8 @@ pub mod model {
155159
Action::PutRetention,
156160
Action::PutAlert,
157161
Action::GetAlert,
162+
Action::GetAbout,
163+
Action::QueryLLM,
158164
],
159165
stream: Some("*".to_string()),
160166
tag: None,
@@ -172,6 +178,8 @@ pub mod model {
172178
Action::GetRetention,
173179
Action::PutAlert,
174180
Action::GetAlert,
181+
Action::GetAbout,
182+
Action::QueryLLM,
175183
],
176184
stream: None,
177185
tag: None,
@@ -187,6 +195,8 @@ pub mod model {
187195
Action::GetStats,
188196
Action::GetRetention,
189197
Action::GetAlert,
198+
Action::GetAbout,
199+
Action::QueryLLM,
190200
],
191201
stream: None,
192202
tag: None,

0 commit comments

Comments
 (0)