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
d30a55a9
Commit
d30a55a9
authored
Sep 07, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use LDAP user uid from config. Search by first value from user dn
parent
397282b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
17 deletions
+26
-17
lib/gitlab/ldap/adapter.rb
lib/gitlab/ldap/adapter.rb
+11
-5
lib/gitlab/ldap/group.rb
lib/gitlab/ldap/group.rb
+7
-3
lib/gitlab/ldap/person.rb
lib/gitlab/ldap/person.rb
+8
-9
No files found.
lib/gitlab/ldap/adapter.rb
View file @
d30a55a9
...
...
@@ -51,14 +51,20 @@ module Gitlab
end
end
def
users
(
uid
=
"*"
)
def
users
(
opts
)
if
opts
.
respond_to?
:key?
key
,
uid
=
opts
.
keys
.
first
,
opts
.
values
.
first
else
key
,
uid
=
config
.
uid
,
opts
||
"*"
end
options
=
{
base:
config
[
'base'
],
filter:
Net
::
LDAP
::
Filter
.
eq
(
config
.
uid
,
uid
)
filter:
Net
::
LDAP
::
Filter
.
eq
(
key
,
uid
)
}
entries
=
ldap
.
search
(
options
).
select
do
|
entry
|
entry
.
respond_to?
:
uid
entry
.
respond_to?
config
.
uid
end
entries
.
map
do
|
entry
|
...
...
@@ -66,8 +72,8 @@ module Gitlab
end
end
def
user
(
uid
)
users
(
uid
).
first
def
user
(
opts
)
users
(
opts
).
first
end
private
...
...
lib/gitlab/ldap/group.rb
View file @
d30a55a9
...
...
@@ -20,8 +20,8 @@ module Gitlab
end
def
members
member_uids
.
map
do
|
uid
|
adapter
.
user
(
uid
)
member_uids
.
map
do
|
opts
|
adapter
.
user
(
opts
)
end
.
compact
end
...
...
@@ -30,7 +30,7 @@ module Gitlab
entry
.
memberuid
else
member_dns
.
map
do
|
dn
|
$1
if
dn
=~
/uid=([a-zA-Z0-9.-]+)/
dn_to_opts
(
dn
)
end
end
.
compact
end
...
...
@@ -56,6 +56,10 @@ module Gitlab
def
adapter
@adapter
||=
Gitlab
::
LDAP
::
Adapter
.
new
end
def
dn_to_opts
(
dn
)
dn
.
split
(
","
).
first
.
split
(
"="
)
end
end
end
end
lib/gitlab/ldap/person.rb
View file @
d30a55a9
...
...
@@ -8,14 +8,9 @@ module Gitlab
module
LDAP
class
Person
def
self
.
find
(
user_uid
)
uid
=
if
user_uid
=~
/uid=([a-zA-Z0-9.-]+)/
$1
else
user_uid
end
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
uid
)
id
=
user_uid
.
split
(
","
).
first
key
,
value
=
id
.
split
(
"="
)
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
key
=>
value
)
end
def
initialize
(
entry
)
...
...
@@ -27,7 +22,7 @@ module Gitlab
end
def
uid
entry
.
uid
.
join
(
" "
)
entry
.
send
(
config
.
uid
)
.
join
(
" "
)
end
def
username
...
...
@@ -49,6 +44,10 @@ module Gitlab
def
adapter
@adapter
||=
Gitlab
::
LDAP
::
Adapter
.
new
end
def
config
@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