Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Per-Query-User-Information / Impersonation #257

Merged
merged 3 commits into from
Apr 13, 2024

Conversation

FabianScheidt
Copy link
Member

@FabianScheidt FabianScheidt commented Mar 12, 2024

One of the awesome features in Trino is that the session user can be different from the authenticated user. This allows the authenticated user to impersonate other users.

This PR adds a settings that allows to impersonate the current Grafana user, so we can use the same connection and dashboards for users with different permissions (similar to what we can do with Apache Superset). If enabled, the current user login will be passed as X-Trino-User.

Hope you find this useful and consider merging. I'm happy to make changes if needed.

Fixes #251

Copy link

cla-bot bot commented Mar 12, 2024

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Copy link
Member

@nineinchnick nineinchnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, I would have never figured it out myself, thanks!

src/ConfigEditor.tsx Outdated Show resolved Hide resolved
Copy link

cla-bot bot commented Mar 12, 2024

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@nineinchnick
Copy link
Member

@cla-bot check

Copy link

cla-bot bot commented Mar 18, 2024

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Copy link

cla-bot bot commented Mar 18, 2024

The cla-bot has been summoned, and re-checked this pull request!

@FabianScheidt
Copy link
Member Author

Seems like my CLA has been processed :)

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Apr 4, 2024
Copy link

cla-bot bot commented Apr 4, 2024

The cla-bot has been summoned, and re-checked this pull request!

@nineinchnick
Copy link
Member

I'll test this manually, merge this and do a new release somewhere over the weekend.

@FabianScheidt
Copy link
Member Author

Oh, if you need a test setup, here's mine: It's the Example HTTP Connector with File-based access control. If you build a dashboard for the numbers table, admin should be able to see all contents. If you impersonate alice, she should only see even numbers.

example-http.properties
connector.name=example-http
metadata-uri=https://trino-http-example.s3.eu-central-1.amazonaws.com/example-metadata.json
access-control.properties
access-control.name=file
security.config-file=/etc/trino/rules.json
rules.json
{
  "tables": [
    {
      "user": "alice",
      "catalog": "example-http",
      "schema": "example",
      "table": "numbers",
      "privileges": ["SELECT"],
      "filter": "value % 2 = 0"
    },
    {
      "user": "alice",
      "privileges": ["SELECT"]
    },
    {
      "user": "admin",
      "privileges": ["SELECT"]
    }
  ],
  "impersonation": [
    {
      "original_role": "admin",
      "new_user": ".*",
      "allow": true
    }
  ]
}

@nineinchnick nineinchnick merged commit e5336a1 into trinodb:main Apr 13, 2024
2 checks passed
@nineinchnick
Copy link
Member

1.0.7 was just accepted by Grafana and published in their catalog, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants