r/apify • u/ClimateDistinct8980 • 22h ago
Help needed Multi-tenant Server Actors: How to securely distinguish authenticated gateway requests from direct container access?
Hi everyone,
We're developing a new Actor that supports both regular Runs and the multi-tenant Server interface, using pay-per-event (PPE) billing.
During private cloud testing, we encountered a security question that we haven't been able to resolve through the official documentation.
What we've observed
- The authenticated Server gateway validates the caller's Apify token and provides
X-Apify-User-IDandX-Actor-Request-ID. - Anonymous requests to the Server gateway are rejected.
- However, the direct container URL (
*.runs.apify.net) appears to be accessible without authentication. - Requests sent directly to the container can include client-supplied values for those same identity headers.
This makes it difficult for our application to determine whether a request actually came through the authenticated Apify gateway.
Why this matters
We understand that the Charge API validates the request ID and rejects invalid or expired IDs without charging the customer.
However, by the time our Actor attempts to charge, it may already have consumed compute resources, performed scraping, or called paid third-party APIs.
We would like to verify that a request is legitimate before starting any potentially expensive business processing, rather than relying solely on billing validation afterward.
Our questions
- Is there a supported way to disable or restrict direct container access for multi-tenant Server Actors?
- Does Apify provide a trusted ingress indicator, signed header, or network-level mechanism that distinguishes authenticated gateway requests from direct container requests?
- Is there a read-only API or SDK method to validate an active
X-Actor-Request-IDand its associated user identity before charging? - If none of these mechanisms exists, what is the recommended architecture for protecting multi-tenant PPE Server Actors against unauthorized requests that consume compute or paid API resources?
We've reviewed the following documentation:
- https://docs.apify.com/actors/development/programming-interface/server-actors
- https://docs.apify.com/actors/monetize/server-actors
- https://docs.apify.com/actors/development/programming-interface/container-web-server
We've also contacted Apify Support, but their AI assistant confirmed that the public documentation does not provide definitive answers to these questions.
Has anyone encountered this issue when developing a multi-tenant Server Actor? How are you handling trusted request identity in production?
Any insights from experienced Actor developers or the Apify engineering team would be greatly appreciated.
Thanks!
2
u/fab_brno 16h ago
Responses from my colleague: