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
de62f54d
Commit
de62f54d
authored
4 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Readded ldap starttls support after accidentally removing it in
a721ff1b
parent
997f3a65
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
uffd/ldap.py
+2
-1
2 additions, 1 deletion
uffd/ldap.py
uffd/session/views.py
+4
-2
4 additions, 2 deletions
uffd/session/views.py
with
6 additions
and
3 deletions
uffd/ldap.py
+
2
−
1
View file @
de62f54d
...
...
@@ -46,7 +46,8 @@ class FlaskLDAPMapper(LDAPMapper):
current_app
.
ldap_mock
.
bind
()
return
current_app
.
ldap_mock
server
=
ldap3
.
Server
(
current_app
.
config
[
"
LDAP_SERVICE_URL
"
],
get_info
=
ldap3
.
ALL
)
auto_bind
=
ldap3
.
AUTO_BIND_TLS_BEFORE_BIND
if
current_app
.
config
[
"
LDAP_SERVICE_USE_STARTTLS
"
]
else
True
return
ldap3
.
Connection
(
server
,
current_app
.
config
[
"
LDAP_SERVICE_BIND_DN
"
],
current_app
.
config
[
"
LDAP_SERVICE_BIND_PASSWORD
"
],
auto_bind
=
True
)
current_app
.
config
[
"
LDAP_SERVICE_BIND_PASSWORD
"
],
auto_bind
=
auto_bind
)
ldap
=
FlaskLDAPMapper
()
This diff is collapsed.
Click to expand it.
uffd/session/views.py
+
4
−
2
View file @
de62f54d
...
...
@@ -6,6 +6,7 @@ from flask import Blueprint, render_template, request, url_for, redirect, flash,
import
ldap3
from
ldap3.core.exceptions
import
LDAPBindError
,
LDAPPasswordIsMandatoryError
from
ldapalchemy.core
import
encode_filter
from
uffd.user.models
import
User
from
uffd.ldap
import
ldap
...
...
@@ -31,11 +32,12 @@ def login_get_user(loginname, password):
return
None
else
:
server
=
ldap3
.
Server
(
current_app
.
config
[
"
LDAP_SERVICE_URL
"
],
get_info
=
ldap3
.
ALL
)
auto_bind
=
ldap3
.
AUTO_BIND_TLS_BEFORE_BIND
if
current_app
.
config
[
"
LDAP_SERVICE_USE_STARTTLS
"
]
else
True
try
:
conn
=
ldap3
.
Connection
(
server
,
dn
,
password
,
auto_bind
=
True
)
conn
=
ldap3
.
Connection
(
server
,
dn
,
password
,
auto_bind
=
auto_bind
)
except
(
LDAPBindError
,
LDAPPasswordIsMandatoryError
):
return
None
conn
.
search
(
conn
.
user
,
'
(objectClass=person)
'
)
conn
.
search
(
conn
.
user
,
encode_filter
(
current_app
.
config
[
"
LDAP_USER_SEARCH_FILTER
"
])
)
if
len
(
conn
.
entries
)
!=
1
:
return
None
return
User
.
query
.
get
(
dn
)
...
...
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