Skip to content
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

Implement RFC 55 #983

Merged
merged 2 commits into from
Jun 19, 2024
Merged

Implement RFC 55 #983

merged 2 commits into from
Jun 19, 2024

Conversation

aaronjeline
Copy link
Contributor

@aaronjeline aaronjeline commented Jun 13, 2024

Description of changes

(partially) Implements RFC 55
This does not implement the backwards compatibility functions, saving that for a second PR as this one is already large.

Issue #, if available

N/A

Checklist for requesting a review

The change in this PR is (choose one, and delete the other options):

  • A breaking change requiring a major version bump to cedar-policy (e.g., changes to the signature of an existing API).

I confirm that this PR (choose one, and delete the other options):

  • Updates the "Unreleased" section of the CHANGELOG with a description of my change (required for major/minor version bumps).

I confirm that cedar-spec (choose one, and delete the other options):

  • Does not require updates because my change does not impact the Cedar formal model or DRT infrastructure.

@aaronjeline aaronjeline force-pushed the aeline/rfc55 branch 2 times, most recently from 029038f to 3536e78 Compare June 14, 2024 13:44
@aaronjeline
Copy link
Contributor Author

Note: one integration test will need change

Copy link
Contributor

@khieta khieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple comments -- more will come later. I've decided to work on this review in parts.

cedar-policy-core/src/ast/policy.rs Outdated Show resolved Hide resolved
cedar-policy-core/src/ast/policy.rs Outdated Show resolved Hide resolved
cedar-policy/src/ffi/is_authorized.rs Outdated Show resolved Hide resolved
cedar-policy/src/api.rs Outdated Show resolved Hide resolved
cedar-policy-core/src/ast/entity.rs Outdated Show resolved Hide resolved
cedar-policy-core/src/ast/entity.rs Show resolved Hide resolved
cedar-policy-core/src/ast/entity.rs Outdated Show resolved Hide resolved
cedar-policy-core/src/ast/entity.rs Outdated Show resolved Hide resolved
cedar-policy/CHANGELOG.md Outdated Show resolved Hide resolved
@khieta khieta mentioned this pull request Jun 14, 2024
3 tasks
Copy link
Contributor

@khieta khieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more comments. I'll wait until Monday to look at the rest of the validator code 😅 Great to see all this special casing for unspecified entities disappear!

cedar-policy-validator/src/coreschema.rs Outdated Show resolved Hide resolved
cedar-policy-validator/src/human_schema/err.rs Outdated Show resolved Hide resolved
cedar-policy-validator/src/human_schema/test.rs Outdated Show resolved Hide resolved
cedar-policy/CHANGELOG.md Show resolved Hide resolved
cedar-policy/tests/public_interface.rs Outdated Show resolved Hide resolved
None,
Some(resource.clone()),
principal.clone(),
r#"__cedar::"Default""#.parse().unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to work with RFC52?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses __cedar?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we decide the interactions of those RFCs? I.e., whether __cedar::Default will be one of the allowed uses of the __cedar namespace (like __cedar::Long)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has to be or we need to change the RFC. I was assuming it was because otherwise that part of the RFC doesn't make sense in the context of 52

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __cedar syntax if only mentioned in the Alternatives section of RFC 55, not in the main proposal. But the intention in the alternatives was that __cedar::Default would be builtin the same way as __cedar::Long.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Regardless, I think it should be removed from the tests here since we decided not to support it as part of RFC 55.)

@@ -219,11 +219,11 @@ fn authorize_custom_request() -> Result<(), Box<dyn Error>> {
Decision::Allow
);

// Requesting with an unspecified principal or resource will return Deny (but not fail)
// Requesting with default principal or resource will return Deny (but not fail)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test also makes it seem like __cedar::"Default" is something special. Are these tests really testing something interesting? I suspect they could be removed in favor of existing tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, I think it's nice to have a confirmation our migration suggestion is breaking anything

Copy link
Contributor

@khieta khieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final batch of comments from me! I'll approve once my comments are addressed & you have a draft of the corresponding cedar-spec PR to fix DRT.

cedar-policy-validator/src/human_schema/to_json_schema.rs Outdated Show resolved Hide resolved
cedar-policy-validator/src/human_schema/err.rs Outdated Show resolved Hide resolved
cedar-policy-validator/src/rbac.rs Outdated Show resolved Hide resolved
cedar-policy-validator/src/typecheck.rs Outdated Show resolved Hide resolved
@aaronjeline
Copy link
Contributor Author

Draft pr for cedar-integration-tests: cedar-policy/cedar-integration-tests#6

cedar-policy-cli/src/lib.rs Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tagging @shaobo-he-aws to review the changes to this file and other human-schema related files.

@@ -21,17 +21,17 @@ use cedar_policy_core::parser::{Node, Loc, unescape::to_unescaped_string, cst::R
use cedar_policy_core::ast::Id;
use smol_str::SmolStr;
use smol_str::ToSmolStr;
use crate::human_schema::ast::{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to split this white space fix into a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh I think my editor did that automatically

None,
Some(resource.clone()),
principal.clone(),
r#"__cedar::"Default""#.parse().unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses __cedar?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fold this in with the other schema parsing tests. It's doesn't test typechecking at all anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be tests that do when I add the backwards compat methods

cedar-policy/CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@cdisselkoen cdisselkoen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this PR and RFC, from the implementation perspective. So many of these changes make things simpler.

cedar-policy-cli/src/lib.rs Show resolved Hide resolved
cedar-policy-core/src/ast/entity.rs Outdated Show resolved Hide resolved
cedar-policy-core/src/ast/entity.rs Outdated Show resolved Hide resolved
cedar-policy-core/src/est/expr.rs Outdated Show resolved Hide resolved
cedar-policy-core/src/est/scope_constraints.rs Outdated Show resolved Hide resolved
cedar-policy-validator/src/schema/namespace_def.rs Outdated Show resolved Hide resolved
cedar-policy-validator/src/schema/namespace_def.rs Outdated Show resolved Hide resolved
cedar-policy/src/ffi/is_authorized.rs Outdated Show resolved Hide resolved
cedar-policy/src/ffi/is_authorized.rs Outdated Show resolved Hide resolved
None,
Some(resource.clone()),
principal.clone(),
r#"__cedar::"Default""#.parse().unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we decide the interactions of those RFCs? I.e., whether __cedar::Default will be one of the allowed uses of the __cedar namespace (like __cedar::Long)?

@aaronjeline
Copy link
Contributor Author

DRT PR: cedar-policy/cedar-spec#366

Co-authored-by: Kesha Hietala <khieta@amazon.com>
Co-authored-by: John Kastner <130772734+john-h-kastner-aws@users.noreply.github.com>
Co-authored-by: Craig Disselkoen <cdiss@amazon.com>
Signed-off-by: Aaron Eline <aeline+github@amazon.com>
@khieta
Copy link
Contributor

khieta commented Jun 18, 2024

Only remaining comment from me is that you're using __cedar::Default in some tests. This will not be supported with the implementation of RFC52 -- these can be added as tests when implementing that RFC. I don't think they should be added here.

Copy link
Contributor

@shaobo-he-aws shaobo-he-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shaobo-he-aws
Copy link
Contributor

Only remaining comment from me is that you're using __cedar::Default in some tests. This will not be supported with the implementation of RFC52 -- these can be added as tests when implementing that RFC. I don't think they should be added here.

I think we can keep these tests. I'll add them to my PR implementing RFC 52 when I sync it with main.

Signed-off-by: Aaron Eline <aeline+github@amazon.com>
@aaronjeline aaronjeline merged commit afd99f2 into main Jun 19, 2024
10 of 17 checks passed
@aaronjeline aaronjeline deleted the aeline/rfc55 branch June 20, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants