Skip to main content

authorize_with_matcher

Function authorize_with_matcher 

Source
pub fn authorize_with_matcher<M: ScopeMatcher>(
    user_scope_str: &str,
    required_token: &str,
) -> bool
Expand description

Checks if a required scope is authorized by any of the user’s scopes using the given ScopeMatcher implementation.

§Arguments

  • user_scope_str: space-delimited string of scopes from the user (e.g. from claims or roles)
  • required_token: the scope token required for the action (e.g. "read:users")

§Returns

  • true if at least one user scope matches the required scope using the matcher.

§Example

let authorized = authorize_with_matcher::<FlexibleMatcher>("read:users write:posts", "read:users");
assert!(authorized);