Triggering Data Updates
OPAL allows for other components to notify it (and through it all the OPAL clients , and their next-door policy agents) of data updates, triggering each client [subscribed to the published topic] to fetch the data it needs.
What is this good for?
Let's try an example - say your application has a billing service, and you want to allow access only to users who have billing enabled (enforced via a policy agent). You now need changes to the state of the billing service to be propagated to each of the enforcement points/agents (and preferably instantly [Users who've paid - don't like to wait 😅 ]). With the OPAL's data-update-triggers feature the billing-service, another service monitoring it, or even a person can trigger updates as they need - knowing OPAL will take it from there to all the points that need it.
First, you need to obtain a data-source identity token (JWT)
Every service that publishes to OPAL needs a datasource
identity token.
Obtaining one is easy, but you need access to the corresponding OPAL Server master token.
Obtain a data source token with the cli:
opal-client obtain-token $OPAL_AUTH_MASTER_TOKEN --server-url=$YOUR_SERVERS_ADDRESS --type datasource
If you don't want to use the cli, you can obtain the JWT directly from the deployed OPAL server via its REST API:
curl --request POST 'https://opal.yourdomain.com/token' \
--header 'Authorization: Bearer MY_MASTER_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"type": "datasource",
}'
The /token
API endpoint can receive more parameters, as documented here.
This example assumes that:
- You deployed OPAL server to
https://opal.yourdomain.com
- The master token of your deployment is
MY_MASTER_TOKEN
.- In real life, use a cryptographically secure secret. If you followed our tutorials while deploying OPAL, you probably generated one with
opal-server generate-secret
.
- In real life, use a cryptographically secure secret. If you followed our tutorials while deploying OPAL, you probably generated one with