cedar-policy / cedar-go

Apache License 2.0
44 stars 7 forks source link

Convert a JSON Policy to its Textual representation #15

Closed suchiksagar closed 1 month ago

suchiksagar commented 1 month ago

Changelist Summary for PR: Enhancements to Convert a JSON Representation of the Policy to its Textual Counterpart

Overview

Changes Made

  1. Source File Modifications:

    • Implemented a function to convert a simple JSON representation of a policy (as defined by Cedar Guide) into its textual format. This includes handling of Principal, Action, and Resource elements.
    • For the Context element, the current implementation passes the JSON representation as-is, without syntax validation, due to its complexity and variability.
  2. Test File Updates:

    • Introduced new test cases specifically designed to assess the accuracy of the JSON to Text conversion process for policies.
    • Utilized a newly added JSON file to supply test data, ensuring a broad range of policy scenarios are covered and accurately converted.
  3. Test JSON Data Adjustments:

    • The test JSON data has been expanded to include various policy scenarios, encompassing both straightforward and complex cases. This ensures the conversion process is robust and can handle real-world policy configurations.
    • Special attention was given to scenarios such as conditional access based on office hours and user location, testing the system's ability to accurately represent these conditions in textual format.

Feedback

Any feedback on these changes is highly appreciated, especially in areas concerning the handling of complex Context elements and the overall usability of the converted textual policies.

Note: Before I merge my code though, can we tag the versions of the main branch to follow semantic versioning of the library

philhassey commented 1 month ago

Thanks for the PR! We're still thinking over exactly how we want to approach JSON in the cedar-go project here, and I'm not sure if this is quite what we're looking for. For now, since your PR does at least partially address your concern in https://github.com/cedar-policy/cedar-go/issues/13, I'd suggest adding a comment to that issue linking to your fork.