Add middleware for API security