Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uffd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca (strifel)
uffd
Commits
8cdadd69
Commit
8cdadd69
authored
4 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
handle LDAPPasswordIsMandatoryError in user_conn, closes #27
parent
54c98455
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_session.py
+0
-1
0 additions, 1 deletion
tests/test_session.py
uffd/ldap/ldap.py
+6
-3
6 additions, 3 deletions
uffd/ldap/ldap.py
with
6 additions
and
4 deletions
tests/test_session.py
+
0
−
1
View file @
8cdadd69
...
...
@@ -75,7 +75,6 @@ class TestSession(UffdTestCase):
self
.
assertEqual
(
r
.
status_code
,
200
)
self
.
assertLogout
()
@unittest.skip
(
'
See #27
'
)
def
test_empty_password
(
self
):
r
=
self
.
client
.
post
(
path
=
url_for
(
'
session.login
'
),
data
=
{
'
loginname
'
:
'
testuser
'
,
'
password
'
:
''
},
follow_redirects
=
True
)
...
...
This diff is collapsed.
Click to expand it.
uffd/ldap/ldap.py
+
6
−
3
View file @
8cdadd69
...
...
@@ -2,7 +2,7 @@ import string
from
flask
import
Blueprint
,
current_app
from
ldap3.utils.conv
import
escape_filter_chars
from
ldap3.core.exceptions
import
LDAPBindError
,
LDAPCursorError
from
ldap3.core.exceptions
import
LDAPBindError
,
LDAPCursorError
,
LDAPPasswordIsMandatoryError
from
ldap3
import
Server
,
Connection
,
ALL
,
ALL_ATTRIBUTES
,
ALL_OPERATIONAL_ATTRIBUTES
,
MOCK_SYNC
...
...
@@ -45,13 +45,16 @@ def user_conn(loginname, password):
# implementation just compares the string in the objects's userPassword
# field with the password, no support for hashing or OpenLDAP-style
# password-prefixes ("{PLAIN}..." or "{ssha512}...").
if
not
conn
.
rebind
(
loginname_to_dn
(
loginname
),
password
):
try
:
if
not
conn
.
rebind
(
loginname_to_dn
(
loginname
),
password
):
return
False
except
(
LDAPBindError
,
LDAPPasswordIsMandatoryError
):
return
False
return
get_mock_conn
()
server
=
Server
(
current_app
.
config
[
"
LDAP_SERVICE_URL
"
],
get_info
=
ALL
)
try
:
return
fix_connection
(
Connection
(
server
,
loginname_to_dn
(
loginname
),
password
,
auto_bind
=
True
))
except
LDAPBindError
:
except
(
LDAPBindError
,
LDAPPasswordIsMandatoryError
)
:
return
False
def
get_conn
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment