Skip to main content
Version: 2.0.0

Send Critical Updates

When checking permissions right after creating or syncing a user, there may be a delay in data syncing to the PDP. To reduce this latency, we’ve implemented a mechanism that sends data updates directly to the PDP first, then distributes them through OPAL (including other PDPs if you operate in multi-PDP setup).

The approach works by making calls directly to the PDP, which then forwards the facts to the connected OPAL Server. The OPAL Server will then distribute the facts to all the PDPs in the environment. The update has been added as a configuration option in the SDK which enables you to use the same favorite SDK to interact with Permit.io as you have previously without changing function calls. This approach will also ensure all other PDPs running in your environment receive those facts by forwarding the facts to the connected OPAL Server which then distributes the facts to all the PDPs in the environment.

EAP

Notice that this API is in Early Access Program stage and might be subject to changes.

Min. PDP version required

Notice that this feature is available from PDP version 0.5.1 and above.

How to configure the SDK to upload facts via the PDP

This will allow you to use the same SDK to upload facts via PDP.

from permit import Permit
# This line initializes the SDK and connects your python app
# to the Permit.io PDP container you've set up.
permit = Permit(
# your secret API KEY
token="<your-api-key>",
# In production, you might need to change this URL to fit your deployment
# This is the address where you can find the PDP container.
pdp="http://localhost:7766",
# configure the SDK to upload facts via the PDP
proxy_facts_via_pdp=True,
# Add here any more configurations that you usually use
)

After configuring you can use the normal SDK functions to upload facts and the SDK will take care of the rest.

Wait for the fact to be ready for permission check

Using the following guide you will be able to wait for the PDP to be ready to enforce permission on the newly added facts. Timeout with value 0 will respond immediately without waiting. Timeout with a positive value will wait for the facts to be synced for the specified duration. Timeout with a negative value will wait forever for the facts to be synced.

Important Note

Waiting for the facts to be synced is available only when proxy_facts_via_pdp is enabled

from permit import Permit
# This line initializes the SDK and connects your python app
# to the Permit.io PDP container you've set up.
permit = Permit(
# your secret API KEY
token="<your-api-key>",
# In production, you might need to change this URL to fit your deployment
# This is the address where you can find the PDP container.
pdp="http://localhost:7766",
# configure the SDK to upload facts via the PDP
proxy_facts_via_pdp=True,
# you can set the timeout to wait for the facts to be synced,
# in the initialization of the client - will apply for all the supported SDK calls
# as an argument to the sync_function call - will apply only for the calls inside the context manager
facts_sync_timeout=10,
# Add here any more configurations that you usually use
)

async with permit.wait_for_sync(timeout=15) as p:
user: UserRead = await p.api.users.sync(
{
"key": "auth0|elon",
"email": "elonmusk@tesla.com",
"first_name": "Elon",
"last_name": "Musk",
"attributes": {
"age": 50,
"favorite_color": "red",
},
}
)