#[roles_allowed]Expand description
Role-based method security annotation (Java EE standard).
§Java EE Equivalent
@RolesAllowed({"ADMIN", "USER"})
§Spring Security Equivalent
@Secured({"ROLE_ADMIN", "ROLE_USER"})
§Usage
ⓘ
use actix_security_codegen::roles_allowed;
use actix_security_core::http::security::AuthenticatedUser;
#[roles_allowed("ADMIN")]
#[get("/admin")]
async fn admin_only(user: AuthenticatedUser) -> impl Responder {
HttpResponse::Ok().body("Admin area")
}
#[roles_allowed("ADMIN", "MANAGER")]
#[get("/management")]
async fn management(user: AuthenticatedUser) -> impl Responder {
HttpResponse::Ok().body("Management area")
}§Note
This is an alias for #[secured] following Java EE naming conventions.