Skip to content

Passing username for impersonation - #334

Open
gbrian wants to merge 1 commit into
cloudera:masterfrom
acloudfrontier:superset-impersonation
Open

Passing username for impersonation#334
gbrian wants to merge 1 commit into
cloudera:masterfrom
acloudfrontier:superset-impersonation

Conversation

@gbrian

@gbrian gbrian commented Feb 4, 2019

Copy link
Copy Markdown

No description provided.

@timarmstrong

Copy link
Copy Markdown
Contributor

Can you add a test for this feature? Maybe you can use the effective_user() builtin function to make sure that it had the intended effect.

@gbrian

gbrian commented Feb 27, 2019

Copy link
Copy Markdown
Author

Do you mean kind of:

def test_sqlalchemy_impersonation():
    engine = create_engine('impala://localhost')
    result = connection.execute("select effective_user() as effective_user")
    observed = result[0]['effective_user']
    expected = '?????'
    assert expected == observed

    impersonate = 'user1'
    engine = create_engine('impala://%s@localhost' % impersonate)
    result = connection.execute("select effective_user() as effective_user")
    observed = result[0]['effective_user']
    expected = impersonate
    assert expected == observed

@timarmstrong

Copy link
Copy Markdown
Contributor

Something along those lines, yeah. I think the second part of that test is the most important. Mainly to prove that the 'effective_user' value gets plumbed all the way through to Impala correctly.

@timarmstrong timarmstrong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a test for this potentially?

Comment thread impala/dbapi.py
password=None, kerberos_service_name='impala', use_ldap=None,
ldap_user=None, ldap_password=None, use_kerberos=None,
protocol=None):
protocol=None,username=None):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: space after comma to be consistent with surrounding code and PEP8

Comment thread impala/hiveserver2.py
default_db)
self.service = service
self.default_db = default_db
self.impersonate=impersonate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: spaces around = to be consistent with surrounding code and PEP8

Comment thread impala/hiveserver2.py

log.debug('.cursor(): getting new session_handle')

if self.impersonate != None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@huw0

huw0 commented May 22, 2023

Copy link
Copy Markdown
Contributor

#281 indicates that impersonation works on a per-cursor basis.

Therefore can this PR be closed? I think it will be confusing to support impersonation in multiple places and this could lead to unintentional security issues where connections are re-used.

@gbrian gbrian closed this May 23, 2023
@gbrian

gbrian commented May 23, 2023

Copy link
Copy Markdown
Author

Not needed

@gbrian gbrian reopened this May 23, 2023
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

Successfully merging this pull request may close these issues.

3 participants