-
Notifications
You must be signed in to change notification settings - Fork 84
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)!: move TOKEN_CONFIGS into the token_metadata schema #10972
base: main
Are you sure you want to change the base?
Conversation
add required_claims, entity_type_name, entity mapping to TokenEntityMetadata Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
the following tests: - test_failed_user_mapping - test_failed_workload_mapping - test_failed_access_token_mapping - test_failed_id_token_mapping - test_failed_userinfo_token_mapping were removed since they are practically testing the same thing as the following but with a more complex setup: - can_build_entity_using_jwt - errors_when_entity_not_in_schema Signed-off-by: rmarinn <[email protected]>
…roperty 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]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
…expr Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
… schema - also implement building TrustedIssuerEntity Signed-off-by: rmarinn <[email protected]>
mappings are already tested in the entity_builder module so there's no need to test the same thing in mapping_entities.rs which creates a whole cedarling instance and request just to test mappings. Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
- fix policy tests the broke because of the entity builder refactor 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]>
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]>
Signed-off-by: rmarinn <[email protected]>
Signed-off-by: rmarinn <[email protected]>
- update description for user_id - update description for workload_id Signed-off-by: rmarinn <[email protected]>
note that we might need to move the |
- add test for building User entity without roles - add test for building token entity without a TrustedIssuer Entity Signed-off-by: rmarinn <[email protected]>
jans-cedarling/cedarling/examples/authorize_with_jwt_validation.rs
Outdated
Show resolved
Hide resolved
jans-cedarling/cedarling/examples/authorize_without_jwt_validation.rs
Outdated
Show resolved
Hide resolved
@@ -72,6 +128,10 @@ impl ClaimMapping { | |||
}, | |||
} | |||
} | |||
|
|||
pub fn apply_mapping_value(&self, value: &serde_json::Value) -> serde_json::Value { | |||
json!(self.apply_mapping(value)) |
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.
What happens on error case?
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.
panics.
...but this will never happen since we already deserialized the mappings from JSON when we parsed them on startup so why would it become suddenly invalid JSON?
@@ -142,7 +110,10 @@ macro_rules! cmp_policy { | |||
|
|||
/// util function for convenient conversion Decision | |||
pub fn get_decision(resp: &Option<cedar_policy::Response>) -> Option<cedar_policy::Decision> { | |||
resp.as_ref().map(|v| v.decision()) | |||
resp.as_ref().map(|v| { | |||
println!("diagnostics: {:?}\n", v.diagnostics()); |
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.
Don't forget to remove println
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.
that's in the test utils.
i intentionally left that there because i couldn't figure out what was happening if the tests fails as the error messages aren't really helpful.
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]>
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]>
Prepare
Description
This PR moves token-to-entity mappings and token validation settings from the bootstrap properties into the policy store. This change centralizes configuration, simplifying token metadata management.
Target issue
closes #10888
Implementation Details
The
CEDARLING_TOKEN_CONFIGS
bootstrap property has been removed. The entity type name and the validation configs should now be configured via the updated token entity metadata schema (TEMS).Creation of the
Jans::TrustedIssuer
entity has been implemented.Renamed
Jans::id_token
toJans::Id_token
to be more consistent withJans::Access_token
andJans::Userinfo_token
.Started using JSON Schema instead of examples for defining the Json Schema
The
CEDARLING_TOKEN_CONFIGS
bootstrap property has been removed. Entity type names and validation configurations should now be defined using the updated Token Entity Metadata Schema (TEMS).Added support for creating the
Jans::TrustedIssuer
entity, which represents external identity providers (IDPs) that Cedarling can trust.Renamed the
Jans::id_token
entity toJans::Id_token
to align better with the existing naming convention used forJans::Access_token
andJans::Userinfo_token
.Replaced informal examples with JSON Schema definitions for improved validation, consistency, and documentation.
Updated Token Entity Metadata Schema
Below is the updated Token Entity Metadata Schema written in the JSON Schema specification defined at. For the full schema, see the following section.
entity_type_name
field used to specify the entity type name of the token entity that will be created for the given token.principal_identifier
which was used to determine the claim used as the token entity's ID has been renamed totoken_id
.workload_id
field used to specify which claim will be used to create the Workload entity.Below is a non-normative example of a JSON object that adheres to the updated
tokens_metadata
.Full Updated Policy Store Schema
This PR required significant updates to the policy store structure, which impacted a large number of tests. To ensure compatibility with existing policies and avoid introducing breaking changes, I had to review and validate many tests and pre-existing policies.
Manually verifying all these cases is both time-consuming and error-prone, increasing the risk of missing updates or inconsistencies. To address this, I propose that we adopt a formal JSON Schema definition for Cedarling’s policy store. JSON Schema provides a standard way to define, validate, and document our data structure, ensuring consistency across tests, examples, and future updates.
The official JSON Schema specification can be found at: https://json-schema.org.
For convenience, I’ve included the full JSON Schema for Cedarling’s policy store below. You can validate policy store documents using online tools such as https://www.jsonschemavalidator.net/.
This schema will also be stored in the repository at:
/jans/jans-cedarling/schema/cedarling_store_schema.json
.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.