Struct mailpot_web::RequireAuthorizationLayer
pub struct RequireAuthorizationLayer<UserId, User, Role = ()>(UserId, User, Role);
Expand description
A wrapper around [tower_http::auth::RequireAuthorizationLayer
] which
provides login authorization.
Tuple Fields§
§0: UserId
§1: User
§2: Role
Implementations§
§impl<UserId, User, Role> RequireAuthorizationLayer<UserId, User, Role>where
Role: PartialOrd<Role> + PartialEq<Role> + Clone + Send + Sync + 'static,
User: AuthUser<UserId, Role>,
impl<UserId, User, Role> RequireAuthorizationLayer<UserId, User, Role>where Role: PartialOrd<Role> + PartialEq<Role> + Clone + Send + Sync + 'static, User: AuthUser<UserId, Role>,
pub fn login<ResBody>(
) -> RequireAuthorizationLayer<Login<UserId, User, ResBody, Role>>where
ResBody: Body + Default,
pub fn login<ResBody>( ) -> RequireAuthorizationLayer<Login<UserId, User, ResBody, Role>>where ResBody: Body + Default,
Authorizes requests by requiring a logged in user, otherwise it rejects
with http::StatusCode::UNAUTHORIZED
.
pub fn login_with_role<ResBody>(
role_bounds: impl RangeBounds<Role> + Clone + Send + Sync + 'static
) -> RequireAuthorizationLayer<Login<UserId, User, ResBody, Role>>where
ResBody: Body + Default,
pub fn login_with_role<ResBody>( role_bounds: impl RangeBounds<Role> + Clone + Send + Sync + 'static ) -> RequireAuthorizationLayer<Login<UserId, User, ResBody, Role>>where ResBody: Body + Default,
Authorizes requests by requiring a logged in user to have a specific
range of roles, otherwise it rejects with
http::StatusCode::UNAUTHORIZED
.