Skip to content

Conversation

@afernandez
Copy link
Contributor

@afernandez afernandez commented Oct 12, 2017

Superset today has a config for impersonation when creating/editing a datasource.
When used with Presto, it actually creates a connection on behalf of the logged on user.
For Hive, we instead want to connect as the superuser (superset service account) but use the hive.server2.proxy.user property in the URI to enable impersonation.

Unit Tests passed.

cc @timifasubaa @mistercrunch

@afernandez afernandez changed the title DI-1113. Authentication: Enable user impersonation for Superset to HiveServer2 using hive.server2.proxy.user (a.fernandez) Authentication: Enable user impersonation for Superset to HiveServer2 using hive.server2.proxy.user (a.fernandez) Oct 12, 2017
@afernandez
Copy link
Contributor Author

Need to fix unit tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Base class has methods for how to modify a URI and URL object for impersonation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Python Engine Spec overrides the methods for how to modify a URI and URL object for impersonation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this to its own method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed uri to url since it was of type SQLAlchemy.URL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Important to mask the URL while logging since it may contain a password

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In some code paths, conn was not defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Important to mask the URL while logging since it may contain a password

Copy link
Contributor Author

@afernandez afernandez Oct 12, 2017

Choose a reason for hiding this comment

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

Unit test is failing since g.user.username is missing. Will fix soon.

Copy link
Contributor Author

@afernandez afernandez left a comment

Choose a reason for hiding this comment

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

Initial annotations

@afernandez afernandez force-pushed the afernandez_impersonate branch from eee12f1 to 4e9263e Compare October 12, 2017 23:39
@afernandez
Copy link
Contributor Author

Unit tests passed,

Ran 168 tests in 268.075s

OK
Submitting coverage to coveralls.io...
Coverage submitted!
Job ##8777.1
https://coveralls.io/jobs/30207773

@coveralls
Copy link

coveralls commented Oct 12, 2017

Coverage Status

Coverage increased (+0.08%) to 70.191% when pulling 4e9263e804d4297a94edf81aaeaf1b1f39cfd04d on afernandez:afernandez_impersonate into 52a9f27 on apache:master.

Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

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

Highlighted a few minor things but LGTM otherwise. Please lint according to our .pylinrc. We used to have automation with Landscape.io but switched it off since we move the repo to Apache...

Copy link
Member

Choose a reason for hiding this comment

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

NIT: I'd go without the is not None as None evals to False

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

Some very long lines here. PEP8 says 80, our pylint say 90. If you want to lint your PR only you can git diff master... | flake8 --diff thought that's flake8 not pylint. There's also git-lint which can lint your diff as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

NIT: -is not None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

…veServer2 using hive.server2.proxy.user (a.fernandez)
@afernandez afernandez force-pushed the afernandez_impersonate branch from 4e9263e to f310817 Compare October 13, 2017 23:03
@coveralls
Copy link

coveralls commented Oct 13, 2017

Coverage Status

Coverage decreased (-0.02%) to 70.364% when pulling f310817 on afernandez:afernandez_impersonate into bad6938 on apache:master.

@afernandez
Copy link
Contributor Author

@mistercrunch would you be able to re-review these changes? Does the decrease in coveralls mean I need to add unit tests?

@mistercrunch mistercrunch merged commit adef519 into apache:master Oct 17, 2017
@afernandez
Copy link
Contributor Author

Thanks for reviewing. I figured out how to do it without needing changes to PyHive. Will submit another PR soon.
@mistercrunch

michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
…veServer2 using hive.server2.proxy.user (a.fernandez) (apache#3652)
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.20.5 First shipped in 0.20.5 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.20.5 First shipped in 0.20.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants