Turn on Debug Mode for decision logs
Turn on Debug Mode to add the reason behind each permission decision to your decision logs. This page is for developers who need to understand why a policy decision point (PDP) allowed or denied a request.
What Debug Mode adds to decision logs
With Debug Mode on, the PDP adds a debug object to each decision. The debug object shows:
- The request the PDP evaluated: the user and its attributes, whether the user is synced, the tenant, the action, and the resource.
- For each policy model that took part in the decision, a
codeand a human-readablereason. For example,debug.rbac.reasonnames the role that granted access. - For a denied request, a
support_linkto the page that explains the code. See Denial codes in decision logs.
Debug Mode increases policy evaluation latency. Turn off Debug Mode for PDPs that serve production traffic. For other production settings, see Performance settings.
Choose where to set Debug Mode
| Where you set it | Scope | Use it when |
|---|---|---|
PDP_DEBUG environment variable | One PDP container | You debug a single PDP, for example a local container. |
| Permit API | Every PDP that uses the same PDP configuration | You change the setting for an environment's PDPs without redeploying them, including the Cloud PDP. |
use_debugger in a PDP request body | One request | You debug a single check. |
When more than one setting applies, the most specific one wins:
use_debuggerin the request body overrides every other setting.PDP_DEBUGon the PDP container overrides the Permit API setting.- The Permit API setting applies when neither of the settings above is set.
- When nothing is set, Debug Mode is on.
Set Debug Mode on one PDP container
Set the PDP_DEBUG environment variable when you start the PDP container:
| Value | Behavior |
|---|---|
| Not set | The PDP uses the setting from the Permit API. This is the default. |
True | Debug Mode is on for this PDP. |
False | Debug Mode is off for this PDP. |
In this docker run command, replace <YOUR_API_KEY> with your environment API key:
docker run -it \
-p 7766:7000 \
--env PDP_API_KEY=<YOUR_API_KEY> \
--env PDP_DEBUG=True \
permitio/pdp-v2:latest
PDP_DEBUG changes only this PDP. Other PDPs in the environment keep their setting. For every PDP variable, see PDP configuration.
Set Debug Mode for a PDP configuration with the Permit API
A PDP configuration belongs to an environment. Every PDP that runs with an API key of that PDP configuration uses its Debug Mode setting, including the Cloud PDP.
Before you start, get your project ID (proj_id), environment ID (env_id), and an API key for the environment. See Get project and environment IDs and Get your API key.
-
List the environment's PDP configurations, and copy the
idof the PDP configuration to change:curl "https://api.permit.io/v2/pdps/{proj_id}/{env_id}/configs" \-H "Authorization: Bearer {api-key}" -
Use that
idas{pdp_id}, and send one of these requests.- To turn Debug Mode on:
curl "https://api.permit.io/v2/pdps/{proj_id}/{env_id}/configs/{pdp_id}/debug-audit-logs/enable" \-X PUT \-H "Authorization: Bearer {api-key}" \-H 'Content-Type: application/json'
- To turn Debug Mode off:
curl "https://api.permit.io/v2/pdps/{proj_id}/{env_id}/configs/{pdp_id}/debug-audit-logs/disable" \-X PUT \-H "Authorization: Bearer {api-key}" \-H 'Content-Type: application/json'
- To turn Debug Mode on:
The change applies to every PDP that uses this PDP configuration. A PDP container that sets PDP_DEBUG keeps its own setting.
For the request and response schemas, see Enable debug audit logs in the API reference.
Confirm that Debug Mode is on
- Run a
permit.check()call against the PDP. - Open the Audit Log screen in the Permit dashboard and select the new decision.
The decision log has a debug object with a reason. When Debug Mode is off, the decision log has no debug object.