Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
0480d493
Commit
0480d493
authored
Apr 25, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix opds login with ldap, if ldap server is down
parent
b4d7733e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
web.py
cps/web.py
+10
-2
No files found.
cps/web.py
View file @
0480d493
...
@@ -39,7 +39,7 @@ from flask_babel import gettext as _
...
@@ -39,7 +39,7 @@ from flask_babel import gettext as _
from
flask_login
import
login_user
,
logout_user
,
login_required
,
current_user
from
flask_login
import
login_user
,
logout_user
,
login_required
,
current_user
from
sqlalchemy.exc
import
IntegrityError
from
sqlalchemy.exc
import
IntegrityError
from
sqlalchemy.sql.expression
import
text
,
func
,
true
,
false
,
not_
,
and_
,
exists
,
or_
from
sqlalchemy.sql.expression
import
text
,
func
,
true
,
false
,
not_
,
and_
,
exists
,
or_
from
werkzeug.exceptions
import
default_exceptions
from
werkzeug.exceptions
import
default_exceptions
,
FailedDependency
from
werkzeug.datastructures
import
Headers
from
werkzeug.datastructures
import
Headers
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
...
@@ -111,6 +111,14 @@ for ex in default_exceptions:
...
@@ -111,6 +111,14 @@ for ex in default_exceptions:
elif
ex
==
500
:
elif
ex
==
500
:
app
.
register_error_handler
(
ex
,
internal_error
)
app
.
register_error_handler
(
ex
,
internal_error
)
# Only way of catching the LDAPException upon logging in with LDAP server down
@
app
.
errorhandler
(
services
.
ldap
.
LDAPException
)
def
handle_exception
(
e
):
log
.
debug
(
'LDAP server not accessible while trying to login to opds feed'
)
return
error_http
(
FailedDependency
())
web
=
Blueprint
(
'web'
,
__name__
)
web
=
Blueprint
(
'web'
,
__name__
)
log
=
logger
.
create
()
log
=
logger
.
create
()
...
@@ -156,7 +164,7 @@ def load_user_from_auth_header(header_val):
...
@@ -156,7 +164,7 @@ def load_user_from_auth_header(header_val):
except
(
TypeError
,
UnicodeDecodeError
,
binascii
.
Error
):
except
(
TypeError
,
UnicodeDecodeError
,
binascii
.
Error
):
pass
pass
user
=
_fetch_user_by_name
(
basic_username
)
user
=
_fetch_user_by_name
(
basic_username
)
if
config
.
config_login_type
==
constants
.
LOGIN_LDAP
and
services
.
ldap
:
if
user
and
config
.
config_login_type
==
constants
.
LOGIN_LDAP
and
services
.
ldap
:
if
services
.
ldap
.
bind_user
(
str
(
user
.
password
),
basic_password
):
if
services
.
ldap
.
bind_user
(
str
(
user
.
password
),
basic_password
):
return
user
return
user
if
user
and
check_password_hash
(
str
(
user
.
password
),
basic_password
):
if
user
and
check_password_hash
(
str
(
user
.
password
),
basic_password
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment