pub struct ValidatorSchema { /* private fields */ }Expand description
Internal representation of the schema for use by the validator.
In this representation, all common types are fully expanded, and all entity type names are fully disambiguated (fully qualified).
Implementations§
Source§impl ValidatorSchema
impl ValidatorSchema
Sourcepub fn new(
entity_types: impl IntoIterator<Item = ValidatorEntityType>,
action_ids: impl IntoIterator<Item = ValidatorActionId>,
) -> Self
pub fn new( entity_types: impl IntoIterator<Item = ValidatorEntityType>, action_ids: impl IntoIterator<Item = ValidatorActionId>, ) -> Self
Construct a new ValidatorSchema from a set of ValidatorEntityTypes and ValidatorActionIds
Sourcepub fn principals(&self) -> impl Iterator<Item = &EntityType>
pub fn principals(&self) -> impl Iterator<Item = &EntityType>
Returns an iterator over every entity type that can be a principal for any action in this schema
Sourcepub fn resources(&self) -> impl Iterator<Item = &EntityType>
pub fn resources(&self) -> impl Iterator<Item = &EntityType>
Returns an iterator over every entity type that can be a resource for any action in this schema
Sourcepub fn principals_for_action(
&self,
action: &EntityUID,
) -> Option<impl Iterator<Item = &EntityType>>
pub fn principals_for_action( &self, action: &EntityUID, ) -> Option<impl Iterator<Item = &EntityType>>
Sourcepub fn resources_for_action(
&self,
action: &EntityUID,
) -> Option<impl Iterator<Item = &EntityType>>
pub fn resources_for_action( &self, action: &EntityUID, ) -> Option<impl Iterator<Item = &EntityType>>
Sourcepub fn actions_for_principal_and_resource<'a: 'b, 'b>(
&'a self,
principal_type: &'b EntityType,
resource_type: &'b EntityType,
) -> impl Iterator<Item = &'a EntityUID> + 'b
pub fn actions_for_principal_and_resource<'a: 'b, 'b>( &'a self, principal_type: &'b EntityType, resource_type: &'b EntityType, ) -> impl Iterator<Item = &'a EntityUID> + 'b
Returns an iterator over the actions that apply to this principal and
resource type, as specified by the appliesTo block for the action in
this schema.
Sourcepub fn unlinked_request_envs(
&self,
mode: ValidationMode,
) -> impl Iterator<Item = RequestEnv<'_>> + '_
pub fn unlinked_request_envs( &self, mode: ValidationMode, ) -> impl Iterator<Item = RequestEnv<'_>> + '_
Returns an iterator over every valid RequestEnv in the schema
Sourcepub fn ancestors<'a>(
&'a self,
ty: &'a EntityType,
) -> Option<impl Iterator<Item = &'a EntityType> + 'a>
pub fn ancestors<'a>( &'a self, ty: &'a EntityType, ) -> Option<impl Iterator<Item = &'a EntityType> + 'a>
Sourcepub fn action_groups(&self) -> impl Iterator<Item = &EntityUID>
pub fn action_groups(&self) -> impl Iterator<Item = &EntityUID>
Returns an iterator over all the action groups defined in this schema
Sourcepub fn actions(&self) -> impl Iterator<Item = &EntityUID>
pub fn actions(&self) -> impl Iterator<Item = &EntityUID>
Returns an iterator over all actions defined in this schema
Sourcepub fn empty() -> ValidatorSchema
pub fn empty() -> ValidatorSchema
Create a ValidatorSchema without any definitions (of entity types,
common types, or actions).
Sourcepub fn from_json_value(json: Value, extensions: &Extensions<'_>) -> Result<Self>
pub fn from_json_value(json: Value, extensions: &Extensions<'_>) -> Result<Self>
Construct a ValidatorSchema from a JSON value in the appropriate
shape.
Sourcepub fn from_json_str(json: &str, extensions: &Extensions<'_>) -> Result<Self>
pub fn from_json_str(json: &str, extensions: &Extensions<'_>) -> Result<Self>
Construct a ValidatorSchema from a string containing JSON in the
appropriate shape.
Sourcepub fn from_json_file(
file: impl Read,
extensions: &Extensions<'_>,
) -> Result<Self>
pub fn from_json_file( file: impl Read, extensions: &Extensions<'_>, ) -> Result<Self>
Construct a ValidatorSchema directly from a file containing JSON
in the appropriate shape.
Sourcepub fn from_cedarschema_file<'a>(
r: impl Read,
extensions: &'a Extensions<'a>,
) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
pub fn from_cedarschema_file<'a>( r: impl Read, extensions: &'a Extensions<'a>, ) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
Construct a ValidatorSchema directly from a file containing the
Cedar schema syntax.
Sourcepub fn from_cedarschema_str<'a>(
src: &str,
extensions: &Extensions<'a>,
) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
pub fn from_cedarschema_str<'a>( src: &str, extensions: &Extensions<'a>, ) -> Result<(Self, impl Iterator<Item = SchemaWarning> + 'a), CedarSchemaError>
Construct a ValidatorSchema from a string containing the Cedar
schema syntax.
Sourcepub fn from_schema_fragments(
fragments: impl IntoIterator<Item = ValidatorSchemaFragment<ConditionalName, ConditionalName>>,
extensions: &Extensions<'_>,
) -> Result<ValidatorSchema>
pub fn from_schema_fragments( fragments: impl IntoIterator<Item = ValidatorSchemaFragment<ConditionalName, ConditionalName>>, extensions: &Extensions<'_>, ) -> Result<ValidatorSchema>
Construct a ValidatorSchema from some number of ValidatorSchemaFragments.
Sourcepub fn get_action_id(&self, action_id: &EntityUID) -> Option<&ValidatorActionId>
pub fn get_action_id(&self, action_id: &EntityUID) -> Option<&ValidatorActionId>
Lookup the ValidatorActionId object in the schema with the given name.
Sourcepub fn get_entity_type<'a>(
&'a self,
entity_type_id: &EntityType,
) -> Option<&'a ValidatorEntityType>
pub fn get_entity_type<'a>( &'a self, entity_type_id: &EntityType, ) -> Option<&'a ValidatorEntityType>
Lookup the ValidatorEntityType object in the schema with the given name.
Sourcepub fn action_ids(&self) -> impl Iterator<Item = &ValidatorActionId>
pub fn action_ids(&self) -> impl Iterator<Item = &ValidatorActionId>
An iterator over the ValidatorActionIds in the schema.
Sourcepub fn entity_type_names(&self) -> impl Iterator<Item = &EntityType>
pub fn entity_type_names(&self) -> impl Iterator<Item = &EntityType>
An iterator over the entity type names in the schema.
Sourcepub fn entity_types(&self) -> impl Iterator<Item = &ValidatorEntityType>
pub fn entity_types(&self) -> impl Iterator<Item = &ValidatorEntityType>
An iterator over the ValidatorEntityTypes in the schema.
Sourcepub fn context_type(&self, action: &EntityUID) -> Option<&Type>
pub fn context_type(&self, action: &EntityUID) -> Option<&Type>
Get the Type of context expected for the given action.
This always returns a closed record type.
Returns None if the action is not in the schema.
Sourcepub fn action_entities(&self) -> Result<Entities, EntitiesError>
pub fn action_entities(&self) -> Result<Entities, EntitiesError>
Construct an Entity object for each action in the schema
Source§impl ValidatorSchema
impl ValidatorSchema
Sourcepub fn from_deprecated_json_value(
json: Value,
extensions: &Extensions<'_>,
) -> Result<Self, SchemaError>
pub fn from_deprecated_json_value( json: Value, extensions: &Extensions<'_>, ) -> Result<Self, SchemaError>
Construct a ValidatorSchema from a JSON value in the appropriate
shape.
Sourcepub fn from_deprecated_json_str(
json: &str,
extensions: &Extensions<'_>,
) -> Result<Self, SchemaError>
pub fn from_deprecated_json_str( json: &str, extensions: &Extensions<'_>, ) -> Result<Self, SchemaError>
Construct a ValidatorSchema from a string containing JSON in the
appropriate shape.
Sourcepub fn from_deprecated_json_file(
file: impl Read,
extensions: &Extensions<'_>,
) -> Result<Self, SchemaError>
pub fn from_deprecated_json_file( file: impl Read, extensions: &Extensions<'_>, ) -> Result<Self, SchemaError>
Construct a ValidatorSchema directly from a file containing JSON
in the appropriate shape.
Trait Implementations§
Source§impl Clone for ValidatorSchema
impl Clone for ValidatorSchema
Source§fn clone(&self) -> ValidatorSchema
fn clone(&self) -> ValidatorSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ValidatorSchema
impl Debug for ValidatorSchema
Source§impl FromStr for ValidatorSchema
Construct ValidatorSchema from a string containing a schema formatted
in the Cedar schema format.
impl FromStr for ValidatorSchema
Construct ValidatorSchema from a string containing a schema formatted
in the Cedar schema format.
Source§impl RequestSchema for ValidatorSchema
impl RequestSchema for ValidatorSchema
Source§fn validate_context<'a>(
&self,
context: &Context,
action: &EntityUID,
extensions: &Extensions<'a>,
) -> Result<(), RequestValidationError>
fn validate_context<'a>( &self, context: &Context, action: &EntityUID, extensions: &Extensions<'a>, ) -> Result<(), RequestValidationError>
Validate a context against a schema for a specific action
Source§fn validate_scope_variables(
&self,
principal: Option<&EntityUID>,
action: Option<&EntityUID>,
resource: Option<&EntityUID>,
) -> Result<(), RequestValidationError>
fn validate_scope_variables( &self, principal: Option<&EntityUID>, action: Option<&EntityUID>, resource: Option<&EntityUID>, ) -> Result<(), RequestValidationError>
Validate entities against a schema for a specific action
Source§type Error = RequestValidationError
type Error = RequestValidationError
Source§fn validate_request(
&self,
request: &Request,
extensions: &Extensions<'_>,
) -> Result<(), Self::Error>
fn validate_request( &self, request: &Request, extensions: &Extensions<'_>, ) -> Result<(), Self::Error>
request, returning Err if it fails validationAuto Trait Implementations§
impl Freeze for ValidatorSchema
impl RefUnwindSafe for ValidatorSchema
impl Send for ValidatorSchema
impl Sync for ValidatorSchema
impl Unpin for ValidatorSchema
impl UnwindSafe for ValidatorSchema
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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