Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 1.34 KB

File metadata and controls

21 lines (14 loc) · 1.34 KB

Cedar Rust Hello World

This repository contains a simple hello world program demonstrating typical usage of the Cedar Rust APIs.

The file src/main.rs provides example code for the key steps an application takes to use Cedar. These include (1) parsing policies from text; (2) creating access requests and asking whether the request is authorized by the policies; (3) making requests that have an optional context (in addition to a principal, action, and resource); (4) providing entities with a request, which are application data relevant to the request; and (5) validating that policies are consistent with a provided schema.

The following are functions that demonstrate elements of the above.

  • parse_policy: parsing a policy and extract some of its components
  • json_context: constructing a request context from JSON values
  • entity_json: constructing entities from JSON
  • entity_objects: constructing entities from Rust objects
  • validate: validating a policy

Build and Run

This example expects that the cedar repository is cloned into the toplevel (../cedar-examples) directory. You can instruct Cargo to use your local version of cedar-policy by adding path = "../cedar/cedar-policy" to Cargo.toml.

cargo run