[−][src]Module actix_web_grants::proc_macro
Procedural macros for checking user authorities or roles.
Examples
use actix_web::{HttpResponse}; use actix_web_grants::proc_macro::{has_authorities, has_roles}; // User should be ADMIN with OP_GET_SECRET permission #[has_authorities["ROLE_ADMIN", "OP_GET_SECRET"]] async fn macro_secured() -> HttpResponse { HttpResponse::Ok().body("some secured info") } // Role - is authority with prefix "ROLE_". // User should be ADMIN and MANAGER #[has_roles["ADMIN", "MANAGER"]] async fn role_macro_secured() -> HttpResponse { HttpResponse::Ok().body("some secured info") }
Attribute Macros
has_any_authority | Macro to сheck that the user has any of the specified authorities. |
has_any_role | Macro to сheck that the user has any the specified roles. Role - is authority with prefix "ROLE_". |
has_authorities | Macro to сheck that the user has all the specified authorities. |
has_roles | Macro to сheck that the user has all the specified roles. Role - is authority with prefix "ROLE_". |