pub struct AuthenticatedIdentity {
pub subject: String,
pub scopes: Vec<String>,
pub metadata: HashMap<String, Value>,
}Expand description
Fields§
§subject: StringStable subject identifier — e.g. a username, client ID, or JWT sub claim.
scopes: Vec<String>Scopes / roles granted to this identity (e.g. ["tools:execute", "admin"]).
metadata: HashMap<String, Value>Arbitrary key-value metadata attached during authentication. Examples: OAuth2 claims, certificate CN, tenant ID.
Implementations§
Source§impl AuthenticatedIdentity
impl AuthenticatedIdentity
Sourcepub fn new(subject: impl Into<String>) -> Self
pub fn new(subject: impl Into<String>) -> Self
Create a new identity with the given subject and no scopes or metadata.
Sourcepub fn with_scopes(
self,
scopes: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_scopes( self, scopes: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Builder: attach scopes to this identity.
Sourcepub fn with_meta(self, key: impl Into<String>, value: Value) -> Self
pub fn with_meta(self, key: impl Into<String>, value: Value) -> Self
Builder: attach a single metadata key-value pair.
Sourcepub fn has_scope(&self, scope: &str) -> bool
pub fn has_scope(&self, scope: &str) -> bool
Returns true if this identity has the given scope.
Sourcepub fn has_all_scopes(&self, scopes: &[&str]) -> bool
pub fn has_all_scopes(&self, scopes: &[&str]) -> bool
Returns true if this identity has all of the given scopes.
Trait Implementations§
Source§impl Clone for AuthenticatedIdentity
impl Clone for AuthenticatedIdentity
Source§fn clone(&self) -> AuthenticatedIdentity
fn clone(&self) -> AuthenticatedIdentity
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AuthenticatedIdentity
impl RefUnwindSafe for AuthenticatedIdentity
impl Send for AuthenticatedIdentity
impl Sync for AuthenticatedIdentity
impl Unpin for AuthenticatedIdentity
impl UnsafeUnpin for AuthenticatedIdentity
impl UnwindSafe for AuthenticatedIdentity
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