generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 107
Closed
Labels
4.0breaking-changeThis is (likely) a breaking changeThis is (likely) a breaking changefeature-requestThis issue requets a substantial new featureThis issue requets a substantial new featurepapercutSmall annoyances in the Cedar SDK. Lower priority fixes than bugs. Smaller than a feature requestSmall annoyances in the Cedar SDK. Lower priority fixes than bugs. Smaller than a feature request
Description
Category
User level API features/changes
Describe the feature you'd like to request
The code in cedar-policy/src/ffi/
acts as our public interface for JSON-based FFI. It is currently used by the Java and WASM bindings. We plan to use it for the differential testing harness too, in the future (see #75, #76, #125). But there are several rough edges in our frontend interface as it is now. This issue proposes to overhaul our FFI interface. This will result in breaking changes that will need to be delayed to the next major release (as of writing, 4.0 or greater).
Proposed API
Entry point for is_authorized
is_authorized : AuthorizationCall -> AuthorizationAnswer
is_authorized_json : serde_json::Value -> Result<serde_json::Value, serde_json::Error>
is_authorized_json_str : &str -> Result<String, serde_json::Error>
AuthorizationCall
type
struct AuthorizationCall {
principal:EntityUid,
action: EntityUid,
resource:EntityUid,
context: Context,
schema: Option<Schema>,
validate_request: bool,
entities: Entities,
policies: PolicySet
}
struct EntityUid(JsonValueWithNoDuplicateKeys); // see <https://docs.cedarpolicy.com/policies/json-format.html>
struct Context(JsonValueWithNoDuplicateKeys); // see <https://docs.cedarpolicy.com/auth/entities-syntax.html>
enum Schema {
Human(String),
Json(JsonValueWithNoDuplicateKeys), // see <https://docs.cedarpolicy.com/schema/json-schema.html>
}
struct Entities(JsonValueWithNoDuplicateKeys); // see <https://docs.cedarpolicy.com/auth/entities-syntax.html>
struct PolicySet{
static_policies: StaticPolicySet,
templates: HashMap<PolicyId, Template>,
template_links: HashSet<TemplateLink>,
}
enum StaticPolicySet {
Concatenated(String),
Set(HashSet<Policy>),
Map(HashMap<PolicyId, Policy>),
}
enum Policy {
Human(String),
Json(serde_json::Value), // see <https://docs.cedarpolicy.com/policies/json-format.html>
}
enum Template {
Human(String),
Json(serde_json::Value), // see <https://docs.cedarpolicy.com/policies/json-format.html>
}
struct TemplateLink {
template_id: SmolStr,
new_id: SmolStr,
values: HashMap<SlotId, EntityUid>,
}
AuthorizationAnswer
type
enum AuthorizationAnswer {
Failure {
errors: Vec<DetailedError>, // `DetailedError` is a custom JSON format to describe miette errors
warnings: Vec<DetailedError>
},
Success {
response: Response,
warnings: Vec<DetailedError>
},
}
pub struct Response {
decision: Decision,
diagnostics: Diagnostics,
}
pub struct Diagnostics {
reason: HashSet<PolicyId>,
errors: HashSet<AuthorizationError>,
}
struct AuthorizationError {
policy_id: PolicyId,
error: DetailedError,
}
Entry point for validate
validate : ValidationCall -> ValidationAnswer
validate_json : serde_json::Value -> Result<serde_json::Value, serde_json::Error>
validate_json_str : &str -> Result<String, serde_json::Error>
ValidationCall
type
struct ValidationCall {
validation_settings: ValidationSettings,
schema: Schema,
policies: PolicySet,
}
struct ValidationSettings {
enabled: bool,
mode: ValidationMode,
}
ValidationAnswer
type
enum ValidationAnswer {
Failure {
errors: Vec<DetailedError>,
warnings: Vec<DetailedError>
},
Success {
validation_errors: HashSet<ValidationError>,
validation_warnings: HashSet<ValidationError>,
warnings: Vec<DetailedError>
},
}
struct ValidationError {
policy_id: PolicyId,
error: DetailedError // content of `DetailedError` distinguishes "warnings" from "errors"
}
cdisselkoen and jamiewinder
Metadata
Metadata
Assignees
Labels
4.0breaking-changeThis is (likely) a breaking changeThis is (likely) a breaking changefeature-requestThis issue requets a substantial new featureThis issue requets a substantial new featurepapercutSmall annoyances in the Cedar SDK. Lower priority fixes than bugs. Smaller than a feature requestSmall annoyances in the Cedar SDK. Lower priority fixes than bugs. Smaller than a feature request