pub trait SecurityExt {
// Required methods
fn get_user(&self) -> Option<User>;
fn is_authenticated(&self) -> bool;
fn has_role(&self, role: &str) -> bool;
fn has_any_role(&self, roles: &[&str]) -> bool;
fn has_authority(&self, authority: &str) -> bool;
fn has_any_authority(&self, authorities: &[&str]) -> bool;
}Expand description
Extension trait for HttpRequest to check authentication.
Required Methods§
Sourcefn is_authenticated(&self) -> bool
fn is_authenticated(&self) -> bool
Returns true if a user is authenticated.
Sourcefn has_role(&self, role: &str) -> bool
fn has_role(&self, role: &str) -> bool
Checks if the authenticated user has the specified role.
Sourcefn has_any_role(&self, roles: &[&str]) -> bool
fn has_any_role(&self, roles: &[&str]) -> bool
Checks if the authenticated user has any of the specified roles.
Checks if the authenticated user has the specified authority.
Checks if the authenticated user has any of the specified authorities.