pub struct Subject {
pub kind: String,
pub id: Option<String>,
pub roles: Vec<RoleAssignment>,
pub principals: Vec<String>,
pub attrs: Attributes,
}Expand description
Who requests the access.
Fields§
§kind: String§id: Option<String>§roles: Vec<RoleAssignment>§principals: Vec<String>§attrs: AttributesImplementations§
Source§impl Subject
impl Subject
Sourcepub fn user(id: impl Into<String>) -> Self
pub fn user(id: impl Into<String>) -> Self
Identified user, with the principal AUTHENTICATED.
Sourcepub fn of_kind(kind: impl Into<String>, id: impl Into<String>) -> Self
pub fn of_kind(kind: impl Into<String>, id: impl Into<String>) -> Self
Subject of another kind (service account, device), with no principal.
pub fn with_role(self, role: impl Into<String>) -> Self
Sourcepub fn with_assignment(self, assignment: RoleAssignment) -> Self
pub fn with_assignment(self, assignment: RoleAssignment) -> Self
Adds a prepared assignment, such as one with a validity window.
pub fn with_role_in(self, role: impl Into<String>, scope: Anchor) -> Self
pub fn with_principal(self, principal: impl Into<String>) -> Self
pub fn with_attr(self, key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn object_ref(&self) -> Option<ObjectRef>
Sourcepub fn roles_for<'a>(
&'a self,
resource: &'a Resource,
) -> impl Iterator<Item = &'a str>
pub fn roles_for<'a>( &'a self, resource: &'a Resource, ) -> impl Iterator<Item = &'a str>
Direct roles that hold for the resource: unscoped, or with a scope in its path. Assignments
with a validity window are left out, because there is no instant to check them against;
see Subject::roles_at.
Sourcepub fn roles_at<'a>(
&'a self,
resource: &'a Resource,
now: Option<u64>,
) -> impl Iterator<Item = &'a str>
pub fn roles_at<'a>( &'a self, resource: &'a Resource, now: Option<u64>, ) -> impl Iterator<Item = &'a str>
Direct roles that hold for the resource at now: scope in the path and inside the
validity window. Without now, assignments with a window do not hold.
pub fn has_principal(&self, principal: &str) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Subject
impl<'de> Deserialize<'de> for Subject
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Subject
Auto Trait Implementations§
impl Forget for Subject
impl Freeze for Subjectwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<RoleAssignment>: Freeze,
PhantomData<String>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
impl Move for Subject
impl RefUnwindSafe for Subject
impl Send for Subject
impl Sync for Subject
impl Unpin for Subject
impl UnsafeUnpin for Subjectwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<RoleAssignment>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
impl UnwindSafe for Subject
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
Mutably borrows from an owned value. Read more