I am trying to access data.json in rego and it doesn't work, I guess I may be doing something wrong
package rbac.authz
is_user_owner_or_viewer[data.user_attributes.DataSteward] {
true
}
{
"user_attributes" : {
"DataSteward":"acl.owners",
"DelegatedStewards": "acl.owners"
}
}
When I try to execute the same in rego playground it is working fine , but when I try to execute it using opa executable, I may be missing something. all the files are in the same folder (input.json. testPolicy.rego, data.json)
opa_windows_amd64 eval -i input.json -d testPolicy.rego "data"
https://play.openpolicyagent.org/p/2l89PLAsl3
{
"is_user_owner_or_viewer": [
"acl.owners"
]
}
"is_user_owner_or_viewer": []
Hi @Jeyakumardevarajulu
To confirm, the JSON snippet:
{
"user_attributes" : {
"DataSteward":"acl.owners",
"DelegatedStewards": "acl.owners"
}
}
is in a separate file? You will need to include it on the CLI like:
opa_windows_amd64 eval -i input.json -d testPolicy.rego -d data.json "data"
Where the input.json is the INPUT panel of the playground, the testPolicy.rego would be the policy section, and data.json is the DATA panel of the playground.
Awesome, Thanks Pat for your quick response. I was missing -d data.json. It is working now.
Most helpful comment
Awesome, Thanks Pat for your quick response. I was missing -d data.json. It is working now.