Integrate Cerbos with Aperture
Last validated:
Cerbos is a policy engine that provides fine-grained, context-aware authorization. By connecting Aperture to Cerbos, you can send LLM request data to Cerbos so it can enforce authorization policies on AI usage, such as controlling which users can access specific models or tools.
Aperture sends data to Cerbos using the hooks system. You configure a hook endpoint for your Cerbos deployment and a grant that specifies which requests trigger the hook and what data to include.
Prerequisites
Before you begin, ensure you have the following:
- A running Aperture instance accessible from your device.
- A Cerbos deployment (self-hosted or Cerbos Hub) with an API endpoint that can receive webhook data.
Configure the Cerbos endpoint
To integrate Cerbos with Aperture, configure the Cerbos endpoint so you can use it as a hook in Aperture and set up a grant to send request data to that hook. This allows Cerbos to receive real-time data about LLM requests for authorization decisions.
- In your Cerbos deployment, identify or create an endpoint that can receive HTTP POST requests from Aperture.
- Note the endpoint URL and any API key or authentication token. You'll use these when configuring the hook in Aperture.
For details on setting up Cerbos, refer to the Cerbos documentation.
Configure the Aperture hook
Configure a hook in Aperture that points to your Cerbos endpoint. This lets you send request data to Cerbos for authorization decisions.
-
Open the Aperture dashboard at
http://ai/ui/. -
Navigate to the Settings page and open the JSON editor.
-
Add a
cerbosentry in thehookssection with the endpoint URL from your Cerbos deployment."hooks": { "cerbos": { "url": "YOUR_CERBOS_ENDPOINT_URL", "apikey": "YOUR_CERBOS_API_KEY" } }Replace
YOUR_CERBOS_ENDPOINT_URLwith the URL of your Cerbos endpoint andYOUR_CERBOS_API_KEYwith the API key from your Cerbos deployment. -
Add a grant with a
send_hooksentry that references thecerboshook. The grant controls which requests trigger the hook and what data Aperture sends."grants": [ { "src": ["*"], "app": { "tailscale.com/cap/aperture": [ { "send_hooks": [ { "name": "cerbos", "events": ["entire_request"], "send": ["tools", "user_message", "grants"] } ] } ] } } ]This configuration sends request data for all users. The
grantssend type includes the user's custom capabilities, which Cerbos can use for authorization decisions. To limit which users' requests trigger the hook, replace"*"in thesrcfield with specific user identities or tags. -
Save the configuration.
For details on hook events and send types, refer to the hooks configuration reference.
Verify the integration
After configuring the Cerbos hook, verify that Aperture is sending data to Cerbos and that Cerbos is evaluating it against your policies.
- Send a request through Aperture that matches your grant conditions.
- Check your Cerbos deployment to confirm the request data arrives.
- Verify that Cerbos evaluates the data against your authorization policies.
If data doesn't appear, check that the send_hooks name matches the key in your hooks section and that the grant's src field includes the user who made the request.
Next steps
- Build a custom webhook to send Aperture data to other services.
- Learn about hook events and data types in the configuration reference.
- Explore other external integrations for Aperture.