-
Notifications
You must be signed in to change notification settings - Fork 79
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
refactor(jans-cedarling): enhance schema parser and entity creation implementation #10549
Conversation
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
…Kind::Record Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
- implement an entity builder can can make workload entities Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
- implement EntityBuilder::build_entities which builds all the cedarling-specific entities Signed-off-by: rmarinn <[email protected]>
- start using the new CedarJsonSchema - start using EntityBuilder to build entities Signed-off-by: rmarinn <[email protected]>
- make the default type "EntityOrCommon" for unknown variants instead of failing desrialization. Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
- fix the bug where the access_token is being used to create all token entities Signed-off-by: rmarinn <[email protected]>
- fix CommonType contexts not being handled properly Signed-off-by: rmarinn <[email protected]>
- fix entity references within entities not being qualified; i.e. the namespace is not included in the reference... which causes problems down the line Signed-off-by: rmarinn <[email protected]>
- refactor role entities creation to not fail if no role entities were created but just return an empty Vec Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
- silently fail non-required attr creation errors since it was making an existing test fail: "check_mapping_tokens_data" Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
I had to resolve merge conflicts with the WASM PR so could you re-review @olehbozhok |
if regex_mapping.cedar_policy_type == type_name { | ||
Some((claim_name, mapping)) | ||
} else { | ||
None | ||
} |
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.
(regex_mapping.cedar_policy_type == type_name).then_some((claim_name, mapping))
is quite a nice way to do it.
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.
fixed here bd58549
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'm not clear whether or not serde is inadequate to parse the json schema files. But it seems others are waiting for this PR.
Signed-off-by: rmarinn <[email protected]>
I'm not sure what you mean. I did used serde to parse the json schema files -- though we needed to add some since just because it's a valid json it doesn't mean that it's a valid schema as described in the cedar policy docs. |
Prepare
Description
This PR refactors the JSON schema struct and the Cedar entity-building logic to improve code readability and maintainability.
Target issue
target issue: #10513
closes #10513
Implementation Details
Introduction of
EntityBuilder
StructEntityBuilder
struct encapsulates configuration and logic for creating entities.Refactoring
CedarSchemaJson
CedarSchemaJson
struct has been redesigned for better usability.Unit Tests
Improved Automatically adding entities to the context
Entity Builder
The
EntityBuilder
struct centralizes entity creation logic and holds configuration on initialization.Usage:
Function implementations on this struct will have the entity creation code. Other modules will only have to use these functions.
Test and Document the changes
Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with
docs:
to indicate documentation changes or if the below checklist is not selected.