pub struct Request(/* private fields */);
Expand description
An authorization request is a tuple <P, A, R, C>
where
- P is the principal
EntityUid
, - A is the action
EntityUid
, - R is the resource
EntityUid
, and - C is the request
Context
record.
It represents an authorization request asking the question, “Can this principal take this action on this resource in this context?”
Implementations§
Source§impl Request
impl Request
Sourcepub fn builder() -> RequestBuilder<UnsetSchema>
Available on crate feature partial-eval
only.
pub fn builder() -> RequestBuilder<UnsetSchema>
partial-eval
only.Create a RequestBuilder
Sourcepub fn new(
principal: EntityUid,
action: EntityUid,
resource: EntityUid,
context: Context,
schema: Option<&Schema>,
) -> Result<Self, RequestValidationError>
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 EntityUid
s 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
.
Sourcepub fn principal(&self) -> Option<&EntityUid>
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).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
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> 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