#[authorize]Expand description
Declares authorization requirements on a route.
Each attribute is one rule and every rule must be satisfied. Inside a
rule, roles / permissions are any-of lists and the two dimensions are
ANDed; a bare #[authorize] requires a valid authenticated principal.
ⓘ
#[get("/api/users")]
#[authorize(role = "admin")]
impl IRequest<Vec<UserModel>> for ListUsersRequest {}
#[get("/api/auth/me")]
#[authorize]
impl IRequest<UserView> for AuthMeRequest {}
// Either role is enough.
#[get("/api/reports")]
#[authorize(roles = ["admin", "auditor"])]
impl IRequest<Vec<Report>> for ListReportsRequest {}
// Both rules must hold: admin role and the export permission.
#[post("/api/reports/export")]
#[authorize(role = "admin")]
#[authorize(permission = "reports:export")]
impl IRequest<Response> for ExportReportsRequest {}