Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
67aa0b8c
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
67aa0b8c
编写于
12月 31, 2015
作者:
D
Drew Blessing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize LDAP and add a search timeout
上级
a9800ce4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
37 addition
and
11 deletion
+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
未找到文件。
CHANGELOG
浏览文件 @
67aa0b8c
...
...
@@ -37,6 +37,7 @@ v 8.4.0 (unreleased)
v 8.3.3 (unreleased)
- 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)
- 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
- 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)
...
...
config/gitlab.yml.example
浏览文件 @
67aa0b8c
...
...
@@ -204,6 +204,11 @@ production: &base
bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
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.
# For non AD servers it skips the AD specific queries.
# If your LDAP server is not AD, set this to false.
...
...
config/initializers/1_settings.rb
浏览文件 @
67aa0b8c
...
...
@@ -108,6 +108,7 @@ if Settings.ldap['enabled'] || Rails.env.test?
Settings
.
ldap
[
'servers'
].
each
do
|
key
,
server
|
server
[
'label'
]
||=
'LDAP'
server
[
'timeout'
]
||=
10
.
seconds
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
[
'active_directory'
]
=
true
if
server
[
'active_directory'
].
nil?
...
...
doc/integration/ldap.md
浏览文件 @
67aa0b8c
...
...
@@ -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'
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.
# For non AD servers it skips the AD specific queries.
# If your LDAP server is not AD, set this to false.
...
...
lib/gitlab/ldap/access.rb
浏览文件 @
67aa0b8c
...
...
@@ -5,7 +5,7 @@
module
Gitlab
module
LDAP
class
Access
attr_reader
:
adapter
,
:
provider
,
:user
attr_reader
:provider
,
:user
def
self
.
open
(
user
,
&
block
)
Gitlab
::
LDAP
::
Adapter
.
open
(
user
.
ldap_identity
.
provider
)
do
|
adapter
|
...
...
@@ -32,7 +32,7 @@ module Gitlab
end
def
allowed?
if
Gitlab
::
LDAP
::
Person
.
find_by_dn
(
user
.
ldap_identity
.
extern_uid
,
adapter
)
if
ldap_user
return
true
unless
ldap_config
.
active_directory
# Block user in GitLab if he/she was blocked in AD
...
...
@@ -59,6 +59,10 @@ module Gitlab
def
ldap_config
Gitlab
::
LDAP
::
Config
.
new
(
provider
)
end
def
ldap_user
@ldap_user
||=
Gitlab
::
LDAP
::
Person
.
find_by_dn
(
user
.
ldap_identity
.
extern_uid
,
adapter
)
end
end
end
end
lib/gitlab/ldap/adapter.rb
浏览文件 @
67aa0b8c
...
...
@@ -70,19 +70,25 @@ module Gitlab
end
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?
response
=
ldap
.
get_operation_result
if
results
.
nil?
response
=
ldap
.
get_operation_result
unless
response
.
code
.
zero?
Rails
.
logger
.
warn
(
"LDAP search error:
#{
response
.
message
}
"
)
end
unless
response
.
code
.
zero?
Rails
.
logger
.
warn
(
"LDAP search error:
#{
response
.
message
}
"
)
end
[]
else
results
[]
else
results
end
end
rescue
Timeout
::
Error
Rails
.
logger
.
warn
(
"LDAP search timed out after
#{
config
.
timeout
}
seconds"
)
[]
end
end
end
...
...
lib/gitlab/ldap/config.rb
浏览文件 @
67aa0b8c
...
...
@@ -88,6 +88,10 @@ module Gitlab
options
[
'attributes'
]
end
def
timeout
options
[
'timeout'
].
to_i
end
protected
def
base_config
Gitlab
.
config
.
ldap
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录