Skip to content

Commit

Permalink
Add missing permissions utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
marcua committed Nov 1, 2023
1 parent db341c2 commit 2130a8a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/http/permissions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::ayb_db::models::{InstantiatedDatabase, InstantiatedEntity};

pub fn can_create_database(
authenticated_entity: &InstantiatedEntity,
desired_entity: &InstantiatedEntity,
) -> bool {
// An entity/user can only create databases on itself (for now)
return authenticated_entity.id == desired_entity.id;
}

pub fn can_query(
authenticated_entity: &InstantiatedEntity,
database: &InstantiatedDatabase,
) -> bool {
// An entity/user can only query its own databases (for now)
return authenticated_entity.id == database.entity_id;
}

0 comments on commit 2130a8a

Please sign in to comment.