mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-25 17:40:31 +00:00
Enable debug output for ldap login
This commit is contained in:
parent
d35e781d41
commit
9646b6e2dd
@ -20,6 +20,7 @@ import base64
|
||||
|
||||
from flask_simpleldap import LDAP, LDAPException
|
||||
from flask_simpleldap import ldap as pyLDAP
|
||||
from flask import current_app
|
||||
from .. import constants, logger
|
||||
|
||||
try:
|
||||
@ -28,9 +29,41 @@ except ImportError:
|
||||
pass
|
||||
|
||||
log = logger.create()
|
||||
_ldap = LDAP()
|
||||
|
||||
|
||||
class mySimpleLDap(LDAP):
|
||||
|
||||
@staticmethod
|
||||
def init_app(app):
|
||||
super(mySimpleLDap, mySimpleLDap).init_app(app)
|
||||
app.config.setdefault('LDAP_LOGLEVEL', 0)
|
||||
|
||||
|
||||
@property
|
||||
def initialize(self):
|
||||
"""Initialize a connection to the LDAP server.
|
||||
|
||||
:return: LDAP connection object.
|
||||
"""
|
||||
try:
|
||||
log_level = 2 if current_app.config['LDAP_LOGLEVEL'] == logger.logging.DEBUG else 0
|
||||
conn = pyLDAP.initialize('{0}://{1}:{2}'.format(
|
||||
current_app.config['LDAP_SCHEMA'],
|
||||
current_app.config['LDAP_HOST'],
|
||||
current_app.config['LDAP_PORT']), trace_level=log_level)
|
||||
conn.set_option(pyLDAP.OPT_NETWORK_TIMEOUT,
|
||||
current_app.config['LDAP_TIMEOUT'])
|
||||
conn = self._set_custom_options(conn)
|
||||
conn.protocol_version = pyLDAP.VERSION3
|
||||
if current_app.config['LDAP_USE_TLS']:
|
||||
conn.start_tls_s()
|
||||
return conn
|
||||
except pyLDAP.LDAPError as e:
|
||||
raise LDAPException(self.error(e.args))
|
||||
|
||||
|
||||
_ldap = mySimpleLDap()
|
||||
|
||||
def init_app(app, config):
|
||||
if config.config_login_type != constants.LOGIN_LDAP:
|
||||
return
|
||||
@ -70,7 +103,7 @@ def init_app(app, config):
|
||||
app.config['LDAP_OPENLDAP'] = bool(config.config_ldap_openldap)
|
||||
app.config['LDAP_GROUP_OBJECT_FILTER'] = config.config_ldap_group_object_filter
|
||||
app.config['LDAP_GROUP_MEMBERS_FIELD'] = config.config_ldap_group_members_field
|
||||
|
||||
app.config['LDAP_LOGLEVEL'] = config.config_log_level
|
||||
try:
|
||||
_ldap.init_app(app)
|
||||
except ValueError:
|
||||
|
@ -1,8 +1,8 @@
|
||||
# GDrive Integration
|
||||
google-api-python-client>=1.7.11,<2.78.0
|
||||
google-api-python-client>=1.7.11,<2.90.0
|
||||
gevent>20.6.0,<23.0.0
|
||||
greenlet>=0.4.17,<2.1.0
|
||||
httplib2>=0.9.2,<0.22.0
|
||||
httplib2>=0.9.2,<0.23.0
|
||||
oauth2client>=4.0.0,<4.1.4
|
||||
uritemplate>=3.0.0,<4.2.0
|
||||
pyasn1-modules>=0.0.8,<0.3.0
|
||||
@ -13,7 +13,7 @@ rsa>=3.4.2,<4.10.0
|
||||
|
||||
# Gmail
|
||||
google-auth-oauthlib>=0.4.3,<0.9.0
|
||||
google-api-python-client>=1.7.11,<2.78.0
|
||||
google-api-python-client>=1.7.11,<2.90.0
|
||||
|
||||
# goodreads
|
||||
goodreads>=0.3.2,<0.4.0
|
||||
|
Loading…
Reference in New Issue
Block a user