Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
37e09858
Commit
37e09858
authored
Oct 21, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rake gitlab:ldap:check
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
a54d5dc7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
31 deletions
+15
-31
lib/gitlab/ldap/adapter.rb
lib/gitlab/ldap/adapter.rb
+5
-1
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+10
-30
No files found.
lib/gitlab/ldap/adapter.rb
View file @
37e09858
...
@@ -22,7 +22,7 @@ module Gitlab
...
@@ -22,7 +22,7 @@ module Gitlab
Gitlab
::
LDAP
::
Config
.
new
(
provider
)
Gitlab
::
LDAP
::
Config
.
new
(
provider
)
end
end
def
users
(
field
,
value
)
def
users
(
field
,
value
,
limit
=
nil
)
if
field
.
to_sym
==
:dn
if
field
.
to_sym
==
:dn
options
=
{
options
=
{
base:
value
,
base:
value
,
...
@@ -45,6 +45,10 @@ module Gitlab
...
@@ -45,6 +45,10 @@ module Gitlab
end
end
end
end
if
limit
.
present?
options
.
merge!
(
size:
limit
)
end
entries
=
ldap_search
(
options
).
select
do
|
entry
|
entries
=
ldap_search
(
options
).
select
do
|
entry
|
entry
.
respond_to?
config
.
uid
entry
.
respond_to?
config
.
uid
end
end
...
...
lib/tasks/gitlab/check.rake
View file @
37e09858
...
@@ -664,7 +664,7 @@ namespace :gitlab do
...
@@ -664,7 +664,7 @@ namespace :gitlab do
warn_user_is_not_gitlab
warn_user_is_not_gitlab
start_checking
"LDAP"
start_checking
"LDAP"
if
ldap_config
.
enabled
if
Gitlab
::
LDAP
::
Config
.
enabled?
print_users
(
args
.
limit
)
print_users
(
args
.
limit
)
else
else
puts
'LDAP is disabled in config/gitlab.yml'
puts
'LDAP is disabled in config/gitlab.yml'
...
@@ -675,38 +675,18 @@ namespace :gitlab do
...
@@ -675,38 +675,18 @@ namespace :gitlab do
def
print_users
(
limit
)
def
print_users
(
limit
)
puts
"LDAP users with access to your GitLab server (only showing the first
#{
limit
}
results)"
puts
"LDAP users with access to your GitLab server (only showing the first
#{
limit
}
results)"
ldap
.
search
(
attributes:
attributes
,
filter:
filter
,
size:
limit
,
return_result:
false
)
do
|
entry
|
puts
"DN:
#{
entry
.
dn
}
\t
#{
ldap_config
.
uid
}
:
#{
entry
[
ldap_config
.
uid
]
}
"
end
end
def
attributes
servers
=
Gitlab
.
config
.
ldap
.
servers
.
keys
[
ldap_config
.
uid
]
end
def
filter
uid_filter
=
Net
::
LDAP
::
Filter
.
present?
(
ldap_config
.
uid
)
if
user_filter
Net
::
LDAP
::
Filter
.
join
(
uid_filter
,
user_filter
)
else
uid_filter
end
end
def
user_filter
servers
.
each
do
|
server
|
if
ldap_config
[
'user_filter'
]
&&
ldap_config
.
user_filter
.
present?
puts
"Server:
#{
server
}
"
Net
::
LDAP
::
Filter
.
construct
(
ldap_config
.
user_filter
)
Gitlab
::
LDAP
::
Adapter
.
open
(
"ldap
#{
server
}
"
)
do
|
adapter
|
else
users
=
adapter
.
users
(
adapter
.
config
.
uid
,
'*'
,
100
)
nil
users
.
each
do
|
user
|
puts
"
\t
DN:
#{
user
.
dn
}
\t
#{
adapter
.
config
.
uid
}
:
#{
user
.
uid
}
"
end
end
end
end
def
ldap
@ldap
||=
OmniAuth
::
LDAP
::
Adaptor
.
new
(
ldap_config
).
connection
end
end
def
ldap_config
@ldap_config
||=
Gitlab
.
config
.
ldap
end
end
end
end
...
...
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