pub struct ScopeRequirement { /* private fields */ }Expand description
A set of required OAuth scopes for an operation.
All scopes in the requirement must be present in the token for access to be granted (AND semantics).
Implementations§
Source§impl ScopeRequirement
impl ScopeRequirement
Sourcepub fn all(scopes: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn all(scopes: impl IntoIterator<Item = impl Into<String>>) -> Self
Create a scope requirement from multiple scopes.
Sourcepub fn require(self, scope: impl Into<String>) -> Self
pub fn require(self, scope: impl Into<String>) -> Self
Add a required scope to this requirement.
Sourcepub fn check(&self, claims: &TokenClaims) -> Result<(), OAuthError>
pub fn check(&self, claims: &TokenClaims) -> Result<(), OAuthError>
Check if the given token claims satisfy this requirement.
Returns Ok(()) if all required scopes are present, or
Err(OAuthError::InsufficientScope) with details about
which scopes are missing.
Sourcepub fn check_with(
&self,
claims: &TokenClaims,
matcher: &dyn ScopeMatcher,
) -> Result<(), OAuthError>
pub fn check_with( &self, claims: &TokenClaims, matcher: &dyn ScopeMatcher, ) -> Result<(), OAuthError>
Check the requirement using a custom scope matcher.
Sourcepub fn required_scopes(&self) -> &HashSet<String>
pub fn required_scopes(&self) -> &HashSet<String>
Returns the required scopes.
Trait Implementations§
Source§impl Clone for ScopeRequirement
impl Clone for ScopeRequirement
Source§fn clone(&self) -> ScopeRequirement
fn clone(&self) -> ScopeRequirement
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScopeRequirement
impl Debug for ScopeRequirement
Source§impl Default for ScopeRequirement
impl Default for ScopeRequirement
Source§fn default() -> ScopeRequirement
fn default() -> ScopeRequirement
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ScopeRequirement
impl RefUnwindSafe for ScopeRequirement
impl Send for ScopeRequirement
impl Sync for ScopeRequirement
impl Unpin for ScopeRequirement
impl UnsafeUnpin for ScopeRequirement
impl UnwindSafe for ScopeRequirement
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