cedar_policy

Struct Request

Source
pub struct Request(/* private fields */);
Expand description

An authorization request is a tuple <P, A, R, C> where

It represents an authorization request asking the question, “Can this principal take this action on this resource in this context?”

Implementations§

Source§

impl Request

Source

pub fn builder() -> RequestBuilder<UnsetSchema>

Available on crate feature partial-eval only.

Create a RequestBuilder

This feature is experimental. For more information see https://github.com/cedar-policy/rfcs/blob/main/README.md#experimental-features
Source

pub fn new( principal: EntityUid, action: EntityUid, resource: EntityUid, context: Context, schema: Option<&Schema>, ) -> Result<Self, RequestValidationError>

Create a Request.

Note that you can create the EntityUids using .parse() on any string (via the FromStr implementation for EntityUid). The principal, action, and resource fields are optional to support the case where these fields do not contribute to authorization decisions (e.g., because they are not used in your policies). If any of the fields are None, we will automatically generate a unique entity UID that is not equal to any UID in the store.

If schema is present, this constructor will validate that the Request complies with the given schema.

Source

pub fn principal(&self) -> Option<&EntityUid>

Get the principal component of the request. Returns None if the principal is “unknown” (i.e., constructed using the partial evaluation APIs).

Source

pub fn action(&self) -> Option<&EntityUid>

Get the action component of the request. Returns None if the action is “unknown” (i.e., constructed using the partial evaluation APIs).

Source

pub fn resource(&self) -> Option<&EntityUid>

Get the resource component of the request. Returns None if the resource is “unknown” (i.e., constructed using the partial evaluation APIs).

Trait Implementations§

Source§

impl Debug for Request

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Request

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl RefCast for Request

Source§

type From = Request

Source§

fn ref_cast(_from: &Self::From) -> &Self

Source§

fn ref_cast_mut(_from: &mut Self::From) -> &mut Self

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.