superset icon indicating copy to clipboard operation
superset copied to clipboard

Can't contact LDAP server

Open bharath0208 opened this issue 6 years ago • 7 comments

Hi Team, I have modified the superset_config.py to connect to my ldap server. When i run this as a docker pod i m able to connect to the LDAP server and the logging is working fine. But when i deploy this on a Kubernetes cluster using helm charts it throws the below error.

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/security/manager.py", line 909, in auth_user_ldap
    if not self._bind_ldap(ldap, con, username, password):
  File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/security/manager.py", line 825, in _bind_ldap
    self._bind_indirect_user(ldap, con)
  File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/security/manager.py", line 810, in _bind_indirect_user
    con.bind_s(indirect_user, indirect_password)
  File "/usr/local/lib/python3.6/site-packages/ldap/ldapobject.py", line 397, in bind_s
    msgid = self.bind(who,cred,method)
  File "/usr/local/lib/python3.6/site-packages/ldap/ldapobject.py", line 391, in bind
    return self.simple_bind(who,cred)
  File "/usr/local/lib/python3.6/site-packages/ldap/ldapobject.py", line 376, in simple_bind
    return self._ldap_call(self._l.simple_bind,who,cred,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
  File "/usr/local/lib/python3.6/site-packages/ldap/ldapobject.py", line 263, in _ldap_call
    result = func(*args,**kwargs)
ldap.SERVER_DOWN: {'desc': "Can't contact LDAP server"}

Note: The ldap server is up and running and we are able to contact it from other kube pods not sure why it is not working from superset pod.

bharath0208 avatar Jan 16 '20 21:01 bharath0208

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

issue-label-bot[bot] avatar Jan 16 '20 21:01 issue-label-bot[bot]

Hi @bharath0208,

This does not seem like a superset issue. You need to troubleshoot your environment, for example start by accessing your container on kubernetes and test if you can connect to your LDAP server

dpgaspar avatar Jan 20 '20 08:01 dpgaspar

@dpgaspar I tried that it connects 1 out of 10 times. But when i ping it from some other pod running on my k8 cluster it connects fine. I am using the helm charts provided here in Github.

bharath0208 avatar Jan 20 '20 17:01 bharath0208

I also had this problem and I fixed it by changing the assignment of the variable username in _bind_ldap (when AUTH_LDAP_BIND_USER is set to True)

I use the following command:

sed -i 's/username = user\[0\]\[0\]/username = user\[1\]\[0\]/' /usr/local/lib/python3.6/site-packages/flask_appbuilder/security/manager.py

Though this is probably a problem of Flask Appbuilder or of an LDAP misconfiguration, I hope it helps.

PeterCahn avatar Jan 21 '20 13:01 PeterCahn

@PeterCahn @dpgaspar

Thanks peter I have added this value already when AUTH_LDAP_BIND_USER is set to True. I fixed this error by adding this property in my deployment YAML file.

spec:
  hostAliases:
    - ip: "8888888888888"
      hostnames:
        - "google.com"

I see the authentication is going through now but I am getting the below error. Any help can be highly appreciated.

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.6/site-packages/superset/views/core.py", line 2806, in welcome
    "common": common_bootstrap_payload(),
  File "/usr/local/lib/python3.6/site-packages/superset/views/base.py", line 258, in common_bootstrap_payload
    "menu_data": menu_data(),
  File "/usr/local/lib/python3.6/site-packages/superset/views/base.py", line 200, in menu_data
    menu = appbuilder.menu.get_data()
  File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/menu.py", line 62, in get_data
    allowed_menus = current_app.appbuilder.sm.get_user_menu_access(
AttributeError: 'SupersetSecurityManager' object has no attribute 'get_user_menu_access'

bharath0208 avatar Jan 21 '20 16:01 bharath0208

I'm also facing same issue.. same LDAP settings works fine on docker but not on K8. But if I change AUTH_LDAP_SERVER from ldaps(or port 636) to ldap(port 389) and disable TLS, it works fine. I think I need to configure cert, cacert etc but not sure how to pass cert path with ldap.

manisha-tanwar avatar Feb 08 '22 15:02 manisha-tanwar

I'm also facing same issue.. same LDAP settings works fine on docker but not on K8. But if I change AUTH_LDAP_SERVER from ldaps(or port 636) to ldap(port 389) and disable TLS, it works fine. I think I need to configure cert, cacert etc but not sure how to pass cert path with ldap.

i got the same issue, this kind of workaround solved the issue.

faridrah0514 avatar Jul 14 '22 08:07 faridrah0514