-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce basic label generation, qr generation, and engine logic
- Loading branch information
Showing
16 changed files
with
1,279 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"vsicons.associations.folders": [ | ||
{ "icon": "engine", "extensions": ["engine"], "format": "svg" } | ||
], | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ use tracing::info; | |
|
||
mod router; | ||
mod state; | ||
mod permissions; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use crate::permissions::rule::{PermissionedEntity, Rule, RuleOutput}; | ||
|
||
/** | ||
* | ||
* Examples rules for permissions (impl Rule): | ||
* - byOrg(ruleOutput, org) | ||
* - byUser(ruleOutput, user) | ||
* - byGroup(ruleOutput, group) | ||
* | ||
*/ | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ByOrgRule { | ||
pub rule_output: RuleOutput, | ||
pub org: String, | ||
} | ||
|
||
impl Rule for ByOrgRule { | ||
fn check(&self, entity: PermissionedEntity) -> RuleOutput { | ||
match entity { | ||
PermissionedEntity::Organization(org) => { | ||
if org == self.org { | ||
self.rule_output | ||
} | ||
else { | ||
RuleOutput::PASSTHROUGH | ||
} | ||
}, | ||
_ => RuleOutput::PASSTHROUGH, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_by_org_rule() { | ||
let rule = ByOrgRule { | ||
rule_output: RuleOutput::READ, | ||
org: "test".to_string(), | ||
}; | ||
|
||
let entity = PermissionedEntity::Organization("test".to_string()); | ||
assert_eq!(rule.check(entity), RuleOutput::READ); | ||
|
||
let entity = PermissionedEntity::Organization("other".to_string()); | ||
assert_eq!(rule.check(entity), RuleOutput::NONE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod rule; | ||
mod default_rules; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#[derive(Debug, Clone, Copy, PartialEq)] | ||
pub enum RuleOutput { | ||
DISSALOW, | ||
READ, | ||
WRITE, | ||
PASSTHROUGH, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum PermissionedEntity { | ||
Organization(String), | ||
User(String), | ||
Group(String), | ||
} | ||
|
||
pub trait Rule { | ||
fn check(&self, entity: PermissionedEntity) -> RuleOutput; | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.