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

Incorrectly documented SQLALCHEMY_CUSTOM_PASSWORD_STORE #4043

Closed
ottomata opened this issue Dec 11, 2017 · 5 comments
Closed

Incorrectly documented SQLALCHEMY_CUSTOM_PASSWORD_STORE #4043

ottomata opened this issue Dec 11, 2017 · 5 comments
Labels
inactive Inactive for >= 30 days

Comments

@ottomata
Copy link

The docs say to do:

def example_lookup_password(url):
    secret = <<get password from external framework>>
    return 'secret'

SQLALCHEMY_CUSTOM_PASSWORD_STORE = example_lookup_password

But, superset sets this function as a instance variable on the Database model class, and calls it as such, with self:

conn.password = self.custom_password_store(conn)

When called with self, it is expected that the function take a self argument as the first parameter.

I fixed this temporarily in my function by adding a dummy 'self', but probably the code should not need this. :)

@mistercrunch
Copy link
Member

mistercrunch commented Dec 11, 2017

@fabianmenges I think you contributed this originally. The function should probably be stamped in module scope instead of as a class attribute.

@fabianmenges
Copy link
Contributor

Hm, interesting, we are using this slightly different, which is why I didn't run into it... e.g.:

class ExamplePasswordStore(object):
  ...
  def get_password(self, sqla_connection):
    key = self._gen_key(sqla_connection.__dict__)
    return self.password_lookup.get(key)

p_store = ExamplePasswordStore(...)
SQLALCHEMY_CUSTOM_PASSWORD_STORE = p_store.get_password

Not sure how this wasn't caught in the unit test.
https://github.com/apache/incubator-superset/blob/c84211ec449a6fc0e80f1e1b6df54cb4340ca3f7/tests/core_tests.py#L311

Anyways, two options. Either change the documentation or move the 'function' custom_password_store out of the Database class.

@ottomata are you using the self reference to the Database object inside the password store? Otherwise I might just move the function out. @mistercrunch, any preference?

@fabianmenges
Copy link
Contributor

Oh, I just realized this is probably because this field is on a SQLAlchemy model and we probably have some weird interaction here. I should probably move this function out of the Database class.

@ottomata
Copy link
Author

ottomata commented Dec 14, 2017 via email

wmfgerrit pushed a commit to wikimedia/operations-puppet that referenced this issue Aug 28, 2018
apache/superset#4043 has been fixed

Bug: T201430
Change-Id: I83f9d96681484c4f07eebbc94ce4c3bbe4291bd9
@stale
Copy link

stale bot commented Apr 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 11, 2019
@stale stale bot closed this as completed Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

3 participants