Struct cedar_policy::Context
source · #[repr(transparent)]pub struct Context(_);
Expand description
the Context object for an authorization request
Implementations§
source§impl Context
impl Context
sourcepub fn from_pairs(
pairs: impl IntoIterator<Item = (String, RestrictedExpression)>
) -> Self
pub fn from_pairs( pairs: impl IntoIterator<Item = (String, RestrictedExpression)> ) -> Self
Create a Context
from a map of key to “restricted expression”,
or a Vec of (key, restricted expression)
pairs, or any other iterator
of (key, restricted expression)
pairs.
sourcepub fn from_json_str(
json: &str,
schema: Option<(&Schema, &EntityUid)>
) -> Result<Self, ContextJsonError>
pub fn from_json_str( json: &str, schema: Option<(&Schema, &EntityUid)> ) -> Result<Self, ContextJsonError>
Create a Context
from a string containing JSON (which must be a JSON
object, not any other JSON type, or you will get an error here).
JSON here must use the __entity
and __extn
escapes for entity
references, extension values, etc.
If a schema
is provided, this will inform the parsing: for instance, it
will allow __entity
and __extn
escapes to be implicit, and it will error
if attributes have the wrong types (e.g., string instead of integer).
Since different Actions have different schemas for Context
, you also
must specify the Action
for schema-based parsing.
sourcepub fn from_json_value(
json: Value,
schema: Option<(&Schema, &EntityUid)>
) -> Result<Self, ContextJsonError>
pub fn from_json_value( json: Value, schema: Option<(&Schema, &EntityUid)> ) -> Result<Self, ContextJsonError>
Create a Context
from a serde_json::Value
(which must be a JSON object,
not any other JSON type, or you will get an error here).
JSON here must use the __entity
and __extn
escapes for entity
references, extension values, etc.
If a schema
is provided, this will inform the parsing: for instance, it
will allow __entity
and __extn
escapes to be implicit, and it will error
if attributes have the wrong types (e.g., string instead of integer).
Since different Actions have different schemas for Context
, you also
must specify the Action
for schema-based parsing.
sourcepub fn from_json_file(
json: impl Read,
schema: Option<(&Schema, &EntityUid)>
) -> Result<Self, ContextJsonError>
pub fn from_json_file( json: impl Read, schema: Option<(&Schema, &EntityUid)> ) -> Result<Self, ContextJsonError>
Create a Context
from a JSON file. The JSON file must contain a JSON
object, not any other JSON type, or you will get an error here.
JSON here must use the __entity
and __extn
escapes for entity
references, extension values, etc.
If a schema
is provided, this will inform the parsing: for instance, it
will allow __entity
and __extn
escapes to be implicit, and it will error
if attributes have the wrong types (e.g., string instead of integer).
Since different Actions have different schemas for Context
, you also
must specify the Action
for schema-based parsing.