Express middleware to validate resource permissions.