[−][src]Struct oxide_auth::primitives::scope::Scope
Scope of a given grant or resource, a set of scope-tokens separated by spaces.
Scopes are interpreted as a conjunction of scope tokens, i.e. a scope is fulfilled if all of
its scope tokens are fulfilled. This induces a partial ordering on scopes where scope A
is less or equal than scope B if all scope tokens of A are also found in B. This can be
interpreted as the rule
A token with scope
Bis allowed to access a resource requiring scopeAiffA <= B
Example
let grant_scope = "some_scope other_scope".parse::<Scope>().unwrap(); let resource_scope = "some_scope".parse::<Scope>().unwrap(); let uncomparable = "some_scope third_scope".parse::<Scope>().unwrap(); // Holding a grant with `grant_scope` allows access to the resource since: assert!(resource_scope <= grant_scope); assert!(resource_scope.allow_access(&grant_scope)); // But holders would not be allowed to access another resource with scope `uncomparable`: assert!(!(uncomparable <= grant_scope)); assert!(!uncomparable.allow_access(&grant_scope)); // This would also not work the other way around: assert!(!(grant_scope <= uncomparable)); assert!(!grant_scope.allow_access(&uncomparable));
Scope-tokens are restricted to the following subset of ascii:
- The character '!'
- The character range '\x32' to '\x5b' which includes numbers and upper case letters
- The character range '\x5d' to '\x7e' which includes lower case letters Individual scope-tokens are separated by spaces.
In particular, the characters '\x22' (") and '\x5c' (\) are not allowed.
Methods
impl Scope[src]
pub fn priviledged_to(&self, rhs: &Scope) -> bool[src]
Determines if this scope has enough privileges to access some resource requiring the scope
on the right side. This operation is equivalent to comparison via >=.
pub fn allow_access(&self, rhs: &Scope) -> bool[src]
Determines if a resouce protected by this scope should allow access to a token with the
grant on the right side. This operation is equivalent to comparison via <=.
Trait Implementations
impl PartialOrd<Scope> for Scope[src]
fn partial_cmp(&self, rhs: &Self) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Clone for Scope[src]
fn clone(&self) -> Scope[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl PartialEq<Scope> for Scope[src]
impl Eq for Scope[src]
impl Debug for Scope[src]
impl Display for Scope[src]
impl FromStr for Scope[src]
type Err = ParseScopeErr
The associated error which can be returned from parsing.
fn from_str(string: &str) -> Result<Scope, ParseScopeErr>[src]
Auto Trait Implementations
impl Unpin for Scope
impl Send for Scope
impl Sync for Scope
impl RefUnwindSafe for Scope
impl UnwindSafe for Scope
Blanket Implementations
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized, [src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool[src]
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> DebugAny for T where
T: Any + Debug,
T: Any + Debug,
impl<T> CloneAny for T where
T: Clone + Any,
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
T: Send + Sync,
impl<T> UnsafeAny for T where
T: Any,
T: Any,
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T, I> AsResult<T, I> for T where
I: Input,
I: Input,