pub struct Policy { /* private fields */ }Expand description
Compiled bucket policy ready to evaluate requests.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn from_json_str(s: &str) -> Result<Self, String>
pub fn from_json_str(s: &str) -> Result<Self, String>
Parse a JSON bucket policy. Returns the human-readable [Display]
of the underlying PolicyParseError for backward compatibility
with the pre-v0.8.4 Result<_, String> callers (CLI flag handler,
existing E2E tests). Use Policy::from_json_str_typed when you
need to inspect the error variant programmatically.
Sourcepub fn from_json_str_typed(s: &str) -> Result<Self, PolicyParseError>
pub fn from_json_str_typed(s: &str) -> Result<Self, PolicyParseError>
v0.8.4 #75: typed-error variant of Policy::from_json_str. Lets
new callers (and the unit tests for audit H-4 / H-5) match on
PolicyParseError directly instead of grepping a String.
pub fn from_path(path: &Path) -> Result<Self, String>
Sourcepub fn evaluate(
&self,
action: &str,
bucket: &str,
key: Option<&str>,
principal_id: Option<&str>,
) -> Decision
pub fn evaluate( &self, action: &str, bucket: &str, key: Option<&str>, principal_id: Option<&str>, ) -> Decision
Evaluate a request against the policy.
principal_id is typically the SigV4 access key id taken from the
authenticated request. Pass None for anonymous (will only match
statements with wildcard or absent Principal).
Convenience for the common case with no Condition data; calls the
full Policy::evaluate_with with a default RequestContext.
Sourcepub fn evaluate_with(
&self,
action: &str,
bucket: &str,
key: Option<&str>,
principal_id: Option<&str>,
ctx: &RequestContext,
) -> Decision
pub fn evaluate_with( &self, action: &str, bucket: &str, key: Option<&str>, principal_id: Option<&str>, ctx: &RequestContext, ) -> Decision
Same as Policy::evaluate but lets the caller plumb a populated
RequestContext for v0.3 #13 IAM Conditions (IP allowlists,
user-agent restrictions, time windows, etc.).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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 more