You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/opa/pages/usage-guide/resource-info-fetcher.adoc
+52-7Lines changed: 52 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
:description: Resource Info Fetcher for OPA retrieves data from backends like DataHub. Integrate extra resource details into Rego rules for enhanced policy management.
3
3
4
4
The _Resource info fetcher_ allows for additional information to be obtained from the configured backend (for example, DataHub).
5
-
You can then write Rego rules for OpenPolicyAgent which make an HTTP request to the Resource info fetcher and make use of the additional information returned for the resource, such as Trino tables or Kafka topic.
5
+
You can then write Rego rules for OpenPolicyAgent which make an HTTP request to the Resource info fetcher and make use of the additional information returned for the resource, such as Trino tables or Apache Kafka topics.
6
6
7
7
You can enable the Resource info fetcher sidecar as follows:
8
8
@@ -45,7 +45,7 @@ stringData:
45
45
<1> Enable the `resource-info-fetcher` sidecar
46
46
<2> Enable TLS verification using the CA from the `tls` SecretClass.
47
47
<3> Authenticate to DataHub with a Personal Access Token (PAT) read from the specified Secret. The Secret must have a `token` entry. See the DataHub documentation on https://docs.datahub.com/docs/authentication/personal-access-tokens[Personal Access Tokens] for how to create one, and make sure https://docs.datahub.com/docs/authentication/introducing-metadata-service-authentication[Metadata Service Authentication] is enabled on your DataHub.
48
-
<4> The DataHub environment (fabric) to query, e.g. `PROD` or `DEV`. Defaults to `PROD`.
48
+
<4> The DataHub environment (fabric) to query, e.g. `PROD` or `DEV`. Defaults to `PROD`, which is also what DataHub's ingestion sources default to.
49
49
50
50
Currently the following backends are supported:
51
51
@@ -65,7 +65,33 @@ DataHub is currently only supported backend, so the general documentation from a
65
65
66
66
== Resource info fetcher API
67
67
68
-
Resource information can be retrieved from regorules using the functions `TODO` in `data.stackable.opa.resourceinfo.v1`.
68
+
Resource information can be retrieved from regorules using the functions in `data.stackable.opa.resourceinfo.v1`.
The naming is intentionally product-agnostic, so that one function serves the equivalent resource of every product.
84
+
`databaseResourceInfo` addresses what Trino calls a catalog, and `streamResourceInfo` what Apache Kafka calls a topic.
85
+
86
+
`rawIdentifierResourceInfo` is the escape hatch for resources the functions above do not cover: it passes the identifier to the backend as-is.
87
+
For DataHub that is a URN, such as `urn:li:chart:(superset,my-namespace/my-superset.1)`.
88
+
89
+
The first two arguments are the same everywhere:
90
+
91
+
* `system` is the kind of product the resource lives in, for example `trino`, `kafka` or `superset`. DataHub calls this the _data platform_.
92
+
* `instance` identifies _which_ deployment of that product, for example `my-namespace/my-trino`. DataHub calls this the _platform instance_, and the value must match the `platform_instance` of the ingestion source that produced the metadata.
93
+
94
+
The DataHub environment (fabric) is deliberately *not* an argument: it describes how the catalog was populated rather than the resource being authorized, so it is configured once on the OpaCluster (see `env` above) instead of being passed in by every Rego rule.
69
95
70
96
An example of the returned structure:
71
97
@@ -99,22 +125,41 @@ An example of the returned structure:
99
125
100
126
=== Debug request
101
127
102
-
To debug the resource-info-fetcher you can `curl` it's API for a given resource.
128
+
To debug the resource-info-fetcher you can `curl` its API for a given resource.
129
+
Every Rego function above maps to a `GET /metadata/<resource type>` endpoint that takes its arguments as query parameters.
103
130
To achieve this shell into the `opa` container and execute
A resource the backend does not know about is not reported as an error: the resource-info-fetcher returns a record with empty `tags`, `owners` and `dataProducts` and a `null` `domain`.
164
+
Prefer rules that require a positive signal, like the one above, which denies access in that case.
165
+
A rule that merely excludes a tag would instead grant access to every resource missing from the backend.
0 commit comments