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.).