Perform a Local Policy Check
Run a permission check against a policy decision point (PDP) container on your own machine instead of the managed Cloud PDP. This page is for developers who already have a policy in Permit and want checks to run locally. Each step links to the page that owns the details.
Prerequisites
- A Permit.io policy to check against. See Configure your first RBAC policy.
- Your environment API key. See Get your API key.
- The Permit SDK installed in your application. See Use the Permit API and SDK.
1. Run the PDP container
Pull and run the permitio/pdp-v2 container with your API key. The container listens on http://localhost:7766. Follow Run the PDP and confirm that http://localhost:7766/health returns "status": "ok".
2. Point the SDK at the local PDP
Initialize the SDK with http://localhost:7766 as the pdp option. Replace [YOUR_API_KEY] with your environment API key:
3. Call permit.check()
Call permit.check() with a user, an action, and a resource. The SDK sends the check to the local PDP, which returns true or false. For the arguments and examples with tenants, attributes, and relationships, see Check permissions with permit.check().
Verify the local check
The decision appears in the Audit Log screen of the Permit dashboard, because the PDP uploads decision logs to Permit by default. To see each decision in the container output, set PDP_OPA_DECISION_LOG_CONSOLE=True. See Print decisions to the console.