Skip to content

Commit 768998f

Browse files
committed
make check_program_auth async too
1 parent 045bef9 commit 768998f

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

libsql-server/src/connection/libsql.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ where
415415

416416
PROGRAM_EXEC_COUNT.increment(1);
417417

418-
check_program_auth(&ctx, &pgm, &self.inner.lock().config_store.get())?;
418+
let config = self.inner.lock().config_store.get();
419+
check_program_auth(&ctx, &pgm, &config).await?;
419420

420421
// create the bomb right before spawning the blocking task.
421422
let mut bomb = Bomb {

libsql-server/src/connection/program.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ fn value_size(val: &rusqlite::types::ValueRef) -> usize {
341341
}
342342
}
343343

344-
pub fn check_program_auth(
344+
pub async fn check_program_auth(
345345
ctx: &RequestContext,
346346
pgm: &Program,
347347
config: &DatabaseConfig,
@@ -363,15 +363,11 @@ pub fn check_program_auth(
363363
}
364364
StmtKind::Attach(ref ns) => {
365365
ctx.auth.has_right(ns, Permission::AttachRead)?;
366-
return tokio::runtime::Handle::current().block_on(async {
367-
if !ctx.meta_store.handle(ns.clone()).await.get().allow_attach {
368-
return Err(Error::NotAuthorized(format!(
369-
"Namespace `{ns}` doesn't allow attach"
370-
)));
371-
} else {
372-
Ok(())
373-
}
374-
});
366+
if !ctx.meta_store.handle(ns.clone()).await.get().allow_attach {
367+
return Err(Error::NotAuthorized(format!(
368+
"Namespace `{ns}` doesn't allow attach"
369+
)));
370+
}
375371
}
376372
StmtKind::Detach => (),
377373
}

libsql-server/src/database/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl crate::connection::Connection for SchemaConnection {
5050

5151
res
5252
} else {
53-
check_program_auth(&ctx, &migration, &self.config.get())?;
53+
check_program_auth(&ctx, &migration, &self.config.get()).await?;
5454
let connection = self.connection.clone();
5555
validate_migration(&mut migration)?;
5656
let migration = Arc::new(migration);

0 commit comments

Comments
 (0)