iRoot13x18 opened a new issue, #28427:
URL: https://github.com/apache/superset/issues/28427

   ### Bug description
   
   I need to link LDAP to my superset and it is giving me error when 
connecting, I have verified that the LDAP credentials are correct. I have based 
on these two configuration files.
   
   ### How to reproduce the bug
   
   1- go to PYTHONPATH
   
   2-edit superset_config.py file and put the relevant configuration for LDAP, 
in particular this was this
   import os
   from superset.security import SupersetSecurityManager
   from flask_appbuilder.security.manager import AUTH_DB,AUTH_LDAP
   from custom_security_manager import CustomSecurityManager
   
   AUTH_TYPE = AUTH_LDAP 
   AUTH_USER_REGISTRATION = True
   AUTH_USER_REGISTRATION_ROLE = "Public" 
   AUTH_LDAP_SERVER = "ldaps://server.yourdomain.com:636"
   AUTH_LDAP_USE_TLS = False
   AUTH_LDAP_BIND_USER = "cn=mycn,ou=myou,ou=myou,dc=mydc,dc=com"
   AUTH_LDAP_BIND_PASSWORD = "password"
   AUTH_LDAP_SEARCH = "DC=your_domain,DC=com,"
   AUTH_LDAP_UID_FIELD = "sAMAccountName"
   AUTH_LDAP_ALLOW_SELF_SIGNED=True
   AUTH_LDAP_APPEND_DOMAIN=False
   AUTH_LDAP_FIRSTNAME_FIELD="givenName"
   AUTH_LDAP_LASTNAME_FIELD="sn"
   AUTH_LDAP_USE_TLS=False
   AUTH_USER_REGISTRATION=True
   
   CUSTOM_SECURITY_MANAGER = CustomSecurityManager
   
   3-create and modify the custom_security_manager.py file in PYTHONPATH
   from superset.security import SupersetSecurityManager
   from flask_appbuilder.security.views import AuthLDAPView
   from flask_appbuilder.security.views import expose
   from flask import g, redirect, flash
   from flask_appbuilder.security.forms import LoginForm_db
   from flask_login import login_user
   from flask_appbuilder._compat import as_unicode
   
   class AuthLocalAndLDAPView(AuthLDAPView):
       @expose("/login/", methods=["GET", "POST"])
       def login(self):
           if g.user is not None and g.user.is_authenticated:
               return redirect(self.appbuilder.get_url_for_index)
           form = LoginForm_db()
           if form.validate_on_submit():
               user = self.appbuilder.sm.auth_user_ldap(
                   form.username.data, form.password.data
               )
               if not user:
                   user = self.appbuilder.sm.auth_user_db(
                       form.username.data, form.password.data
                   )
               if user:
                   login_user(user, remember=False)
                   return redirect(self.appbuilder.get_url_for_index)
               else:
                   flash(as_unicode(self.invalid_login_message), "warning")
                   return redirect(self.appbuilder.get_url_for_login)
           return self.render_template(
               self.login_template, title=self.title, form=form, 
appbuilder=self.appbuilder
           )
   
   
   class CustomSecurityManager(SupersetSecurityManager):
       authldapview = AuthLocalAndLDAPView
       def __init__(self, appbuilder):
           super(CustomSecurityManager, self).__init__(appbuilder)
   
   4-restart docker-compose and try logging in with ldap credentials
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   4.0.0
   
   ### Python version
   
   3.10
   
   ### Node version
   
   18 or greater
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   I will leave here the web page on which I based my configuration. 
   
https://medium.com/@ozan/configure-ldap-and-local-user-login-on-superset-69fa4df4ee24
   
   ### Checklist
   
   - [X] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [X] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [X] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to