question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LDAP issue logging into Superset (no attribute 'login_count')

See original GitHub issue

I can’t login to Superset with a user that is not registered in the DB. It is failing in the user registration code of fab.

My config entries:

AUTH_TYPE = 2
AUTH_LDAP_SERVER = "ldap://x.x.x.x"
AUTH_LDAP_SEARCH = "OU=someusers,OU=another,DC=somedomain,DC=com"
AUTH_LDAP_UID_FIELD = "userPrincipalName"
AUTH_USER_REGISTRATION = True
AUTH_USER_REGISTRATION_ROLE = 'alpha'

I can get my AD details using the python-ldap library much like the code does in manager.py. The following code run against MSFT AD works fine:

import ldap
con =  ldap.initialize(AUTH_LDAP_SERVER)
con.bind_s("auser@somedomain.com", "pass")
con.search_s(AUTH_LDAP_SEARCH,ldap.SCOPE_SUBTREE,"userPrincipalName=auser@somedomain.com", ['givenName', 'sn', 'mail'])

But when I try to login I get following message:

Error:

2017-02-17 14:52:31,642:ERROR:flask_appbuilder.security.sqla.manager:Error adding new user to database. Can't flush None value found in collection User.roles
[2017-02-17 14:52:31,642] ERROR in app: Exception on /login/ [POST]
Traceback (most recent call last):
  File "/home/centos/anaconda2/envs/science2/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/centos/anaconda2/envs/science2/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/centos/anaconda2/envs/science2/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/centos/anaconda2/envs/science2/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/centos/anaconda2/envs/science2/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/centos/anaconda2/envs/science2/lib/python2.7/site-packages/flask_appbuilder/security/views.py", line 398, in login
    user = self.appbuilder.sm.auth_user_ldap(form.username.data, form.password.data)
  File "/home/centos/anaconda2/envs/science2/lib/python2.7/site-packages/flask_appbuilder/security/manager.py", line 631, in auth_user_ldap
    self.update_user_auth_stat(user)
  File "/home/centos/anaconda2/envs/science2/lib/python2.7/site-packages/flask_appbuilder/security/manager.py", line 488, in update_user_auth_stat
    if not user.login_count:
AttributeError: 'bool' object has no attribute 'login_count'
Exception on /login/ [POST]

I don’t know why the user object is a bool.

  • OS: Centos 7
  • Flask appbuilder version 1.8.1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
juthikashenoycommented, May 17, 2018

I am trying to integrate supersets with LDAP and running into this error - after login File “/home/jshenoy/venv/lib/python2.7/site-packages/flask/app.py”, line 1997, in call return self.wsgi_app(environ, start_response) File “/home/jshenoy/venv/lib/python2.7/site-packages/flask/app.py”, line 1985, in wsgi_app response = self.handle_exception(e) File “/home/jshenoy/venv/lib/python2.7/site-packages/flask/app.py”, line 1540, in handle_exception reraise(exc_type, exc_value, tb) File “/home/jshenoy/venv/lib/python2.7/site-packages/flask/app.py”, line 1982, in wsgi_app response = self.full_dispatch_request() File “/home/jshenoy/venv/lib/python2.7/site-packages/flask/app.py”, line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File “/home/jshenoy/venv/lib/python2.7/site-packages/flask/app.py”, line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File “/home/jshenoy/venv/lib/python2.7/site-packages/flask/app.py”, line 1612, in full_dispatch_request rv = self.dispatch_request() File “/home/jshenoy/venv/lib/python2.7/site-packages/flask/app.py”, line 1598, in dispatch_request return self.view_functionsrule.endpoint File “/home/jshenoy/venv/lib/python2.7/site-packages/flask_appbuilder/security/views.py”, line 402, in login user = self.appbuilder.sm.auth_user_ldap(form.username.data, form.password.data) File “/home/jshenoy/venv/lib/python2.7/site-packages/flask_appbuilder/security/manager.py”, line 622, in auth_user_ldap raise Exception(“No ldap library for python.”) Exception: No ldap library for python. Any Suggestions ?

0reactions
tooptoop4commented, Mar 27, 2020

has anyone solved this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

T223335 Can't log into Superset - Wikimedia Phabricator
When I try to log into https://superset.wikimedia.org/ with my LDAP account, ... AttributeError: 'bool' object has no attribute 'login_count' ...
Read more >
LDAP - Easy Identity
A quick look in the directory server log files demonstrates that all operations coming from the Web Application are performed by the service...
Read more >
Security - Flask AppBuilder - Read the Docs
F.A.B. will ask for the 'email' from OpenID, and if this email belongs to some user on your application he/she will login successfully....
Read more >
Can't use local user with LDAP - Stack Overflow
I'm trying to integrate the apache superset with LDAP. with the configuration that I will provide below I can log in superset web...
Read more >
Security in MySQL
6.1.9 No-Login Pluggable Authentication . ... This section describes general security issues to be aware of and what you can do to make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found