Skip to main content

Cedarling

Struct Cedarling 

Source
pub struct Cedarling { /* private fields */ }
Expand description

The instance of the Cedarling application. It is safe to share between threads.

Implementations§

Source§

impl Cedarling

Source

pub async fn new_with_env( raw_config: Option<BootstrapConfigRaw>, ) -> Result<Cedarling, InitCedarlingError>

Create a new instance of the Cedarling application. Initialize instance from enviroment variables and from config. Configuration structure has lower priority.

Source

pub async fn new( config: &BootstrapConfig, ) -> Result<Cedarling, InitCedarlingError>

Create a new instance of the Cedarling application.

Source

pub async fn authorize_unsigned( &self, request: RequestUnsigned, ) -> Result<AuthorizeResult, AuthorizeError>

Authorize request with unsigned data. makes authorization decision based on the [RequestUnverified]

Source

pub async fn authorize_unsigned_batch( &self, request: BatchAuthorizeUnsignedRequest, ) -> Result<BatchAuthorizeResponse<Result<AuthorizeResult, BatchItemError>>, AuthorizeError>

Authorize a batch of unsigned requests against one shared principal.

Runs setup work (principal build + pushed-data snapshot) once and evaluates each item with its own resource and context. Results are returned in input order, wrapped in a BatchAuthorizeResponse that carries a shared batch_id for audit correlation.

Batch-level failures (validation, principal parse) return Err(AuthorizeError); per-item failures are returned as Err(BatchItemError) for that item, while genuine Cedar denials remain Ok(AuthorizeResult) with decision=false.

Source

pub async fn authorize_multi_issuer( &self, request: AuthorizeMultiIssuerRequest, ) -> Result<MultiIssuerAuthorizeResult, AuthorizeError>

Authorize multi-issuer request. makes authorization decision based on multiple JWT tokens from different issuers

Source

pub async fn authorize_multi_issuer_batch( &self, request: BatchAuthorizeMultiIssuerRequest, ) -> Result<BatchAuthorizeResponse<Result<MultiIssuerAuthorizeResult, BatchItemError>>, AuthorizeError>

Authorize a batch of multi-issuer requests against one shared token set.

Validates tokens and builds token/issuer entities once, then evaluates each item with its own resource and context. Results are returned in input order, wrapped in a BatchAuthorizeResponse carrying a shared batch_id. Batch-level failures (validation, JWT verification, status-list refresh) return Err(AuthorizeError); per-item failures are returned as Err(BatchItemError), while genuine Cedar denials remain Ok(MultiIssuerAuthorizeResult) with decision=false.

Source

pub fn get_matching_policies_unsigned( &self, principal: Option<&EntityData>, actions: &[String], resources: &[EntityData], ) -> Result<Vec<PolicyMetadata>, AuthorizeError>

Returns metadata for all policies whose scope constraints are compatible with the given principals, actions, and resources.

This performs scope-level filtering only (principal/action/resource constraints). Policies with when/unless conditions may still not apply at evaluation time.

Source

pub fn get_matching_policies_multi_issuer( &self, tokens: &[TokenInput], actions: &[String], resources: &[EntityData], ) -> Result<Vec<PolicyMetadata>, AuthorizeError>

Returns metadata for all policies whose scope constraints are compatible with the given token-derived principals, actions, and resources.

Tokens are validated and their mapping types used as principal entity types.

Source

pub fn annotations_map<'a>( &self, ids: impl IntoIterator<Item = &'a PolicyId>, ) -> HashMap<String, String>

Merge the annotations (@key("value")) of the given policies into a single map.

Intended for resolving the determining policies of an authorization decision: pass the IDs from result.response.diagnostics().reason().

Lossy: if the same annotation key appears on several policies, one value wins arbitrarily (order undefined). Use Self::annotation_values or Self::annotations_by_policy when duplicates matter.

Resolve annotations promptly after authorize*(): a concurrent policy-store refresh may swap the store, in which case IDs that no longer resolve are silently dropped from the result.

Source

pub fn annotation_values<'a>( &self, ids: impl IntoIterator<Item = &'a PolicyId>, key: &str, ) -> Vec<String>

Collect every value of the annotation key across the given policies, preserving duplicates.

Intended for resolving the determining policies of an authorization decision: pass the IDs from result.response.diagnostics().reason().

Resolve annotations promptly after authorize*(): a concurrent policy-store refresh may swap the store, in which case IDs that no longer resolve are silently dropped from the result.

Source

pub fn annotations_by_policy<'a>( &self, ids: impl IntoIterator<Item = &'a PolicyId>, ) -> HashMap<String, HashMap<String, String>>

Return the annotations of each given policy, grouped by policy ID — the loss-free companion to Self::annotations_map.

Intended for resolving the determining policies of an authorization decision: pass the IDs from result.response.diagnostics().reason().

Resolve annotations promptly after authorize*(): a concurrent policy-store refresh may swap the store, in which case IDs that no longer resolve are silently dropped from the result.

Source

pub async fn shut_down(&self)

Closes the connections to the Lock Server and pushes all available logs.

Trait Implementations§

Source§

impl Clone for Cedarling

Source§

fn clone(&self) -> Cedarling

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DataApi for Cedarling

Source§

fn push_data_ctx( &self, key: &str, value: Value, ttl: Option<Duration>, ) -> Result<(), DataError>

Push a value into the store with an optional TTL. Read more
Source§

fn get_data_ctx(&self, key: &str) -> Result<Option<Value>, DataError>

Get a value from the store by key. Read more
Source§

fn get_data_entry_ctx(&self, key: &str) -> Result<Option<DataEntry>, DataError>

Get a data entry with full metadata by key. Read more
Source§

fn remove_data_ctx(&self, key: &str) -> Result<bool, DataError>

Remove a value from the store by key. Read more
Source§

fn clear_data_ctx(&self) -> Result<(), DataError>

Clear all entries from the store.
Source§

fn list_data_ctx(&self) -> Result<Vec<DataEntry>, DataError>

List all entries with their metadata. Read more
Source§

fn get_stats_ctx(&self) -> Result<DataStoreStats, DataError>

Get statistics about the data store. Read more
Source§

impl LogStorage for Cedarling

Source§

fn pop_logs(&self) -> Vec<Value>

Return logs and remove them from the storage
Source§

fn get_log_by_id(&self, id: &str) -> Option<Value>

Get specific log entry
Source§

fn get_log_ids(&self) -> Vec<String>

Returns a list of all log ids
Source§

fn get_logs_by_tag(&self, tag: &str) -> Vec<Value>

Get logs by tag, like log_kind or log level. Tag can be log_kind, log_level.
Source§

fn get_logs_by_request_id(&self, request_id: &str) -> Vec<Value>

Get logs by request_id. Return log entries that match the given request_id.
Source§

fn get_logs_by_request_id_and_tag(&self, id: &str, tag: &str) -> Vec<Value>

Get log by request_id and tag, like composite key request_id + log_kind. Tag can be log_kind, log_level. Return log entries that match the given request_id and tag.
Source§

impl TrustedIssuerLoadingInfo for Cedarling

Source§

fn is_trusted_issuer_loaded_by_name(&self, issuer_id: &str) -> bool

Returns true if the trusted issuer with the given ID (policy store key) is loaded.
Source§

fn is_trusted_issuer_loaded_by_iss(&self, iss_claim: &str) -> bool

Returns true if the trusted issuer with the given iss claim is loaded.
Source§

fn total_issuers(&self) -> usize

Returns the total number of trusted issuers that are expected to be loaded.
Source§

fn loaded_trusted_issuers_count(&self) -> usize

Returns the number of trusted issuers that have been loaded.
Source§

fn loaded_trusted_issuer_ids(&self) -> HashSet<String>

Returns all issuer IDs in the index of loaded trusted issuers. Read more
Source§

fn failed_trusted_issuer_ids(&self) -> HashSet<String>

Returns issuer IDs that failed to load. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more