Permit.io Introduces Database-Level Authorization with Trino Integration

- Share:





2938 Members
Securing sensivite information at the database level is now a critical priority for organizations, as traditional access controls often leave gaps that expose data to unauthorized users or grant overly broad permissions that complicate compliance. To address this, we’re introducing Permit.io’s latest capability: full support for database-level authorization through seamless integration with Trino, the powerful open-source distributed SQL query engine. With this integration, teams can enforce fine-grained permissions directly at the data source, ensuring every query is evaluated and filtered before any information leaves the database.
Trino acts as a centralized gateway for querying multiple data sources, making it an ideal enforcement point for authorization. By pairing it with Permit.io's Policy Decision Point (PDP), you can manage policies centrally, apply row-level filtering, column masking, and more, all without modifying your underlying databases. This not only simplifies security but also scales effortlessly across internal tools, such as BI dashboards and external APIs. In this article, we'll explore the challenges of database access control, delve into the benefits of this integration, and provide a practical guide to getting started, complete with a demo setup inspired by real-world examples.
Whether you're an analyst safeguarding proprietary data or a developer building secure applications, this feature positions Permit.io as your go-to solution for robust, policy-based authorization. Let's break it down.
Databases are the backbone of modern applications, storing everything from customer records to financial metrics. However, as data volumes grow and access patterns become more complex, relying solely on application-layer checks or basic database roles isn't enough. Common issues include:
Permit.io addresses these by extending its authorization platform to the database layer. With Trino as the intermediary, you can route all queries through a single point, where Permit.io evaluates permissions in real-time. This setup supports advanced models like RBAC, ABAC, and ReBAC, allowing you to define policies that filter or mask data dynamically. The result? Secure, efficient access that aligns with your business logic, all managed via Permit.io's intuitive UI.
For organizations with diverse data sources—think PostgreSQL, MySQL, or even big data lakes—Trino's federation capabilities combined with Permit.io's PDP create a unified authorization layer. It's particularly valuable for multi-tenant SaaS apps, where tenant isolation is key, or enterprises needing to audit every query.
We're thrilled to roll out this integration, which builds on Permit.io's commitment to fine-grained authorization. Key highlights include:
This isn't just about security—it's about efficiency. Teams can now decouple authorization logic from databases, making it easier to update policies without downtime. Plus, it supports hybrid environments, blending Permit.io with Trino's built-in controls for admin users.
To illustrate the architecture, here's a high-level diagram showing how queries flow through the system:

In this flow, Trino consults the PDP for every query, applying Permit.io's decisions before fetching data.
Let's put this into action with a hands-on guide. We'll set up a demo environment using PostgreSQL as the backend, Trino for querying, and Permit.io for authorization. This mirrors the setup in our public GitHub repo (check it out for full code: https://github.com/permitio/trino-authz-example). The goal is to enforce policies where users can only access certain tables, with row filtering and column masking applied.
We'll create a simple multi-tenant project management app with a PostgreSQL database containing projects and tasks tables. Authorization rules:
This demonstrates database-level control for internal analysts or API consumers.
Tech stack:
Start by outlining resources and policies in plain English:
trino_sys), catalogs, schemas, tables (e.g., trino_table_postgresql_public_projects), and optionally columns.filter_only_active for rows and AddColumnMask for columns.In Permit.io's UI, create a new environment for this integration. This isolates your Trino policies.
Clone the demo repo and spin up services with Docker Compose:
git clone https://github.com/permitio/trino-authz-example.git
cd trino-authz-example
docker-compose up -d
This launches PostgreSQL, Trino, and a local PDP. Populate the database with sample data (scripts in the repo).
Next, generate an API key from your Permit.io dashboard and set it as an environment variable: export PERMIT_API_KEY=your_key_here.
Use the Permit CLI to introspect Trino and create matching resources:
permit env apply trino --url http://localhost:8080 --user trino_user --create-column-resources
This command scans catalogs, schemas, tables, and columns, mapping them to Permit.io (e.g., trino_table_postgresql_public_projects). For column-level control, the --create-column-resources flag is key.
Deploy the PDP with Trino-specific settings. In your Docker setup, enable PDP_ALLOW_UNAUTHENTICATED_TRINO=True for unauthenticated checks (secure it behind a firewall).
Create a trino-authz.yaml file for filters and masks:
columnMasking:trino_table_postgresql_public_projects:columns:- column_name: description
view_expression: "CONCAT(SUBSTRING(description, 1, 10), '...')"- column_name: secret_key
view_expression: "********"rowFilters:trino_table_postgresql_public_projects:- action: filter_only_active
expression: "status = 'active'"
Mount this to the PDP container at /app/config/trino-authz.yaml.
Update Trino's access-control.properties:
access-control.name=opaopa.policy.uri=http://pdp:7766/trino/allowedopa.policy.row-filters-uri=http://pdp:7766/trino/row-filteropa.policy.batch-column-masking-uri=http://pdp:7766/trino/batch-column-masking
Restart Trino to apply changes.
In Permit.io's Policy Editor, assign roles:
ExecuteQuery on trino_sys and full actions on tables.SelectFromColumns with conditions for filters (e.g., ABAC rule: if user.tenant == project.tenant).Sync users via Permit.io's Directory (e.g., import from your auth provider like Auth0).
Query Trino as different users. For example, using the Trino CLI:
SELECT * FROM postgresql.public.projects;
As a regular user, you'll see filtered rows (only active projects) and masked columns. Check Permit.io's audit logs to verify decisions.
If issues arise, enable logging in Trino (opa.log-requests=true) and review PDP responses.
In our demo, a user query might return:
| id | name | status | description | secret_key |
|---|---|---|---|---|
| 1 | Proj A | active | First 10 c… | ******** |
| 2 | Proj B | active | Another pr… | ******** |
This ensures sensitive data stays protected. For performance, scale the PDP horizontally if handling high query volumes.
This Trino integration exemplifies Permit.io's flexibility, turning complex authorization into a streamlined process. It reduces risk, boosts compliance, and frees developers from custom auth code. We've seen teams cut implementation time by 70% while achieving finer control than native database tools.
Ready to try it? Dive into the full demo on GitHub or explore Permit.io's docs for more on RBAC and data filtering.
Join our community on Slack (https://io.permit.io/slack) for support, or check out advanced topics like GitOps integration and AI-driven permissions. With Permit.io, database security is no longer an afterthought—it's built-in and scalable. Let's secure your data together.

Senior Software Engineer. Lead maintainer of open-source projects, including OPAL, actively managing its development, growth, and developer community engagement.