Hi team, I'm integrating Trino with <Permit.io> fo...
# general
b
Hi team, I'm integrating Trino with Permit.io for Row Filtering and Column Masking. However, I'm facing a 'deny-all' behavior. Trino sends authorization checks for everything (loading catalogs, system metadata, etc.), and the OPA logs show that every single request is returning
result: false
. Could you please help me identify the root cause of this issue?
this is my trino-authz.yaml
Copy code
rowFilters:
  trino_table_mariadb_demo_petition:
    - action: view_all
      expression: "1=1"
    - action: view_own_data
      expression: "prosecution_unit_id = (SELECT department_id FROM user_position_department JOIN users ON users.id = user_position_department.user_id WHERE users.username = current_user)"
    - action: view_part_data
      expression: "prosecution_unit_id IN (SELECT id FROM prosecution_unit WHERE parent_id = (SELECT department_id FROM user_position_department JOIN users ON users.id = user_position_department.user_id WHERE users.username = current_user) UNION SELECT department_id FROM user_position_department JOIN users ON users.id = user_position_department.user_id WHERE users.username = current_user)"
# Note:
# - The resource name follows the format: trino_table_{catalog}_{schema}_{table}
# - The 'action' corresponds to the action in your Permit policy
# - The 'expression' is the SQL WHERE clause that will be applied to queries
# - Multiple filters can be defined per table
# - If a user has permission for multiple actions, all corresponding expressions will be returned

# Column Masking Configuration
columnMasking:
  trino_table_mariadb_demo_petition:
    action: view_sensitive_data

    columns:
      # 1. Che hoàn toàn nội dung chi tiết
      - column_name: content
        view_expression: "'*** NỘI DUNG ĐÃ BỊ ẨN ***'"

      # 2. Che một phần trích yếu (chỉ hiện 10 ký tự đầu)
      - column_name: subject
        view_expression: "CONCAT(SUBSTRING(subject, 1, 10), '...')"

      # 3. Làm giả ID người tạo (để bảo vệ người tố giác)
      - column_name: create_by_user_id
        view_expression: "-1"

# Note for Column Masking:
# - The resource name follows the same format as row filters: trino_table_{catalog}_{schema}_{table}
# - The 'action' at the table level is the default action for all columns
# - Each column can optionally override the action
# - The 'view_expression' is the SQL expression that will be used to mask the column
# - Optional 'identity' field allows evaluating the expression as a different user
# - Column masks are applied based on permissions:
#   * Table-level permission: user has 'action' permission on the table resource
#   * Column-level permission: user has 'action' permission on the specific column resource
#   * A mask is applied if EITHER table-level OR column-level permission is granted
a
Hey @B22DCCN393 Nguyễn Việt Huy, I'll make sure the person handling this sees the message and will circle back to you.
b
Ah, I figured it out! The issue stems from the
trino-authz-example
. The Permit CLI command automatically generates a lot of system-level permissions there, but I had only defined specific resources and actions in my
trino-authz.yaml
. That explains the mismatch.
By the way, could you provide clearer documentation regarding the system permissions that Trino sends to OPA? I'd like to understand exactly which operations (like
FilterCatalogs
) are checked by default so I can configure them correctly
d
Hey @B22DCCN393 Nguyễn Việt Huy, good job for figuring that out! 💪 General tip here - you can checkout the Audit Logs from your environment to see what checks has been denied for you, so you could adjust your policy / permissions to grant that access. The Trino System resource has some top-level actions like ExecuteQuery and ImpersonateUser. The Permit CLI command automatically generates it for you, or you can adjust it as you go with more actions as needed to allow access as needed (from evaluating denied checks from the Audit Logs for example). Trino internally implement what it checks for when doing operations. They don't document it directly, but we've extracted all of the actions currently implemented in Trino's code, and all of them are created automatically when generating the policy using the Permit CLI command. My recommendation would be to grant least access to being with, reviewing denied checks as you go and granting needed permissions if necessary. This will make sure you are in control of what is allowed or denied for each of your roles as you go. Feel free to ask followup questions if you have any 🙂
✅ 1
❤️ 1