Trino authentication (Enterprise)
Trino with Ranger access control evaluates policies for the user name of each query. Without authentication, Trino takes that name from the client, so anyone who reaches Trino can query as any user. In a governed installation Trino therefore requires a password over HTTPS. The SQL editor reaches Trino through the SQL engine (Kyuubi), which signs in as a technical account and runs each query as the signed-in Ilum user; Ranger decides whether the technical account may act for that user. BI tools sign in to Trino directly with their own user. Superset signs in as an account of its own and runs each query as the user signed in to Superset (see Superset in governed mode).
How it works
- The Trino coordinator serves HTTPS on port 8443 with a certificate issued by a CA that the chart generates. Plain HTTP on port 8080 stays open for the communication between the coordinator and the workers, which is signed with a shared secret, and accepts no user requests.
- Users and the technical account sign in with a password (
PASSWORDauthentication). The chart creates Trino's password file with the technical account (and Superset's account when Superset is on); directory users are added through LDAP (see LDAP and Active Directory). - The SQL engine signs in as the technical account (
ilum-sqlby default) and sends the signed-in user as the query user. Trino asks Ranger whether the technical account may impersonate that user (trinouserresource,impersonateaccess). - A client that signs in as one user and asks to run a query as another is refused unless a Ranger policy allows it.
Enabling
values-governed.yaml of the helm_aio chart turns Trino authentication on together with the other governed
settings (see Apache Ranger):
helm upgrade --install ilum ilum/ilum -f my-values.yaml -f values-governed.yaml
It sets global.trinoAuth.enabled, HTTPS and PASSWORD authentication on the coordinator, the shared secret of
internal communication, and the SQL engine's Trino address https://ilum-trino:8443. On the first install the chart
generates three Secrets in the release namespace, four with Superset on, and keeps them on later upgrades:
| Secret | Keys | Used by |
|---|---|---|
ilum-trino-tls | ca.crt, tls.crt, tls.key, tls.pem | Trino coordinator (tls.pem), SQL engine (ca.crt) |
ilum-trino-auth | password.db, technical-password | Trino coordinator (password.db), SQL engine (technical-password) |
ilum-trino-internal | TRINO_INTERNAL_SHARED_SECRET | Trino coordinator and workers |
ilum-trino-superset | ILUM_TRINO_SUPERSET_PASSWORD, ILUM_TRINO_CA | Superset (with superset.enabled; see Superset in governed mode) |
The certificate is valid for ilum-trino and its names inside the cluster. Further host names, for example the
address that BI tools use through a load balancer, are added in global.trinoAuth.dnsNames; a change of the names
issues a new certificate on the next upgrade.
The certificate is valid for 825 days. The chart records its expiry in the annotation ilum.cloud/not-after of ilum-trino-tls and
issues a new certificate and CA at the first upgrade made less than 30 days before it, or when one of the four keys is missing from the
Secret. Ilum does not renew a certificate without an upgrade: run helm upgrade at least once a year. A Secret created by an earlier
chart version has no such annotation and is kept; delete it before an upgrade to issue a new certificate. After a new certificate, restart
the ilum-sql pod so that it reads the new CA.
With global.trinoAuth.createSecrets: false, the chart creates none of the Secrets, and Secrets with the same names and
keys are expected, for example from cert-manager or an external secret store. tls.pem holds the private key and the
certificate in one PEM file; cert-manager writes such a file as tls-combined.pem when the certificate requests the
CombinedPEM output format, in which case set trino.server.config.https.keystore.path to that file.
Trino authentication needs the Ranger base policies of the ilum_trino service, which the ilum-ranger bootstrap
creates (see Ranger policies). The SQL engine reads the technical account's password when it
starts; after a change of technical-password, restart the ilum-sql pod.
A technical-password that you supply (with createSecrets: false, or by editing the Secret) is passed to the SQL engine as a Java
option, so it may contain only letters, digits and the characters -, _, . and ~. Spaces, quotes, $, backticks, backslashes and
line breaks break the option. The generated password has 40 letters and digits.
An ilum-trino-auth Secret written by a chart version before the annotation ilum.cloud/trino-technical-user existed does not drop the
old technical account's line from password.db when global.trinoAuth.technicalUser is renamed. Delete the Secret once by hand before
the upgrade that renames the account; the chart then writes it again with the annotation (users added to password.db by hand must be
added again).
The SQL engine reaches Trino over HTTPS only with an ilum/kyuubi image built with the Trino engine patch of
ops/docker/ilum-kyuubi/patches, which the chart's default ilum/kyuubi:1.12.0-spark-trino-ilum1 carries. Apache Kyuubi
1.12 replaces the configured truststore with an empty one, and with an older image every query of the TRINO engine
fails with the trustAnchors parameter must be non-empty.
BI tools
A BI tool connects to https://<Trino address>:8443 with the JDBC URL parameter SSL=true, a user name and a password.
The tool trusts the CA in ca.crt of ilum-trino-tls:
kubectl -n <release namespace> get secret ilum-trino-tls -o jsonpath='{.data.ca\.crt}' | base64 -d > ilum-trino-ca.crt
jdbc:trino://trino.example.com:8443/hr?SSL=true&SSLTrustStorePath=/path/to/ilum-trino-ca.crt
With values-governed.yaml, Trino's NetworkPolicy admits only the SQL engine. Namespaces and address ranges of BI
tools are admitted to the HTTPS port with:
global:
trinoAuth:
clients:
namespaces: [bi-tools]
ipBlocks: [10.20.0.0/16]
Clients outside the cluster also need a route to the coordinator, such as a LoadBalancer Service
(trino.service.coordinator.type) or an Ingress with TLS passthrough.
Users in the password file
Without a directory, users are added to Trino's password file. The file holds one user:hash line per user, with a
bcrypt hash (prefix $2y$, cost 8 or more):
htpasswd -nbB -C 10 alice '<password>'
Add the lines to the key password.db of the Secret ilum-trino-auth, after the technical account's line. The chart
keeps the lines on later upgrades, and Trino reloads a changed file without a restart:
kubectl -n <release namespace> get secret ilum-trino-auth -o jsonpath='{.data.password\.db}' | base64 -d > password.db
htpasswd -nbB -C 10 alice '<password>' >> password.db
kubectl -n <release namespace> patch secret ilum-trino-auth --type merge \
-p "{\"data\":{\"password.db\":\"$(base64 -w0 password.db)\"}}"
LDAP and Active Directory
Directory users sign in through Trino's LDAP authenticator, next to the password file that keeps the technical account.
Apply the settings after values-governed.yaml:
trino:
server:
coordinatorExtraConfig: |
password-authenticator.config-files=/etc/trino/password-authenticator.properties,/etc/trino/password-authenticator-ldap.properties
coordinator:
additionalConfigFiles:
password-authenticator-ldap.properties: |
password-authenticator.name=ldap
ldap.url=ldaps://ad.example.com:636
ldap.user-bind-pattern=${USER}@example.com
ldap.user-base-dn=OU=Users,DC=example,DC=com
ldap.group-auth-pattern=(&(objectClass=user)(sAMAccountName=${USER})(memberOf=CN=GG-Trino-Users,OU=Groups,DC=example,DC=com))
The user names must be the ones that Ranger usersync brings from the same directory, because Ranger looks up a user's groups by name. For more information about the LDAP authenticator refer to Trino LDAP authentication.
Ranger policies
The ilum-ranger bootstrap creates the base policies of the ilum_trino service, which Trino needs before any query
runs:
| Resource | Access | Granted to |
|---|---|---|
queryid = * | execute | public: users may run queries; tables still need their own policies |
trinouser = {USER} | impersonate | public: each user acts as itself |
trinouser = * | impersonate | the SQL engine's technical account (global.trinoAuth.technicalUser), Superset's account (global.trinoAuth.superset.user) and ilum-ranger.bootstrap.trino.impersonators |
catalog = ilum-delta, and catalog = ilum-delta with schema = default | use, show | public: the SQL editor starts each query there (ilum-ranger.bootstrap.trino.editorSchemas) |
procedures register_table, unregister_table, migrate, add_files, add_files_from_table, register_partition, unregister_partition in every catalog and schema | execute denied | public, except ilum-ranger.bootstrap.trino.procedureAdmins |
The policies are applied when they are missing or when their settings change; the bootstrap only adds to them, so an
item removed by an administrator stays removed until the settings change. Grants on the wildcard resources join the
built-in policies all - queryid and all - trinouser, because Ranger keeps one policy per resource set.
Iceberg's add_files runs as ALTER TABLE ... EXECUTE in recent Trino releases, which Ranger checks as alter on the
table. Grant alter on governed tables only to their owners.
The SQL editor starts each Trino query with USE default in the SQL engine's default catalog
(ilum-sql.config.trino.catalog, ilum-delta by default), so the bootstrap grants use and show on that catalog and
its default schema to everyone. The grant shows the schema, not its tables. With another catalog, set
ilum-ranger.bootstrap.trino.editorSchemas to match, or the SQL editor's Trino queries fail with Cannot access catalog or Cannot access schema.
Catalogs on their own identities
A catalog reads storage with the key it is configured with. When every catalog uses the platform key, a table in any
catalog that points at a governed location is readable, whatever metastore holds it. values-governed-catalogs.yaml
gives each Trino catalog a key of its own, so such a table fails at the object store even when no Ranger policy stops
it:
| Catalog | Metastore | Storage key Secret | Reaches |
|---|---|---|---|
hr | governed metastore | ilum-trino-hr-storage | governed buckets, read |
hr_files | governed metastore | ilum-trino-hr-storage | governed buckets, read (Hive tables, CSV and Parquet) |
domains | bundled metastore | ilum-trino-domains-storage | domain buckets that SQL users may query |
published | bundled metastore | ilum-trino-published-storage | published (masked) bucket, read and write |
ilum-delta | bundled metastore | ilum-trino-domains-storage | as domains; kept so that existing queries keep working |
Create the Secrets (keys access-key and secret-key) and the Secret of the governed metastore, then apply the file
after values-governed.yaml:
helm upgrade --install ilum ilum/ilum -f my-values.yaml -f values-governed.yaml -f values-governed-catalogs.yaml
The file turns on the governed metastore and removes the platform key from the Trino pods.
Catalogs that can register tables over existing files have it turned off: delta.register-table-procedure.enabled=false
on the Delta Lake catalogs, and hive.non-managed-table-creates-enabled=false on hr_files, which refuses
CREATE TABLE ... WITH (external_location = ...). When the buckets are on another object store than the platform's,
change s3.endpoint of the catalogs in a copy of the file.
A metastore creates the directory of a new schema itself, with its own key and endpoint. The bundled metastore uses the
platform storage, so CREATE SCHEMA domains.<name> WITH (location = ...) on a bucket of another object store fails until
the metastore can reach it. Give the metastore an endpoint and a key for that bucket under
ilum-hive-metastore.conf.hiveSite (fs.s3a.bucket.<bucket>.endpoint, .aws.credentials.provider
org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider, .access.key, .secret.key); the key then sits in the metastore's
ConfigMap, so use one limited to that bucket.
Configuration
| Name | Description | Default |
|---|---|---|
global.trinoAuth.enabled | Trino requires a password over HTTPS; the SQL engine signs in as the technical account | false (true in values-governed.yaml) |
global.trinoAuth.technicalUser | Trino account of the SQL engine | ilum-sql |
global.trinoAuth.createSecrets | Generate the Secrets below and keep them across upgrades | true |
global.trinoAuth.authSecret | Password file and technical account's password | ilum-trino-auth |
global.trinoAuth.internalSecret | Shared secret of internal communication | ilum-trino-internal |
global.trinoAuth.tlsSecret | Coordinator certificate and its CA | ilum-trino-tls |
global.trinoAuth.dnsNames | Further host names of the certificate | [] |
global.trinoAuth.clients.namespaces | Namespaces of BI tools admitted to the HTTPS port | [] |
global.trinoAuth.clients.ipBlocks | Address ranges of BI tools admitted to the HTTPS port | [] |
global.trinoAuth.superset.* | Superset's Trino account and connection | see Superset in governed mode |
ilum-ranger.bootstrap.trino.impersonators | Further users that may act as any Trino user | [] |
ilum-ranger.bootstrap.trino.deniedProcedures | Procedures denied to everyone | see above |
ilum-ranger.bootstrap.trino.procedureAdmins | Users and groups that may still call them | none |
ilum-ranger.bootstrap.trino.editorSchemas | Schemas the SQL editor's Trino queries start in, open to everyone for use and show | ilum-delta.default |
Limits
- The SQL engine passes the password of the technical account to its Trino engines as a configuration value; it is
visible to processes inside the
ilum-sqlpod. - The technical accounts (
ilum-sql,ilum-superset) may act as any user. With the LDAP authenticator next to the password file, their names must not exist in the directory: a directory user of that name could sign in as the account. - The shared Trino coordinator serves every catalog. A query that a Ranger policy allows reads with the catalog's key, so the keys of the governed catalogs must reach only the governed buckets.