-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(jans-cedarling): Policy Store: Parse Schema and Policies #9575
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
97ea92a
feat(jans-cedarling): add PolicyStore and field schema. Also added de…
olehbozhok 7dac32a
test(jans-cedarling): add unit tests to check `parse_cedar_schema` (d…
olehbozhok e01bc54
docs(jans-cedarling): add docs for PolicyStore
olehbozhok 928b2bd
feat(jans-cedarling): add loading policy store based on config
olehbozhok bd0df57
feat(jans-cedarling): add loading policy store to Cedarling
olehbozhok 3449b60
chore(jans-cedarling): rename LogType to LogTypeConfig
olehbozhok 821cc2e
chore(jans-cedarling): fix `log_init` example after updating config
olehbozhok 5cd1c79
chore(jans-cedarling): add allow(dead_code) on schema
olehbozhok d29218e
chore(jans-cedarling): add copyright notice
olehbozhok 6b4ed70
docs(jans-cedarling): add README to init module
olehbozhok a1163bd
docs(jans-cedarling): add README to authz module
olehbozhok 8d8cf8b
chore(jans-cedarling): update message in ErrorLoadPolicyStore::MoreTh…
olehbozhok bf89da3
chore(jans-cedarling): add comments to Cedarling::new
olehbozhok b6dacac
chore(jans-cedarling): remove unnecessary code
olehbozhok 8cd92b3
docs(jans-cedarling): in README removed `Cedarling bindings` section
olehbozhok e724090
chore(jans-cedarling): move position of PolicyStoreMap to be first
olehbozhok cf20191
chore(jans-cedarling): refactor, move errors messages to the enum
olehbozhok df19054
Merge branch 'main' into jans-cedaling-issue-9568
moabu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 @@ | ||
# Auth Engine | ||
|
||
Part of Cedarling that main purpose is: | ||
|
||
- evaluate if authorization is granted for *user* | ||
- evaluate if authorization is granted for *client* |
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,7 @@ | ||
# Init engine | ||
|
||
Init engine is responsible for reading and loading entities on start of the application, like: | ||
|
||
- read boostrap properties | ||
- load Cedar Policies | ||
- get keys for JWT validation |
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,86 @@ | ||
/* | ||
* This software is available under the Apache-2.0 license. | ||
* See https://www.apache.org/licenses/LICENSE-2.0.txt for full text. | ||
* | ||
* Copyright (c) 2024, Gluu, Inc. | ||
*/ | ||
|
||
use base64::prelude::*; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum ParceCedarSchemaErrMsg { | ||
#[error("unable to decode cedar policy schema base64")] | ||
BASE64, | ||
#[error("unable to decode cedar policy schema json")] | ||
JSON, | ||
} | ||
|
||
/// A custom deserializer for Cedar's Schema. | ||
// | ||
// is used to deserialize field `schema` in `PolicyStore` | ||
pub(crate) fn parse_cedar_schema<'de, D>(deserializer: D) -> Result<cedar_policy::Schema, D::Error> | ||
where | ||
D: serde::Deserializer<'de>, | ||
{ | ||
let source = <String as serde::Deserialize>::deserialize(deserializer)?; | ||
let decoded: Vec<u8> = BASE64_STANDARD.decode(source.as_str()).map_err(|err| { | ||
serde::de::Error::custom(format!("{}: {}", ParceCedarSchemaErrMsg::BASE64, err,)) | ||
})?; | ||
|
||
let schema = cedar_policy::Schema::from_json_file(decoded.as_slice()).map_err(|err| { | ||
serde::de::Error::custom(format!("{}: {}", ParceCedarSchemaErrMsg::JSON, err)) | ||
})?; | ||
|
||
Ok(schema) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::models::policy_store::PolicyStoreMap; | ||
|
||
#[test] | ||
fn test_read_ok() { | ||
static POLICY_STORE_RAW: &str = include_str!("test_files/policy-store_ok.json"); | ||
|
||
let policy_result = serde_json::from_str::<PolicyStoreMap>(POLICY_STORE_RAW); | ||
assert!(policy_result.is_ok()); | ||
} | ||
|
||
#[test] | ||
fn test_read_base64_error() { | ||
static POLICY_STORE_RAW: &str = | ||
include_str!("test_files/policy-store_schema_err_base64.json"); | ||
|
||
let policy_result = serde_json::from_str::<PolicyStoreMap>(POLICY_STORE_RAW); | ||
assert!(policy_result | ||
.unwrap_err() | ||
.to_string() | ||
.contains(&ParceCedarSchemaErrMsg::BASE64.to_string())); | ||
} | ||
|
||
#[test] | ||
fn test_read_json_error() { | ||
static POLICY_STORE_RAW: &str = | ||
include_str!("test_files/policy-store_schema_err_json.json"); | ||
|
||
let policy_result = serde_json::from_str::<PolicyStoreMap>(POLICY_STORE_RAW); | ||
assert!(policy_result | ||
.unwrap_err() | ||
.to_string() | ||
.contains(&ParceCedarSchemaErrMsg::JSON.to_string())); | ||
} | ||
|
||
#[test] | ||
fn test_read_cedar_error() { | ||
static POLICY_STORE_RAW: &str = | ||
include_str!("test_files/policy-store_schema_err_cedar_mistake.json"); | ||
|
||
let policy_result = serde_json::from_str::<PolicyStoreMap>(POLICY_STORE_RAW); | ||
// in this scenario error message looks like: | ||
// `unable to decode cedar policy schema json: failed to resolve type: User_TypeNotExist", line: 35, column: 1` | ||
let err_msg = policy_result.unwrap_err().to_string(); | ||
assert!(err_msg.contains(&ParceCedarSchemaErrMsg::JSON.to_string())); | ||
assert!(err_msg.contains("failed to resolve type")); | ||
} | ||
} |
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,11 +1,14 @@ | ||
/* | ||
* This software is available under the Apache-2.0 license. | ||
* This software is available under the Apache-2.0 license. | ||
* See https://www.apache.org/licenses/LICENSE-2.0.txt for full text. | ||
* | ||
* Copyright (c) 2024, Gluu, Inc. | ||
* Copyright (c) 2024, Gluu, Inc. | ||
*/ | ||
//! # Init Engine | ||
//! Part of Cedarling that main purpose is: | ||
//! - read boostrap properties | ||
//! - load Cedar Policies | ||
//! - get keys for JWT validation | ||
|
||
pub(crate) mod cedar_schema; | ||
pub(crate) mod policy_store; |
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,58 @@ | ||
/* | ||
* This software is available under the Apache-2.0 license. | ||
* See https://www.apache.org/licenses/LICENSE-2.0.txt for full text. | ||
* | ||
* Copyright (c) 2024, Gluu, Inc. | ||
*/ | ||
|
||
use crate::models::policy_store::{PolicyStore, PolicyStoreMap}; | ||
use crate::models::policy_store_config::{PolicyStoreConfig, PolicyStoreSource}; | ||
|
||
/// Error cases for loading policy | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum ErrorLoadPolicyStore { | ||
#[error("{0}")] | ||
JsonParce(#[from] serde_json::Error), | ||
#[error("store policy is empty")] | ||
PolicyEmpty, | ||
#[error("the `store_key` is not specified and the count on policies more than 1")] | ||
MoreThanOnePolicy, | ||
#[error("could not found policy by id: {0}")] | ||
FindPolicy(String), | ||
} | ||
|
||
/// Load policy store based on config | ||
// | ||
// Unit tests will be added when will be implemented other types of sources | ||
pub(crate) fn load_policy_store( | ||
config: PolicyStoreConfig, | ||
) -> Result<PolicyStore, ErrorLoadPolicyStore> { | ||
let mut policy_store_map: PolicyStoreMap = match config.source { | ||
PolicyStoreSource::Json(json_raw) => serde_json::from_str(json_raw.as_str())?, | ||
}; | ||
|
||
let policy: PolicyStore = match (config.store_id, policy_store_map.policy_stores.len()) { | ||
(Some(store_id), _) => policy_store_map | ||
.policy_stores | ||
.remove(store_id.as_str()) | ||
.ok_or(ErrorLoadPolicyStore::FindPolicy(store_id))?, | ||
(None, 0) => { | ||
return Err(ErrorLoadPolicyStore::PolicyEmpty); | ||
}, | ||
(None, 1) => { | ||
// getting first element and we know it is save to use unwrap here, | ||
// because we know that there is only one element in the map | ||
policy_store_map | ||
.policy_stores | ||
.into_values() | ||
.into_iter() | ||
.next() | ||
.unwrap() | ||
}, | ||
(None, 2..) => { | ||
return Err(ErrorLoadPolicyStore::MoreThanOnePolicy); | ||
}, | ||
}; | ||
|
||
Ok(policy) | ||
} |
35 changes: 35 additions & 0 deletions
35
jans-cedarling/cedarling/src/init/test_files/policy-store_ok.json
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 @@ | ||
{ | ||
"8b805e22fdd39f3dd33a13d9fb446d8e6314153ca997": { | ||
"name": "gluustore", | ||
"description": "gluu", | ||
"policies": { | ||
"840da5d85403f35ea76519ed1a18a33989f855bf1cf8": { | ||
"description": "admin access", | ||
"creation_date": "2024-09-20T17:22:39.996050", | ||
"policy_content": "QGlkKCJhZG1pbiBhY2Nlc3MiKQpwZXJtaXQKKAogcHJpbmNpcGFsID09IEphbnM6OlJvbGU6OiJBZG1pbiIsCiBhY3Rpb24gaW4gW0phbnM6OkFjdGlvbjo6IkNvbXBhcmUiLEphbnM6OkFjdGlvbjo6IkV4ZWN1dGUiXSwKIHJlc291cmNlID09IEphbnM6OkFwcGxpY2F0aW9uOjoiQWRtaW4iCikKd2hlbgp7CiBKYW5zOjpBY2Nlc3NfdG9rZW46OiJhYmMiLnNjb3BlPT0iYWJjIiAmJiBKYW5zOjppZF90b2tlbjo6ImlkeHh4Ii5hbXI9PSJpZHh4eCIgIAp9Ow==" | ||
}, | ||
"b6313811924c9e67f898257cbf017674e08203779ae9": { | ||
"description": "manager access", | ||
"creation_date": "2024-09-20T18:11:26.442574", | ||
"policy_content": "QGlkKCJtYW5hZ2VyIGFjY2VzcyIpCnBlcm1pdAooCiBwcmluY2lwYWwsCiBhY3Rpb24sCiByZXNvdXJjZQopCndoZW4KewogSmFuczo6QWNjZXNzX3Rva2VuOjoieHh4Ii5zY29wZT09Inh4eCIgfHwgSmFuczo6aWRfdG9rZW46OiJpZHh4eCIuYW1yPT0iaWR4eHgiICYmIGNvbnRleHQubmV0d29yay5pc0luUmFuZ2UoaXAoIjIyMi4yMjIuMjIyLjAvMjQiKSkgIAp9Ow==" | ||
}, | ||
"f2b38413cad977ab21616bd4a63c233548491cf25b72": { | ||
"description": "manager access", | ||
"creation_date": "2024-09-20T18:11:37.774401", | ||
"policy_content": "QGlkKCJtYW5hZ2VyIGFjY2VzcyIpCnBlcm1pdAooCiBwcmluY2lwYWwsCiBhY3Rpb24sCiByZXNvdXJjZQopCndoZW4KewogSmFuczo6QWNjZXNzX3Rva2VuOjoieHh4Ii5zY29wZT09Inh4eCIgfHwgSmFuczo6aWRfdG9rZW46OiJpZHh4eCIuYW1yPT0iaWR4eHgiICYmIGNvbnRleHQubmV0d29yay5pc0luUmFuZ2UoaXAoIjIyMi4yMjIuMjIyLjAvMjQiKSkgIAp9Ow==" | ||
}, | ||
"fa6a3f46ab5f741e806deff0f81d0f848af37604500f": { | ||
"description": "without condition", | ||
"creation_date": "2024-09-22T18:18:35.801566", | ||
"policy_content": "QGlkKCJ3aXRob3V0IGNvbmRpdGlvbiIpCnBlcm1pdAooCiBwcmluY2lwYWwgPT0gSmFuczo6Um9sZTo6IkFkbWluIiwKIGFjdGlvbiwKIHJlc291cmNlCikKOw==" | ||
}, | ||
"96deb02f8ce44c46d497d44dbfec80b3b6a64fe22994": { | ||
"description": "forbid", | ||
"creation_date": "2024-09-23T14:51:21.480763", | ||
"policy_content": "QGlkKCJmb3JiaWQiKQpmb3JiaWQKKAogcHJpbmNpcGFsIGluIEphbnM6OlJvbGU6OiJBZG1pbiIsCiBhY3Rpb24gaW4gW0phbnM6OkFjdGlvbjo6IlNlYXJjaCIsSmFuczo6QWN0aW9uOjoiVGFnIl0sCiByZXNvdXJjZSBpbiBKYW5zOjpBcHBsaWNhdGlvbjo6IkFkbWluUG9ydGFsIgopCndoZW4KewogSmFuczo6QWNjZXNzX3Rva2VuOjoieHh4Ii5leHA+MTIzICYmIEphbnM6OkFjY2Vzc190b2tlbjo6ImFhYSIuZXhwPDMyMSB8fCBKYW5zOjpBY2Nlc3NfdG9rZW46OiJhYWEiLmlhdD49MTExICAKfTs=" | ||
} | ||
}, | ||
"identity_source": {}, | ||
"schema": "eyJKYW5zIjp7ImNvbW1vblR5cGVzIjp7IlVybCI6eyJ0eXBlIjoiUmVjb3JkIiwiYXR0cmlidXRlcyI6eyJob3N0Ijp7InR5cGUiOiJTdHJpbmcifSwicGF0aCI6eyJ0eXBlIjoiU3RyaW5nIn0sInByb3RvY29sIjp7InR5cGUiOiJTdHJpbmcifX19LCJDb250ZXh0Ijp7InR5cGUiOiJSZWNvcmQiLCJhdHRyaWJ1dGVzIjp7ImJyb3dzZXIiOnsidHlwZSI6IlN0cmluZyJ9LCJjdXJyZW50X3RpbWUiOnsidHlwZSI6IkxvbmcifSwiZGV2aWNlX2hlYWx0aCI6eyJ0eXBlIjoiU2V0IiwiZWxlbW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nsidHlwZSI6IkNvbnRleHQifX19LCJERUxFVEUiOnsiYXBwbGllc1RvIjp7InJlc291cmNlVHlwZXMiOlsiSFRUUF9SZXF1ZXN0Il0sInByaW5jaXBhbFR5cGVzIjpbIkNsaWVudCJdLCJjb250ZXh0Ijp7InR5cGUiOiJDb250ZXh0In19fSwiUE9TVCI6eyJhcHBsaWVzVG8iOnsicmVzb3VyY2VUeXBlcyI6WyJIVFRQX1JlcXVlc3QiXSwicHJpbmNpcGFsVHlwZXMiOlsiQ2xpZW50Il0sImNvbnRleHQiOnsidHlwZSI6IkNvbnRleHQifX19LCJIRUFEIjp7ImFwcGxpZXNUbyI6eyJyZXNvdXJjZVR5cGVzIjpbIkhUVFBfUmVxdWVzdCJdLCJwcmluY2lwYWxUeXBlcyI6WyJDbGllbnQiXSwiY29udGV4dCI6eyJ0eXBlIjoiQ29udGV4dCJ9fX0sIlBVVCI6eyJhcHBsaWVzVG8iOnsicmVzb3VyY2VUeXBlcyI6WyJIVFRQX1JlcXVlc3QiXSwicHJpbmNpcGFsVHlwZXMiOlsiQ2xpZW50Il0sImNvbnRleHQiOnsidHlwZSI6IkNvbnRleHQifX19LCJQQVRDSCI6eyJhcHBsaWVzVG8iOnsicmVzb3VyY2VUeXBlcyI6WyJIVFRQX1JlcXVlc3QiXSwicHJpbmNpcGFsVHlwZXMiOlsiQ2xpZW50Il0sImNvbnRleHQiOnsidHlwZSI6IkNvbnRleHQifX19LCJBY2Nlc3MiOnsiYXBwbGllc1RvIjp7InJlc291cmNlVHlwZXMiOlsiQXBwbGljYXRpb24iXSwicHJpbmNpcGFsVHlwZXMiOlsiVXNlciIsIlJvbGUiXSwiY29udGV4dCI6eyJ0eXBlIjoiQ29udGV4dCJ9fX19fX0=" | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
jans-cedarling/cedarling/src/init/test_files/policy-store_schema_err_base64.json
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 @@ | ||
{ | ||
"8b805e22fdd39f3dd33a13d9fb446d8e6314153ca997": { | ||
"name": "gluustore", | ||
"description": "gluu", | ||
"policies": { | ||
"840da5d85403f35ea76519ed1a18a33989f855bf1cf8": { | ||
"description": "admin access", | ||
"creation_date": "2024-09-20T17:22:39.996050", | ||
"policy_content": "QGlkKCJhZG1pbiBhY2Nlc3MiKQpwZXJtaXQKKAogcHJpbmNpcGFsID09IEphbnM6OlJvbGU6OiJBZG1pbiIsCiBhY3Rpb24gaW4gW0phbnM6OkFjdGlvbjo6IkNvbXBhcmUiLEphbnM6OkFjdGlvbjo6IkV4ZWN1dGUiXSwKIHJlc291cmNlID09IEphbnM6OkFwcGxpY2F0aW9uOjoiQWRtaW4iCikKd2hlbgp7CiBKYW5zOjpBY2Nlc3NfdG9rZW46OiJhYmMiLnNjb3BlPT0iYWJjIiAmJiBKYW5zOjppZF90b2tlbjo6ImlkeHh4Ii5hbXI9PSJpZHh4eCIgIAp9Ow==" | ||
}, | ||
"b6313811924c9e67f898257cbf017674e08203779ae9": { | ||
"description": "manager access", | ||
"creation_date": "2024-09-20T18:11:26.442574", | ||
"policy_content": "QGlkKCJtYW5hZ2VyIGFjY2VzcyIpCnBlcm1pdAooCiBwcmluY2lwYWwsCiBhY3Rpb24sCiByZXNvdXJjZQopCndoZW4KewogSmFuczo6QWNjZXNzX3Rva2VuOjoieHh4Ii5zY29wZT09Inh4eCIgfHwgSmFuczo6aWRfdG9rZW46OiJpZHh4eCIuYW1yPT0iaWR4eHgiICYmIGNvbnRleHQubmV0d29yay5pc0luUmFuZ2UoaXAoIjIyMi4yMjIuMjIyLjAvMjQiKSkgIAp9Ow==" | ||
}, | ||
"f2b38413cad977ab21616bd4a63c233548491cf25b72": { | ||
"description": "manager access", | ||
"creation_date": "2024-09-20T18:11:37.774401", | ||
"policy_content": "QGlkKCJtYW5hZ2VyIGFjY2VzcyIpCnBlcm1pdAooCiBwcmluY2lwYWwsCiBhY3Rpb24sCiByZXNvdXJjZQopCndoZW4KewogSmFuczo6QWNjZXNzX3Rva2VuOjoieHh4Ii5zY29wZT09Inh4eCIgfHwgSmFuczo6aWRfdG9rZW46OiJpZHh4eCIuYW1yPT0iaWR4eHgiICYmIGNvbnRleHQubmV0d29yay5pc0luUmFuZ2UoaXAoIjIyMi4yMjIuMjIyLjAvMjQiKSkgIAp9Ow==" | ||
}, | ||
"fa6a3f46ab5f741e806deff0f81d0f848af37604500f": { | ||
"description": "without condition", | ||
"creation_date": "2024-09-22T18:18:35.801566", | ||
"policy_content": "QGlkKCJ3aXRob3V0IGNvbmRpdGlvbiIpCnBlcm1pdAooCiBwcmluY2lwYWwgPT0gSmFuczo6Um9sZTo6IkFkbWluIiwKIGFjdGlvbiwKIHJlc291cmNlCikKOw==" | ||
}, | ||
"96deb02f8ce44c46d497d44dbfec80b3b6a64fe22994": { | ||
"description": "forbid", | ||
"creation_date": "2024-09-23T14:51:21.480763", | ||
"policy_content": "QGlkKCJmb3JiaWQiKQpmb3JiaWQKKAogcHJpbmNpcGFsIGluIEphbnM6OlJvbGU6OiJBZG1pbiIsCiBhY3Rpb24gaW4gW0phbnM6OkFjdGlvbjo6IlNlYXJjaCIsSmFuczo6QWN0aW9uOjoiVGFnIl0sCiByZXNvdXJjZSBpbiBKYW5zOjpBcHBsaWNhdGlvbjo6IkFkbWluUG9ydGFsIgopCndoZW4KewogSmFuczo6QWNjZXNzX3Rva2VuOjoieHh4Ii5leHA+MTIzICYmIEphbnM6OkFjY2Vzc190b2tlbjo6ImFhYSIuZXhwPDMyMSB8fCBKYW5zOjpBY2Nlc3NfdG9rZW46OiJhYWEiLmlhdD49MTExICAKfTs=" | ||
} | ||
}, | ||
"identity_source": {}, | ||
"schema": "ewogICJKYW...gfQp9" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than creating different enums for showing error messages, can we just make a single enum for all error messages inside
\jans-cedarling\cedarling\src\models\enum\error
.for Example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea to return the error struct in functions that cover all possible error cases for only the current situation. Because it will be easier to maintain when application grows.
And If we have somethinglike
CedarlingApplicationError
It will have all possible errors for all application.
And when we will be wanted to handle the error cases with match statement, it will be hard to understand what exactly cases current function returns. Because
CedarlingApplicationError
have all possible cases in the application.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what we practise in most of applications. We do not clutter our project with multiple Enums for error messages.
The naming convention of enum items should be sufficient of make its purpose clear. We don't need to make multiple error enums for this.
And I could see
ErrorLoadPolicyStore
in cedar_schem.rs and policy_store.rs. Code duplication does not make sense.