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

Impersonate database user when running queries #2148

Closed
xlows-1227 opened this issue Feb 10, 2017 · 10 comments
Closed

Impersonate database user when running queries #2148

xlows-1227 opened this issue Feb 10, 2017 · 10 comments
Assignees

Comments

@xlows-1227
Copy link

The superset start with root and login with user abc
When I query a sql in sqllab (SQLAlchemy is presto),it run with root in presto,How to run with abc??

@xrmx xrmx added the question label Feb 10, 2017
@xrmx
Copy link
Contributor

xrmx commented Feb 10, 2017

I think you are running queries with the credentials you set up on your datasources.

@xlows-1227
Copy link
Author

It running queries with onlt root,i want to know how can i run with login user?

@juanpampliega
Copy link

Hi, I am also interested in knowing if this is possible.
For most datasources it doesn't make much sense but for Presto that we don't have authentication setup it would be nice for the query to be executed with the login user rather than the superset user.

@mistercrunch mistercrunch changed the title How Can I Run sql on sqllab with login user? Impersonate database user when running queries Aug 11, 2017
@mistercrunch
Copy link
Member

I don't think PyHive (the lib we use to connect to presto) allows for that, does it?

@mistercrunch
Copy link
Member

Actually looks like it may be possible by just using a different connection string as in create_engine('presto://user@host:443/hive'). Would you assume that the superset username matches the presto username?

You'd want to add a configuration Boolean column impersonate_user to the Database model https://github.com/apache/incubator-superset/blob/master/superset/models/core.py#L526, along with a db migration script.

Then it would be a matter of changing there user here:
https://github.com/apache/incubator-superset/blob/master/superset/models/core.py#L580
something like

if self.impersonate_user:
    uri.user = g.user.username

@mistercrunch mistercrunch self-assigned this Aug 16, 2017
@dmigo
Copy link
Contributor

dmigo commented Aug 31, 2017

Would it be considered as a useful feature for Superset, or is it still an open question?
For us it is the only difference with the main repository. I would definitely like to work on a PR.

@mistercrunch
Copy link
Member

Yes. Do it!

@dmigo
Copy link
Contributor

dmigo commented Oct 5, 2017

@luoruixing this should work now.
@mistercrunch this one may be closed.

@MihailGershkovich
Copy link

We are just starting to use superset, and I hope I will be able to promote it in our company.
Probably my request is already resolved and I was just not able to find how to approach it, but in case it is not:

Sorry for another comment on a closed request, but do you plan to implement it for other DBMS aswell? I'd like to see this feature for postgres, so that we can leverage features like access rights on tables, row and column level security or policies. It would be even nicer, if something like "set role" would work.
Example: we limit the access to transactional data based on role membership (including inherited). Imagine, I belong to roles x, y, z and y is member of z. And we have a head of department y, and an analyst in department z, which belongs to y.
Then I can see transactional data and build statistics on all of them. However if I want to share my dashboards with head of department y and analyst of department z, I will have to copy them over and setup connections or build filtered dashboards for them. Otherwise they would see to much info (they would have access to confidential information and receive wrong statistics).
Now imagine head of department y wants to see stats and data for department z (he is allowed to), thus he would have to worry about his filters, etc. or he would need to have access to another set of dashboards, instead of changing his roles.
BR

@Asturias-sam
Copy link

what SQLAlchemy URI have you guys used for presto to Impersonate the logged on user.
Currently only the user who have configured the datasource is able to query for other it's shows

sqlalchemy.exc.OperationalError: (pyhive.exc.OperationalError) Unexpected status code 401
b'Access Denied: Invalid credentials'
[SQL: SHOW SCHEMAS]
(Background on this error at: http://sqlalche.me/e/e3q8)

From Presto side:
Password validation failed for user DN [superset@homeoffice.domain.com]: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090453, comment: AcceptSecurityContext error, data 52e, v3839] ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants