Skip to content

Commit

Permalink
Fix authorization check for CrudCode (#431)
Browse files Browse the repository at this point in the history
* Fix authorization check for CrudCode

Make all mutating SQL operations require the caller to be the database
owner.

* Add auth check tests + ensure all tables in a join are considered
  • Loading branch information
kim authored Oct 16, 2023
1 parent 6715b4c commit 41f9fac
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 59 deletions.
2 changes: 2 additions & 0 deletions crates/lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ pub enum AuthError {
IndexPrivate { named: String },
#[error("Sequence `{named}` is private")]
SequencePrivate { named: String },
#[error("Only the database owner can perform the requested operation")]
OwnerRequired,
}

#[derive(thiserror::Error, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Identity {
const ABBREVIATION_LEN: usize = 16;

/// Returns an `Identity` defined as the given `bytes` byte array.
pub fn from_byte_array(bytes: [u8; 32]) -> Self {
pub const fn from_byte_array(bytes: [u8; 32]) -> Self {
Self {
__identity_bytes: bytes,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ impl Relation for DbTable {
}
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Eq, PartialEq, From)]
pub enum Table {
MemTable(MemTable),
DbTable(DbTable),
Expand Down
Loading

0 comments on commit 41f9fac

Please sign in to comment.