pub struct Cedarling { /* private fields */ }Expand description
The instance of the Cedarling application. It is safe to share between threads.
Implementations§
Source§impl Cedarling
impl Cedarling
Sourcepub async fn new_with_env(
raw_config: Option<BootstrapConfigRaw>,
) -> Result<Cedarling, InitCedarlingError>
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.
Sourcepub async fn new(
config: &BootstrapConfig,
) -> Result<Cedarling, InitCedarlingError>
pub async fn new( config: &BootstrapConfig, ) -> Result<Cedarling, InitCedarlingError>
Create a new instance of the Cedarling application.
Authorize request with unsigned data.
makes authorization decision based on the [RequestUnverified]
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.
Authorize multi-issuer request. makes authorization decision based on multiple JWT tokens from different issuers
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.
Sourcepub fn get_matching_policies_unsigned(
&self,
principal: Option<&EntityData>,
actions: &[String],
resources: &[EntityData],
) -> Result<Vec<PolicyMetadata>, AuthorizeError>
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.
Sourcepub fn get_matching_policies_multi_issuer(
&self,
tokens: &[TokenInput],
actions: &[String],
resources: &[EntityData],
) -> Result<Vec<PolicyMetadata>, AuthorizeError>
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.
Sourcepub fn annotations_map<'a>(
&self,
ids: impl IntoIterator<Item = &'a PolicyId>,
) -> HashMap<String, String>
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.
Sourcepub fn annotation_values<'a>(
&self,
ids: impl IntoIterator<Item = &'a PolicyId>,
key: &str,
) -> Vec<String>
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.
Sourcepub fn annotations_by_policy<'a>(
&self,
ids: impl IntoIterator<Item = &'a PolicyId>,
) -> HashMap<String, HashMap<String, String>>
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.
Trait Implementations§
Source§impl DataApi for Cedarling
impl DataApi for Cedarling
Source§fn push_data_ctx(
&self,
key: &str,
value: Value,
ttl: Option<Duration>,
) -> Result<(), DataError>
fn push_data_ctx( &self, key: &str, value: Value, ttl: Option<Duration>, ) -> Result<(), DataError>
Source§fn get_data_ctx(&self, key: &str) -> Result<Option<Value>, DataError>
fn get_data_ctx(&self, key: &str) -> Result<Option<Value>, DataError>
Source§fn get_data_entry_ctx(&self, key: &str) -> Result<Option<DataEntry>, DataError>
fn get_data_entry_ctx(&self, key: &str) -> Result<Option<DataEntry>, DataError>
Source§fn remove_data_ctx(&self, key: &str) -> Result<bool, DataError>
fn remove_data_ctx(&self, key: &str) -> Result<bool, DataError>
Source§fn list_data_ctx(&self) -> Result<Vec<DataEntry>, DataError>
fn list_data_ctx(&self) -> Result<Vec<DataEntry>, DataError>
Source§fn get_stats_ctx(&self) -> Result<DataStoreStats, DataError>
fn get_stats_ctx(&self) -> Result<DataStoreStats, DataError>
Source§impl LogStorage for Cedarling
impl LogStorage for Cedarling
Source§fn get_log_ids(&self) -> Vec<String>
fn get_log_ids(&self) -> Vec<String>
Source§fn get_logs_by_tag(&self, tag: &str) -> Vec<Value>
fn get_logs_by_tag(&self, tag: &str) -> Vec<Value>
log_kind or log level.
Tag can be log_kind, log_level.Source§impl TrustedIssuerLoadingInfo for Cedarling
impl TrustedIssuerLoadingInfo for Cedarling
Source§fn is_trusted_issuer_loaded_by_name(&self, issuer_id: &str) -> bool
fn is_trusted_issuer_loaded_by_name(&self, issuer_id: &str) -> bool
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
fn is_trusted_issuer_loaded_by_iss(&self, iss_claim: &str) -> bool
true if the trusted issuer with the given iss claim is loaded.Source§fn total_issuers(&self) -> usize
fn total_issuers(&self) -> usize
Source§fn loaded_trusted_issuers_count(&self) -> usize
fn loaded_trusted_issuers_count(&self) -> usize
Auto Trait Implementations§
impl !RefUnwindSafe for Cedarling
impl !UnwindSafe for Cedarling
impl Freeze for Cedarling
impl Send for Cedarling
impl Sync for Cedarling
impl Unpin for Cedarling
impl UnsafeUnpin for Cedarling
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request