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

Upgraded cedar to 4.2.0 #83

Merged
merged 10 commits into from
Dec 4, 2024
272 changes: 132 additions & 140 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cedar-local-agent"
edition = "2021"
version = "2.0.0"
version = "3.0.0"
license = "Apache-2.0"
description = "Foundational library for creating Cedar-based asynchronous authorizers."
keywords = ["cedar", "agent", "authorization", "policy", "security"]
Expand All @@ -13,16 +13,18 @@ bench = false
[dependencies]
# Utilities
async-trait = "0.1.71"
bytemuck = "1.20.0"
chrono = "0.4.26"
derive_builder = "0.12.0"
futures = { version = "0.3.28", features = ["std"] }
futures = { version = "0.3.31", features = ["std"] }
fs2 = "0.4.3"
once_cell = "1.18.0"
rand = "0.8.5"
serde = { version = "1.0.166", features = ["derive"] }
serde_json = "1.0.100"
serde_repr = "0.1.16"
sha256 = "1.3.0"
smol_str = "0.3.2"
tokio = { version = "1.0", features = ["full", "signal", "sync", "parking_lot"] }
uuid = { version = "1.4.1", features = ["v4"] }

Expand All @@ -33,10 +35,10 @@ tracing-core = "0.1.31"
tracing-subscriber = "0.3.17"

# Cedar
cedar-policy = "3.1.0"
cedar-policy-core = "3.1.0"
cedar-policy-formatter = "3.1.0"
cedar-policy-validator = "3.1.0"
cedar-policy = "4.2.0"
cedar-policy-core = "4.2.0"
cedar-policy-formatter = "4.2.0"
cedar-policy-validator = "4.2.0"

[features]
# Experimental features.
Expand Down
2 changes: 1 addition & 1 deletion benches/data_gen/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl From<Entity> for EntityUidRepr {
fn from(value: Entity) -> Self {
EntityUidRepr {
type_name: value.uid().type_name().to_string(),
id: value.uid().id().to_string(),
id: value.uid().to_string(),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion benches/data_gen/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use rand::Rng;

/// Alphabet as an &str
pub const ALPHA: &str = "abcdefghijklmnopqrstuvwxyz";
#[allow(clippy::single_char_add_str)]
pub fn random_string(n: u32, charset: &str) -> String {
let mut rng = rand::thread_rng();

let mut res = "".to_string();
for _i in 0..n as usize {
let random_index: usize = rng.gen_range(0..charset.len());
res.push_str(&charset.chars().nth(random_index).unwrap().to_string());
res.push(charset.chars().nth(random_index).unwrap());
}
res
}
6 changes: 3 additions & 3 deletions benches/is_authorized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::sync::Arc;

fn construct_request() -> Request {
Request::new(
Some("Principal::\"request\"".parse().unwrap()),
Some("Action::\"request\"".parse().unwrap()),
Some("Resource::\"request\"".parse().unwrap()),
"Principal::\"request\"".parse().unwrap(),
"Action::\"request\"".parse().unwrap(),
"Resource::\"request\"".parse().unwrap(),
Context::empty(),
None,
)
Expand Down
8 changes: 0 additions & 8 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# This file defines configuration for the cargo deny command
# Ref: https://github.com/EmbarkStudios/cargo-deny
targets = []

[advisories]
vulnerability = "deny"
unmaintained = "deny"
notice = "deny"
unsound = "deny"
ignore = []

[bans]
Expand Down Expand Up @@ -37,9 +32,6 @@ unknown-registry = "deny"
unknown-git = "deny"

[licenses]
unlicensed = "deny"
allow-osi-fsf-free = "neither"
copyleft = "deny"
confidence-threshold = 0.93
allow = [
"Apache-2.0",
Expand Down
12 changes: 6 additions & 6 deletions src/public/file/entity_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::io::Error;
use std::sync::Arc;

use async_trait::async_trait;
use cedar_policy::{Entities, EntitiesError, Request, Schema};
use cedar_policy::{entities_errors::EntitiesError, Entities, Request, Schema};
use derive_builder::Builder;
use thiserror::Error;
use tokio::sync::RwLock;
Expand Down Expand Up @@ -172,7 +172,7 @@ impl EntityProvider {

let entities = if let Some(schema_path) = configuration.schema_path.as_ref() {
let schema_file = File::open(schema_path)?;
let schema = Schema::from_file(schema_file)
let schema = Schema::from_json_file(schema_file)
.map_err(|_schema_error| SchemaParseErrorWrapper::new(schema_path.clone()))?;
let res = Entities::from_json_file(entities_file, Some(&schema)).map_err(
|entities_error| {
Expand Down Expand Up @@ -227,7 +227,7 @@ impl UpdateProviderData for EntityProvider {
let schema_file = File::open(schema_path).map_err(|e| {
UpdateProviderDataError::General(Box::new(ProviderError::IOError(e)))
})?;
let schema = Schema::from_file(schema_file).map_err(|_| {
let schema = Schema::from_json_file(schema_file).map_err(|_| {
UpdateProviderDataError::General(Box::new(ProviderError::SchemaParseError(
schema_path.to_string(),
)))
Expand Down Expand Up @@ -335,9 +335,9 @@ mod test {
.unwrap()
.get_entities(
&Request::new(
Some(r#"User::"Eric""#.parse().unwrap()),
Some(r#"Action::"View""#.parse().unwrap()),
Some(r#"Box::"10""#.parse().unwrap()),
r#"User::"Eric""#.parse().unwrap(),
r#"Action::"View""#.parse().unwrap(),
r#"Box::"10""#.parse().unwrap(),
Context::empty(),
None,
)
Expand Down
6 changes: 3 additions & 3 deletions src/public/file/policy_set_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ mod test {
.unwrap()
.get_policy_set(
&Request::new(
Some(r#"User::"Adam""#.parse().unwrap()),
Some(r#"Action::"View""#.parse().unwrap()),
Some(r#"Box::"10""#.parse().unwrap()),
r#"User::"Adam""#.parse().unwrap(),
r#"Action::"View""#.parse().unwrap(),
r#"Box::"10""#.parse().unwrap(),
Context::empty(),
None,
)
Expand Down
2 changes: 1 addition & 1 deletion src/public/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub const DEFAULT_REQUESTER_NAME: &str = "cedar::simple::authorizer";
#[builder(setter(into))]
pub struct Config {
/// `format` is used to specify the log rotation format.
/// By default the log rotation format is OpenCyberSecurityFramework (OCSF).
/// By default the log rotation format is `OpenCyberSecurityFramework` (OCSF).
#[builder(default)]
pub format: Format,

Expand Down
Loading
Loading