hi, I have a question about limiting / blocking so...
# opal
d
hi, I have a question about limiting / blocking some credential data to be shown to public in opal. as i known, we could write a
system.rego
file like below to limit the url.
Copy code
# system.rego
allow if {
    input.method == "POST" 
    input.path == ["v1", "data", "token"]
}
however, this would block the data update for that url. we know that the best benefit would be real-time data update in opal. so would there be any problem to trigger using
curl --request POST '<https://opa.xxx.xxx/data/config>'
. great thanks!
a
Hi @Dai Zhang, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
Based on the OPAL documentation, there are several ways to handle data updates without exposing sensitive credentials publicly. For publishing data updates, you should use the OPAL client CLI to push updates rather than directly accessing OPA endpoints (1) . The proper way to trigger updates is:
Copy code
opal-client publish-data-update --src-url <https://api.country.is/23.54.6.78> -t policy_data --dst-path /users/bob/location
This publishes updates through OPAL's pub/sub system without exposing the data directly . For sensitive data configuration, you can use the
OPAL_DATA_CONFIG_SOURCES
environment variable with authentication headers (2) (3) :
Copy code
{
  "config": {
    "entries": [
      {
        "url": "<http://host.docker.internal:8000/permissions.json>",
        "topics": [
          "permissions"
        ],
        "dst_path": "/course_permissions"
      }
    ]
  }
}
(4) If you need to include authentication for secure data sources, you can add headers to the configuration (3) :
Copy code
"config": {"headers": {"Authorization": "Bearer glpat-tx5AxRcPgT1VKt37HPrz"}}
OPAL sends instructions to clients on how to fetch data directly rather than sending the data itself through the pub/sub channel (4) . This approach maintains security while enabling real-time updates. For your specific concern about blocking data updates with
system.rego
, the recommended approach is to use OPAL's built-in data update mechanisms rather than directly posting to OPA endpoints, as this maintains both security and real-time update capabilities (1) (4) .
To learn more, see the sources I considered: [[1] Step 4: Publishing a data update via the OPAL Server](https://docs.opal.ac/getting-started/quickstart/opal-playground/publishing-data-update) [[2] OPAL Configuration Guide | OPAL](https://docs.opal.ac/getting-started/configuration) [[3] OPAL Client Redirected to GitLab Sign-In Page Despite Access Token in OPAL_DATA_CONFIG_SOURCES](https://github.com/permitio/opal/discussions/609) [[4] Data updates](https://docs.opal.ac/faq/)
d
when adding options like
"authorization":"basic"
in
OPAL_INLINE_OPA_CONFIG
, the client could not be able to start successfully.
o
@Ask Inkeep
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
When configuring
OPAL_INLINE_OPA_CONFIG
with authorization settings, the configuration needs to be properly formatted as a JSON object (1) . The
OPAL_INLINE_OPA_CONFIG
setting controls how OPA starts when running inline with OPAL, and the default value is
{}
. This configuration affects the server options that are passed to
opa run --server
. If the client isn't starting successfully with authorization settings, ensure: 1. The JSON is properly escaped and formatted 2. The configuration matches OPA's expected server configuration format For authentication between OPAL client and the policy store (OPA) , you should use
OPAL_POLICY_STORE_AUTH_TYPE
instead, which supports options:
none
,
oauth
,
token
. If using token authentication, set
OPAL_POLICY_STORE_AUTH_TOKEN
with the bearer token . Additionally, if you're having startup issues with your configuration, please share: 1. Which Workspace / Project / Env you are using 2. What calls you are performing (as SDK code or CURL) 3. Which PDP version you are running 4. Relevant logs from your PDP This will help our engineers investigate the specific issue you're encountering.
To learn more, see the sources I considered: [[1] OPAL Configuration Guide | OPAL](https://docs.opal.ac/getting-started/configuration)
d
@Or Weis ai agent's solution won't help out. so if I want to use
data
to store some credentials used by policy but I don't want it to be directly accessed by public. how could i achieved that. great thanks!
o
I don't recommend that path. OPAL is meant to propagate data and policy for decision making not secrets. if you want to propagate secrets use a secrets management solution, like K8s secrets. if you insist on this path, I'd block access to OPA all together for non authenticated calls
d
got it. however, it's a usecase in opa. when blocking the access in
system.rego
, the data will disappear in all his parent url. I will try to find some solutions. thanks!