Should OPA only be used to make decisions based solely on trusted data? #126
clsweeting
started this conversation in
Community
Replies: 1 comment 2 replies
-
It is true that the provider of the device ID data in your case needs to be trusted. If you wish to avoid making external calls at policy evaluation time, the common approach is to provide data via bundles. Bundles are commonly deployed via servers like Nginx, or AWS S3. TLS should help ensure the server is who it says it is, and you can optionally sign the bundles to if you want something close to what you get from JWTs in the input. See the section on bundle signing in the bundle docs for that. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It seems that providing all of the necessary context (i.e. data relationships) for OPA to make decisions based on fully-validated data could add additional overhead to OPA/Rego. I'm wondering how others are approaching this, and whether it was the original design goal of OPA to actually solve for this or to allow the making of 'provisional decisions'.
For example, consider an API to update the information for a 'device':
We wish to authorize requests to an API endpoint such as:
PUT /customers/{customerId}/devices/{deviceId}
Only users who have the
device:admin
role should be able to perform the above operation.The user's access token (JWT) contains a
roles
claim which indicates the user's roles. The access token also includes thecustomerId
.However all of the devices in the particular customer (tenant) are not included in the access token due to the sheer number of possible devices.
We have an Envoy proxy forwarding incoming requests to an OPA sidecar using the external authorization filter to validate the request based on the path and access token.
We then will have a Rego policy which:
/customers/{customerId}/devices/{deviceId}
) and method (PUT).customerId
from the request path, and ensures that it matches the customerId in the access token.In the above scenario, OPA can trust the
customerId
since it is in the user's access token (signed JWT) but OPA does not validate that the device with IDdeviceId
actually belongs to the customer with IDcustomerId
. Is this a problem?On the one hand, OPA can make a policy decision based on the operation and OPA can validate that the user belongs to the Customer (tenant). BUT any authorization approval would be provisional on the API endpoint performing the data integrity check - i.e. validating that the Device belongs to the Customer. (This adds little overhead and should be done anyway by an API making CRUD updates to a relational database.)
Alternatively, we could have OPA/Rego make an external call to the database (potentially via an internal API) to verify that the device (identified by
deviceId
) belongs to the customer identified bycustomerId
. This adds latency to the OPA authorization call, adds more complexity to OPA/Rego, and seems to defeat much of the distributed policy-decision-making which we had.... but provides the guarantee that OPA's decisions are based on 100% trusted data.I'd be interested in any thoughts on how to approach this.
Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions