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
uffd
uffd
Commits
f43bc6cd
Verified
Commit
f43bc6cd
authored
4 years ago
by
nd
Browse files
Options
Downloads
Patches
Plain Diff
cache ldap connection in request
parent
b9ccfd55
No related branches found
No related tags found
1 merge request
!18
LDAP Object Mapper
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uffd/ldap.py
+5
-2
5 additions, 2 deletions
uffd/ldap.py
with
5 additions
and
2 deletions
uffd/ldap.py
+
5
−
2
View file @
f43bc6cd
...
...
@@ -33,6 +33,8 @@ class FlaskLDAPMapper(LDAPMapper):
return
request
.
ldap_session
def
get_connection
(
self
):
if
hasattr
(
request
,
'
ldap_connection
'
):
return
request
.
ldap_connection
if
current_app
.
config
.
get
(
'
LDAP_SERVICE_MOCK
'
,
False
):
if
not
current_app
.
debug
:
raise
Exception
(
'
LDAP_SERVICE_MOCK cannot be enabled on production instances
'
)
...
...
@@ -47,7 +49,8 @@ class FlaskLDAPMapper(LDAPMapper):
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
=
auto_bind
)
request
.
ldap_connection
=
ldap3
.
Connection
(
server
,
current_app
.
config
[
"
LDAP_SERVICE_BIND_DN
"
],
current_app
.
config
[
"
LDAP_SERVICE_BIND_PASSWORD
"
],
auto_bind
=
auto_bind
)
return
request
.
ldap_connection
ldap
=
FlaskLDAPMapper
()
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