-
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.
Formalize generated policy, preparing user role
- Completely refactor of all relevant structs, renaming them more appropriately, and moved into their own module. - Include a new user role relationship, which represents the role that the user has at the system, such that when a resource is at a workflow state, the permissions associated with that role associated with that state will become activated for the user. - Clarified that Reviewer role doesn't need the global role by default at the base model level, as that type of grant is wider than what was intended. With the user role being defined this type of grant is much better fit for that, and will achieve the goal of enabling the access whenever ``State::Pending`` is set for those resources. - Various backend methods have been renamed to be more precise. - Still need to provide backend methods for management of user roles.
- Loading branch information
1 parent
054deb0
commit 78a8001
Showing
11 changed files
with
382 additions
and
189 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod agent; | ||
pub mod genpolicy; | ||
pub mod permit; | ||
pub mod role; | ||
pub mod traits; | ||
|
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,47 @@ | ||
//! Generated Policy | ||
//! | ||
//! The structs provided by this module represents policies generated | ||
//! for consumption by some security enforcer, and is not meant to be | ||
//! persisted in some datastore. | ||
use serde::{Deserialize, Serialize}; | ||
use crate::ac::role::Role; | ||
|
||
/// Grants, roles and permissions associated with the given resource | ||
/// to be passed into the security enforcer as a complete policy. | ||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
pub struct Policy { | ||
pub resource: String, | ||
pub user_roles: Vec<UserRole>, | ||
pub res_grants: Vec<ResGrant>, | ||
pub role_permits: Vec<RolePermit>, | ||
} | ||
|
||
/// A resource grant - the agent will have the stated role at the given | ||
/// resource. | ||
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Deserialize, Serialize)] | ||
pub struct ResGrant { | ||
// this may feel redundant later, but this line signifies the exact | ||
// res this was granted for, which may be at a higher level. | ||
pub res: String, | ||
pub agent: Option<String>, | ||
pub role: Role, | ||
} | ||
|
||
/// This represents the endpoint_group and HTTP method that the role is | ||
/// given the permit for. | ||
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Deserialize, Serialize)] | ||
pub struct RolePermit { | ||
pub role: Role, | ||
pub endpoint_group: String, | ||
pub method: String, | ||
} | ||
|
||
/// Represents the role granted to the user for the system. Roles | ||
/// granted this way is only applicable for resources at some | ||
/// appropriate state. | ||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
pub struct UserRole { | ||
pub user: String, | ||
pub role: Role, | ||
} |
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
26 changes: 26 additions & 0 deletions
26
pmrmodel/.sqlx/query-e3572c1a4e184b624955de0ca48872eaee5226bba34a7194cd7a90e8b058f3e6.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.