Skip to content

Commit 0869bda

Browse files
committed
improve trino docs
1 parent 89c8dd9 commit 0869bda

File tree

1 file changed

+56
-54
lines changed

1 file changed

+56
-54
lines changed

docs/integrations/database-access-control/trino-integration.mdx

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,40 @@ or other applications.
2525
## Quick Start
2626

2727
1. **Prepare Permit**
28-
- Create a new [Permit environment](/manage-your-account/projects-and-env#creating-a-new-environment) dedicated to the Trino cluster.
29-
- Copy the PDP API key from the dashboard.
28+
- Create a new [Permit environment](/manage-your-account/projects-and-env#creating-a-new-environment) dedicated to the Trino cluster.
29+
- Copy the PDP API key from the dashboard.
3030
2. **Sync the schema**
31-
- Install the latest [Permit CLI](/how-to/permit-cli).
32-
- Run `permit env apply trino --url http://<trino-host>:8080 --user <trino-user>` and point it at a user that can read cluster metadata.
33-
- The CLI introspects catalogs, schemas, tables, functions, and (optionally) columns, then creates matching resources and actions in Permit.
31+
- Install the latest [Permit CLI](/how-to/permit-cli).
32+
- Run `permit env apply trino --url http://<trino-host>:8080 --user <trino-user>` and point it at a user that can read cluster metadata.
33+
- The CLI introspects catalogs, schemas, tables, functions, and (optionally) columns, then creates matching resources and actions in Permit.
3434
3. **Deploy the PDP**
35-
- Run a Permit PDP that targets the same environment. Ensure Trino can reach it (default port `7766`).
36-
- Enable `PDP_ALLOW_UNAUTHENTICATED_TRINO=True` to allow unauthenticated Trino queries to be checked by the PDP.
35+
- Run a Permit PDP that targets the same environment. Ensure Trino can reach it (default port `7766`).
36+
- Enable `PDP_ALLOW_UNAUTHENTICATED_TRINO=True` to allow unauthenticated Trino queries to be checked by the PDP.
37+
- Optionally, [mount a Trino authz config file](/concepts/pdp/configuration#pdp_trino_authz_config_path) at to define filtering rules.
3738
4. **Configure Trino to use the PDP for access control**
38-
- Configure the Trino's `/etc/trino/access-control.properties` to call the PDP:
39-
```yaml
40-
access-control.name=opa
41-
opa.policy.uri=http://<pdp-host>:7766/trino/allowed
42-
opa.policy.row-filters-uri=http://<pdp-host>:7766/trino/row-filter
43-
opa.policy.batch-column-masking-uri=http://<pdp-host>:7766/trino/batch-column-masking
44-
opa.log-requests=true
45-
opa.log-responses=true
46-
```
47-
- Restart the Trino coordinator.
39+
- Configure the Trino's `/etc/trino/access-control.properties` to call the PDP:
40+
```yaml
41+
access-control.name=opa
42+
opa.policy.uri=http://<pdp-host>:7766/trino/allowed
43+
opa.policy.row-filters-uri=http://<pdp-host>:7766/trino/row-filter
44+
opa.policy.batch-column-masking-uri=http://<pdp-host>:7766/trino/batch-column-masking
45+
opa.log-requests=true
46+
opa.log-responses=true
47+
```
48+
- Restart the Trino coordinator.
4849
5. **Assign policies**
49-
- Use the [Permit Policy Editor](https://app.permit.io/policy-editor) (or via API, SDK, etc.) to grant roles actions such as `trino_sys#ExecuteQuery` and table-level `SelectFromColumns`.
50-
- Test queries as different users and confirm audit entries appear both in Permit and Trino.
51-
- Use the [Permit Audit Logs](https://app.permit.io/audit-log) to review the access control decisions.
50+
- Use the [Permit Policy Editor](https://app.permit.io/policy-editor) (or via API, SDK, etc.) to grant roles actions such as `trino_sys#ExecuteQuery` and table-level `SelectFromColumns`.
51+
- Test queries as different users and confirm audit entries appear both in Permit and Trino.
52+
- Use the [Permit Audit Logs](https://app.permit.io/audit-log) to review the access control decisions.
5253

5354
Want a sandbox that shows the full stack running? Try the public demo: https://github.com/permitio/trino-authz-example
5455

5556
:::warning Warning:
56-
Trino does not currently support passing an API key or credentials when calling external authorization endpoints.
57+
Trino does not currently support passing an API key or credentials when calling external authorization endpoints.
5758
As a result, you must expose the PDP's Trino authorization routes (such as `/trino/allowed`, `/trino/row-filter`, `/trino/batch-column-masking`) without authentication, by setting `PDP_ALLOW_UNAUTHENTICATED_TRINO=True`.
5859

59-
Because these endpoints are unauthenticated, **do not expose your PDP** to the public internet or any untrusted networks.
60-
Always deploy the PDP behind a firewall or within a secure, trusted network accessible only by the Trino cluster.
60+
Because these endpoints are unauthenticated, **do not expose your PDP** to the public internet or any untrusted networks.
61+
Always deploy the PDP behind a firewall or within a secure, trusted network accessible only by the Trino cluster.
6162

6263
For more information, follow the [Trino issue](https://github.com/trinodb/trino/issues/27022) on this topic.
6364
:::
@@ -74,14 +75,14 @@ Access is granted only when the user is permitted for **all** required columns.
7475
This allows scenarios where a user lacks table-level permissions but can still read a safe subset of columns.
7576

7677
```mermaid
77-
%%{
78+
%%{
7879
init: {
7980
"theme": "base",
8081
"themeVariables": { "wrap": "false" },
81-
"flowchart": {
82+
"flowchart": {
8283
"curve": "linear",
8384
"markdownAutoWrap":"false",
84-
"wrappingWidth": "600"
85+
"wrappingWidth": "600"
8586
}
8687
}
8788
}%%
@@ -106,7 +107,8 @@ You can generate Permit column resources automatically with the CLI flag `--crea
106107

107108
### Column-masking
108109

109-
Permit can instruct Trino to mask sensitive column values instead of blocking the query outright. Masks are defined in a YAML file that the PDP reads on startup:
110+
Permit can instruct Trino to mask sensitive column values instead of blocking the query outright.
111+
Masks are defined in a YAML file that the PDP reads on startup:
110112

111113
```24:38:trino-authz-example/trino-authz.yaml
112114
columnMasking:
@@ -125,7 +127,7 @@ columnMasking:
125127
view_expression: "CONCAT(SUBSTRING(description, 1, 10), '...')"
126128
```
127129

128-
Masks return only when the user (or role) has the corresponding Permit action.
130+
Masks return only when the user (or role) has the corresponding Permit action.
129131
You can review the [Audit Logs](https://app.permit.io/audit-log) to see the Permit action checked on the table resource, causing the mask to be applied.
130132

131133
For more information, see the [Trino documentation](https://trino.io/docs/current/security/opa-access-control.html#column-masking).
@@ -186,61 +188,61 @@ Every query to Trino triggers a call to the PDP. Permit returns `allow` or `deny
186188

187189
### Permit / Trino Resource Mapping
188190

189-
When the Permit PDP receives an authorization request from Trino, it maps the request into a `permit.check()` call.
191+
When the Permit PDP receives an authorization request from Trino, it maps the request into a `permit.check()` call.
190192
The resource name and actions are converted to the corresponding Trino resource and action the user is trying to perform.
191193

192-
All queries are checked with the current Trino user's identity, with permissions on the "default" tenant.
194+
All queries are checked with the current Trino user's identity, with permissions on the "default" tenant.
193195
You can use Trino's several Authentication mechanisms to identify the user, like [JWT](https://trino.io/docs/current/security/jwt.html) or [OAuth2](https://trino.io/docs/current/security/oauth2.html).
194196

195197
By default, if the query does not match any resource or action in Permit, the request is denied. You are not required to create a resource for every table in your database.
196198

197199
#### System Scope
198200

199-
**Resource Name:** `trino_sys`
200-
**Actions:** `ExecuteQuery`, `ImpersonateUser`, `SetSystemSessionProperty`
201+
**Resource Name:** `trino_sys`
202+
**Actions:** `ExecuteQuery`, `ImpersonateUser`, `SetSystemSessionProperty`
201203

202204
This resource represents the entire Trino system. Actions here apply at the highest level, governing general permissions such as running queries or impersonating users across the cluster.
203205

204206
#### Catalog
205207

206-
**Resource Name:** `trino_catalog_<catalog>`
207-
**Actions:** `AccessCatalog`, `FilterCatalogs`, `DropCatalog`
208+
**Resource Name:** `trino_catalog_<catalog>`
209+
**Actions:** `AccessCatalog`, `FilterCatalogs`, `DropCatalog`
208210

209211
A catalog in Trino represents a data source connection—such as a database or data warehouse. This resource governs access and management permissions for that catalog.
210212

211213
#### Schema
212214

213-
**Resource Name:** `trino_schema_<catalog>_<schema>`
214-
**Actions:** `ShowSchemas`, `CreateSchema`, `SetSchemaAuthorization`
215+
**Resource Name:** `trino_schema_<catalog>_<schema>`
216+
**Actions:** `ShowSchemas`, `CreateSchema`, `SetSchemaAuthorization`
215217

216218
A schema organizes database objects within a catalog, grouping related tables. This resource allows control over schema-level actions like listing, creating, or administering schemas.
217219

218220
#### Table / View / Materialized View
219221

220-
**Resource Name:** `trino_table_<catalog>_<schema>_<name>`
221-
**Actions:** `SelectFromColumns`, `InsertIntoTable`, `FilterColumns`, `SetTableProperties`, custom row-filter and column-mask actions
222+
**Resource Name:** `trino_table_<catalog>_<schema>_<name>`
223+
**Actions:** `SelectFromColumns`, `InsertIntoTable`, `FilterColumns`, `SetTableProperties`, custom row-filter and column-mask actions
222224

223-
This resource covers tables, views, and materialized views within a schema, representing structured sets of data.
225+
This resource covers tables, views, and materialized views within a schema, representing structured sets of data.
224226
Actions here usually correspond to reading, writing, filtering, or updating attributes of each table-like object.
225227

226228
#### Column (optional)
227229

228-
**Resource Name:** `trino_column_<catalog>_<schema>_<table>_<column>`
229-
**Actions:** `SelectFromColumns`, custom column-mask actions
230+
**Resource Name:** `trino_column_<catalog>_<schema>_<table>_<column>`
231+
**Actions:** `SelectFromColumns`, custom column-mask actions
230232

231233
This resource represents a specific column within a table or view, and enables fine-grained access or masking rules at the column level.
232234

233235
#### Function
234236

235-
**Resource Name:** `trino_function_<catalog>_<schema>_<function>`
236-
**Actions:** `ExecuteFunction`, `CreateFunction`
237+
**Resource Name:** `trino_function_<catalog>_<schema>_<function>`
238+
**Actions:** `ExecuteFunction`, `CreateFunction`
237239

238240
A function in Trino is a reusable computation or operation available within a schema. This resource is used to control who can execute or create that function.
239241

240242
#### Procedure
241243

242-
**Resource Name:** `trino_procedure_<catalog>_<schema>_<procedure>`
243-
**Actions:** `ExecuteProcedure`
244+
**Resource Name:** `trino_procedure_<catalog>_<schema>_<procedure>`
245+
**Actions:** `ExecuteProcedure`
244246

245247
Procedures are database routines in Trino that perform complex operations. This resource represents permission to execute those procedures.
246248

@@ -256,9 +258,9 @@ The Permit CLI can generate the Permit resources for your Trino schema automatic
256258
permit env apply trino --url http://<trino-host>:8080 --user <trino-user>
257259

258260
# Usage: permit env apply trino [options]
259-
#
261+
#
260262
# Apply permissions policy from a Trino schema, creating resources from catalogs, schemas, tables, columns.
261-
#
263+
#
262264
# Options:
263265
# --api-key [api-key] API key for Permit authentication
264266
# -u, --url <url> Trino cluster URL (e.g., http://localhost:8080)
@@ -272,9 +274,9 @@ permit env apply trino --url http://<trino-host>:8080 --user <trino-user>
272274

273275
The command will need permissions to read the Trino schema. You can use the `--user` flag to specify a user that has the necessary permissions.
274276

275-
The command only adds resources. Removing a table or column in Trino does not delete the Permit resource automatically; you can remove the resource manually in the Permit UI.
277+
The command only adds resources. Removing a table or column in Trino does not delete the Permit resource automatically; you can remove the resource manually in the Permit UI.
276278

277-
Modifying the Trino schema, like adding a new table or column, will not automatically update the Permit resources.
279+
Modifying the Trino schema, like adding a new table or column, will not automatically update the Permit resources.
278280
You will need to run the command again to add the new resources. Trino resources that are not mapped to Permit resources will be denied.
279281

280282
### PDP Trino config file
@@ -311,7 +313,7 @@ rowFilters:
311313
- action: filter_out_todo
312314
```
313315
314-
After updating the file, restart the PDP so the changes take effect.
316+
After updating the file, restart the PDP, so the changes take effect.
315317
316318
### Trino coordinator configuration
317319
@@ -326,13 +328,13 @@ opa.log-requests=true
326328
opa.log-responses=true
327329
```
328330
329-
After updating the file, restart the coordinator so the plugin reloads its configuration.
331+
After updating the file, restart the coordinator, so the plugin reloads its configuration.
330332
331333
## Operational considerations
332334
333335
### Multiple access control systems
334336
335-
Trino supports [multiple access control systems](https://trino.io/docs/current/security/built-in-system-access-control.html#multiple-access-control-systems).
337+
Trino supports [multiple access control systems](https://trino.io/docs/current/security/built-in-system-access-control.html#multiple-access-control-systems).
336338
Using that, you can combine Permit authorization for application users, and Trino's built-in file-based access control for administrative users.
337339
338340
### Trino authentication
@@ -345,10 +347,10 @@ For more information, see the [Trino authentication documentation](https://trino
345347
346348
### Policy isolation
347349
348-
We recommend using a dedicated Permit project and environments for the Trino cluster authorization.
350+
We recommend using a dedicated Permit project and environments for the Trino cluster authorization.
349351
This will help you isolate the authorization decisions from the rest of your data.
350352
351-
Your database schema can include many resources and actions.
353+
Your database schema can include many resources and actions.
352354
Using a dedicated Permit project and environments will help you manage the complexity, follow audit trails, and isolate the authorization decisions from the rest of your data.
353355
354356
Read more about [Permit projects and environments](/manage-your-account/projects-and-env).

0 commit comments

Comments
 (0)