Skip to content

Conversation

@Flgado
Copy link
Member

@Flgado Flgado commented May 15, 2025

This PR adds support for specifying catalog roles in the Trino Go client via both the DSN string and the Config struct. Roles are passed as either:

  • A map[string]string mapping catalogs to roles (e.g. {"hive": "analyst", "system": "admin"})

The roles are URL-encoded and appended to the DSN as a colon-separated list of catalog=ROLE{role} entries.

Example

// Using role map
c := &Config{
    ServerURI: "https://user@localhost:8080",
    Roles: map[string]string{"hive": "analyst", "system": "admin"},
}

using directly the dns connection

dns := ...?roles=catalog1:role1;catalog2:role2

@cla-bot cla-bot bot added the cla-signed label May 15, 2025
@Flgado Flgado requested a review from nineinchnick May 18, 2025 14:05
@nineinchnick
Copy link
Member

@Flgado would you like to get back to this?

@Flgado
Copy link
Member Author

Flgado commented Nov 20, 2025

@nineinchnick Sure! I’m a bit busy these days, but I can pick this up in the next few days. 👍🏻

@Flgado
Copy link
Member Author

Flgado commented Nov 23, 2025

@nineinchnick, do we want to support the X-Trino-Role header when it's provided as a named argument?

For example: db.Query("SELECT * FROM foobar WHERE id = ?", 1, sql.Named("X-Trino-Role", ...))

If so, that should overwrite the roles on the connection string ?
Can this be a security concern ?

@nineinchnick
Copy link
Member

We can allow it, and it's not a security concern. The same program that creates the db connection executes the queries. It would be a good workaround for the unsupported SET ROLE query - we don't handle the X-Trino-Set-Role header in server responses.

@Flgado
Copy link
Member Author

Flgado commented Nov 27, 2025

@nineinchnick can you take a look ?
I am not sure if a argName we should pass the roles as catalog:role1;catalog2:role2 like it is on dsn. Let me know what you think :)

@nineinchnick nineinchnick added the enhancement New feature or request label Nov 28, 2025
@nineinchnick nineinchnick merged commit 8a6a022 into trinodb:master Nov 29, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

2 participants