Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
projects.thm.de
GitLab
Commits
67aa0b8c
Commit
67aa0b8c
authored
Dec 31, 2015
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize LDAP and add a search timeout
parent
a9800ce4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
11 deletions
+37
-11
CHANGELOG
CHANGELOG
+1
-0
config/gitlab.yml.example
config/gitlab.yml.example
+5
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
doc/integration/ldap.md
doc/integration/ldap.md
+5
-0
lib/gitlab/ldap/access.rb
lib/gitlab/ldap/access.rb
+6
-2
lib/gitlab/ldap/adapter.rb
lib/gitlab/ldap/adapter.rb
+15
-9
lib/gitlab/ldap/config.rb
lib/gitlab/ldap/config.rb
+4
-0
No files found.
CHANGELOG
View file @
67aa0b8c
...
@@ -37,6 +37,7 @@ v 8.4.0 (unreleased)
...
@@ -37,6 +37,7 @@ v 8.4.0 (unreleased)
v 8.3.3 (unreleased)
v 8.3.3 (unreleased)
- Preserve CE behavior with JIRA integration by only calling API if URL is set
- Preserve CE behavior with JIRA integration by only calling API if URL is set
- Fix duplicated branch creation/deletion events when using Web UI (Stan Hu)
- Fix duplicated branch creation/deletion events when using Web UI (Stan Hu)
- Add configurable LDAP server query timeout
- Get "Merge when build succeeds" to work when commits were pushed to MR target branch while builds were running
- Get "Merge when build succeeds" to work when commits were pushed to MR target branch while builds were running
- Suppress e-mails on failed builds if allow_failure is set (Stan Hu)
- Suppress e-mails on failed builds if allow_failure is set (Stan Hu)
- Fix project transfer e-mail sending incorrect paths in e-mail notification (Stan Hu)
- Fix project transfer e-mail sending incorrect paths in e-mail notification (Stan Hu)
...
...
config/gitlab.yml.example
View file @
67aa0b8c
...
@@ -204,6 +204,11 @@ production: &base
...
@@ -204,6 +204,11 @@ production: &base
bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
password: '_the_password_of_the_bind_user'
password: '_the_password_of_the_bind_user'
# Set a timeout, in seconds, for LDAP queries. This helps avoid blocking
# a request if the LDAP server becomes unresponsive.
# A value of 0 means there is no timeout.
timeout: 10
# This setting specifies if LDAP server is Active Directory LDAP server.
# This setting specifies if LDAP server is Active Directory LDAP server.
# For non AD servers it skips the AD specific queries.
# For non AD servers it skips the AD specific queries.
# If your LDAP server is not AD, set this to false.
# If your LDAP server is not AD, set this to false.
...
...
config/initializers/1_settings.rb
View file @
67aa0b8c
...
@@ -108,6 +108,7 @@ def base_gitlab_url
...
@@ -108,6 +108,7 @@ def base_gitlab_url
Settings
.
ldap
[
'servers'
].
each
do
|
key
,
server
|
Settings
.
ldap
[
'servers'
].
each
do
|
key
,
server
|
server
[
'label'
]
||=
'LDAP'
server
[
'label'
]
||=
'LDAP'
server
[
'timeout'
]
||=
10
.
seconds
server
[
'block_auto_created_users'
]
=
false
if
server
[
'block_auto_created_users'
].
nil?
server
[
'block_auto_created_users'
]
=
false
if
server
[
'block_auto_created_users'
].
nil?
server
[
'allow_username_or_email_login'
]
=
false
if
server
[
'allow_username_or_email_login'
].
nil?
server
[
'allow_username_or_email_login'
]
=
false
if
server
[
'allow_username_or_email_login'
].
nil?
server
[
'active_directory'
]
=
true
if
server
[
'active_directory'
].
nil?
server
[
'active_directory'
]
=
true
if
server
[
'active_directory'
].
nil?
...
...
doc/integration/ldap.md
View file @
67aa0b8c
...
@@ -48,6 +48,11 @@ main: # 'main' is the GitLab 'provider ID' of this LDAP server
...
@@ -48,6 +48,11 @@ main: # 'main' is the GitLab 'provider ID' of this LDAP server
bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
password: '_the_password_of_the_bind_user'
password: '_the_password_of_the_bind_user'
# Set a timeout, in seconds, for LDAP queries. This helps avoid blocking
# a request if the LDAP server becomes unresponsive.
# A value of 0 means there is no timeout.
timeout: 10
# This setting specifies if LDAP server is Active Directory LDAP server.
# This setting specifies if LDAP server is Active Directory LDAP server.
# For non AD servers it skips the AD specific queries.
# For non AD servers it skips the AD specific queries.
# If your LDAP server is not AD, set this to false.
# If your LDAP server is not AD, set this to false.
...
...
lib/gitlab/ldap/access.rb
View file @
67aa0b8c
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
module
Gitlab
module
Gitlab
module
LDAP
module
LDAP
class
Access
class
Access
attr_reader
:adapter
,
:provider
,
:user
attr_reader
:provider
,
:user
def
self
.
open
(
user
,
&
block
)
def
self
.
open
(
user
,
&
block
)
Gitlab
::
LDAP
::
Adapter
.
open
(
user
.
ldap_identity
.
provider
)
do
|
adapter
|
Gitlab
::
LDAP
::
Adapter
.
open
(
user
.
ldap_identity
.
provider
)
do
|
adapter
|
...
@@ -32,7 +32,7 @@ def initialize(user, adapter=nil)
...
@@ -32,7 +32,7 @@ def initialize(user, adapter=nil)
end
end
def
allowed?
def
allowed?
if
Gitlab
::
LDAP
::
Person
.
find_by_dn
(
user
.
ldap_identity
.
extern_uid
,
adapt
er
)
if
ldap_us
er
return
true
unless
ldap_config
.
active_directory
return
true
unless
ldap_config
.
active_directory
# Block user in GitLab if he/she was blocked in AD
# Block user in GitLab if he/she was blocked in AD
...
@@ -59,6 +59,10 @@ def adapter
...
@@ -59,6 +59,10 @@ def adapter
def
ldap_config
def
ldap_config
Gitlab
::
LDAP
::
Config
.
new
(
provider
)
Gitlab
::
LDAP
::
Config
.
new
(
provider
)
end
end
def
ldap_user
@ldap_user
||=
Gitlab
::
LDAP
::
Person
.
find_by_dn
(
user
.
ldap_identity
.
extern_uid
,
adapter
)
end
end
end
end
end
end
end
lib/gitlab/ldap/adapter.rb
View file @
67aa0b8c
...
@@ -70,19 +70,25 @@ def dn_matches_filter?(dn, filter)
...
@@ -70,19 +70,25 @@ def dn_matches_filter?(dn, filter)
end
end
def
ldap_search
(
*
args
)
def
ldap_search
(
*
args
)
results
=
ldap
.
search
(
*
args
)
# Net::LDAP's `time` argument doesn't work. Use Ruby `Timeout` instead.
Timeout
.
timeout
(
config
.
timeout
)
do
results
=
ldap
.
search
(
*
args
)
if
results
.
nil?
if
results
.
nil?
response
=
ldap
.
get_operation_result
response
=
ldap
.
get_operation_result
unless
response
.
code
.
zero?
unless
response
.
code
.
zero?
Rails
.
logger
.
warn
(
"LDAP search error:
#{
response
.
message
}
"
)
Rails
.
logger
.
warn
(
"LDAP search error:
#{
response
.
message
}
"
)
end
end
[]
[]
else
else
results
results
end
end
end
rescue
Timeout
::
Error
Rails
.
logger
.
warn
(
"LDAP search timed out after
#{
config
.
timeout
}
seconds"
)
[]
end
end
end
end
end
end
...
...
lib/gitlab/ldap/config.rb
View file @
67aa0b8c
...
@@ -88,6 +88,10 @@ def attributes
...
@@ -88,6 +88,10 @@ def attributes
options
[
'attributes'
]
options
[
'attributes'
]
end
end
def
timeout
options
[
'timeout'
].
to_i
end
protected
protected
def
base_config
def
base_config
Gitlab
.
config
.
ldap
Gitlab
.
config
.
ldap
...
...
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