Update LDAP
This commit is contained in:
+17
-11
@@ -41,7 +41,7 @@ from werkzeug.exceptions import default_exceptions
|
||||
from werkzeug.datastructures import Headers
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
|
||||
from . import constants, logger, isoLanguages
|
||||
from . import constants, logger, isoLanguages, ldap
|
||||
from . import global_WorkerThread, searched_ids, lm, babel, db, ub, config, get_locale, app, language_table
|
||||
from .gdriveutils import getFileFromEbooksFolder, do_gdrive_download
|
||||
from .helper import common_filters, get_search_results, fill_indexpage, speaking_language, check_valid_domain, \
|
||||
@@ -52,6 +52,8 @@ from .pagination import Pagination
|
||||
from .redirect import redirect_back
|
||||
|
||||
feature_support = dict()
|
||||
feature_support['ldap'] = ldap.ldap_supported()
|
||||
|
||||
try:
|
||||
from .oauth_bb import oauth_check, register_user_with_oauth, logout_oauth_user, get_oauth_status
|
||||
feature_support['oauth'] = True
|
||||
@@ -59,12 +61,6 @@ except ImportError:
|
||||
feature_support['oauth'] = False
|
||||
oauth_check = {}
|
||||
|
||||
try:
|
||||
import ldap
|
||||
feature_support['ldap'] = True
|
||||
except ImportError:
|
||||
feature_support['ldap'] = False
|
||||
|
||||
try:
|
||||
from goodreads.client import GoodreadsClient
|
||||
feature_support['goodreads'] = True
|
||||
@@ -221,6 +217,7 @@ def edit_required(f):
|
||||
|
||||
return inner
|
||||
|
||||
|
||||
# ################################### Helper functions ################################################################
|
||||
|
||||
|
||||
@@ -244,6 +241,8 @@ def before_request():
|
||||
|
||||
|
||||
# ################################### data provider functions #########################################################
|
||||
|
||||
|
||||
@web.route("/ajax/emailstat")
|
||||
@login_required
|
||||
def get_email_status_json():
|
||||
@@ -308,6 +307,7 @@ def toggle_read(book_id):
|
||||
log.error(u"Custom Column No.%d is not exisiting in calibre database", config.config_read_column)
|
||||
return ""
|
||||
|
||||
|
||||
'''
|
||||
@web.route("/ajax/getcomic/<int:book_id>/<book_format>/<int:page>")
|
||||
@login_required
|
||||
@@ -359,6 +359,7 @@ def get_comic_book(book_id, book_format, page):
|
||||
return "", 204
|
||||
'''
|
||||
|
||||
|
||||
# ################################### Typeahead ##################################################################
|
||||
|
||||
|
||||
@@ -434,6 +435,7 @@ def get_matching_tags():
|
||||
|
||||
# ################################### View Books list ##################################################################
|
||||
|
||||
|
||||
@web.route("/", defaults={'page': 1})
|
||||
@web.route('/page/<int:page>')
|
||||
@login_required_if_no_ano
|
||||
@@ -757,6 +759,7 @@ def category_list():
|
||||
|
||||
# ################################### Task functions ################################################################
|
||||
|
||||
|
||||
@web.route("/tasks")
|
||||
@login_required
|
||||
def get_tasks_status():
|
||||
@@ -768,6 +771,7 @@ def get_tasks_status():
|
||||
|
||||
# ################################### Search functions ################################################################
|
||||
|
||||
|
||||
@web.route("/search", methods=["GET"])
|
||||
@login_required_if_no_ano
|
||||
def search():
|
||||
@@ -963,6 +967,7 @@ def render_read_books(page, are_read, as_xml=False, order=None):
|
||||
|
||||
# ################################### Download/Send ##################################################################
|
||||
|
||||
|
||||
@web.route("/cover/<int:book_id>")
|
||||
@login_required_if_no_ano
|
||||
def get_cover(book_id):
|
||||
@@ -1021,6 +1026,7 @@ def send_to_kindle(book_id, book_format, convert):
|
||||
|
||||
# ################################### Login Logout ##################################################################
|
||||
|
||||
|
||||
@web.route('/register', methods=['GET', 'POST'])
|
||||
def register():
|
||||
if not config.config_public_reg:
|
||||
@@ -1087,17 +1093,17 @@ def login():
|
||||
.first()
|
||||
if config.config_login_type == 1 and user and feature_support['ldap']:
|
||||
try:
|
||||
if ldap.bind_user(form['username'], form['password']) is not None:
|
||||
if ldap.ldap.bind_user(form['username'], form['password']) is not None:
|
||||
login_user(user, remember=True)
|
||||
flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname),
|
||||
category="success")
|
||||
return redirect_back(url_for("web.index"))
|
||||
except ldap.INVALID_CREDENTIALS as e:
|
||||
except ldap.ldap.INVALID_CREDENTIALS as e:
|
||||
log.error('Login Error: ' + str(e))
|
||||
ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr)
|
||||
log.info('LDAP Login failed for user "%s" IP-adress: %s', form['username'], ipAdress)
|
||||
flash(_(u"Wrong Username or Password"), category="error")
|
||||
except ldap.SERVER_DOWN:
|
||||
except ldap.ldap.SERVER_DOWN:
|
||||
log.info('LDAP Login failed, LDAP Server down')
|
||||
flash(_(u"Could not login. LDAP server down, please contact your administrator"), category="error")
|
||||
'''except LDAPException as exception:
|
||||
@@ -1213,6 +1219,7 @@ def token_verified():
|
||||
|
||||
# ################################### Users own configuration #########################################################
|
||||
|
||||
|
||||
@web.route("/me", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def profile():
|
||||
@@ -1279,7 +1286,6 @@ def profile():
|
||||
page="me", registered_oauth=oauth_check, oauth_status=oauth_status)
|
||||
|
||||
|
||||
|
||||
# ###################################Show single book ##################################################################
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user