-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: new command traits and generated code
- Loading branch information
Showing
10 changed files
with
310 additions
and
12 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
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
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
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,35 @@ | ||
use crate::acl::PermissionId; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct CapabilityId { | ||
inner: String, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
|
||
pub struct CapabilitySet { | ||
inner: Vec<Capability>, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct Capability { | ||
identifier: CapabilityId, | ||
description: String, | ||
#[serde(default)] | ||
context: CapabilityContext, | ||
windows: Vec<String>, | ||
permissions: Vec<PermissionId>, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub enum CapabilityContext { | ||
Local, | ||
Remote { dangerous_remote: Vec<String> }, | ||
} | ||
|
||
impl Default for CapabilityContext { | ||
fn default() -> Self { | ||
Self::Local | ||
} | ||
} |
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
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,45 @@ | ||
use matchit::Router; | ||
use serde::de::DeserializeOwned; | ||
use serde::{Deserialize, Serialize}; | ||
use std::collections::BTreeMap; | ||
|
||
/// TODO: the current proof of concept uses [`matchit`], but we should use a simplified | ||
/// router router that __only__ supports static and wildcard values (without wildcard params) | ||
pub struct WindowMatcher { | ||
inner: Router<String>, | ||
} | ||
|
||
pub struct WindowMatch { | ||
inner: BTreeMap<String, ResolvedCommand>, | ||
} | ||
|
||
pub enum ResolvedCommand { | ||
Deny, | ||
Allow(ResolvedScopes<serde_json::Value>), | ||
} | ||
|
||
pub enum ScopeKind<'de, T> | ||
where | ||
T: Serialize + Deserialize<'de>, | ||
{ | ||
Allow(&'de T), | ||
Deny(&'de T), | ||
} | ||
|
||
pub struct ResolvedScopes<T> | ||
where | ||
T: Serialize, | ||
for<'de> T: Deserialize<'de>, | ||
{ | ||
allow: Vec<T>, | ||
deny: Vec<T>, | ||
} | ||
|
||
impl<T> ResolvedScopes<T> | ||
where | ||
T: Serialize + DeserializeOwned, | ||
for<'de> T: Deserialize<'de>, | ||
{ | ||
} | ||
|
||
pub struct Resolved {} |
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
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
Oops, something went wrong.