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
44507069
Commit
44507069
authored
Sep 09, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use dn lookup for person. Collect group members dn when check for membership
parent
d30a55a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
34 deletions
+32
-34
lib/gitlab/ldap/access.rb
lib/gitlab/ldap/access.rb
+1
-1
lib/gitlab/ldap/adapter.rb
lib/gitlab/ldap/adapter.rb
+11
-11
lib/gitlab/ldap/group.rb
lib/gitlab/ldap/group.rb
+5
-17
lib/gitlab/ldap/person.rb
lib/gitlab/ldap/person.rb
+15
-5
No files found.
lib/gitlab/ldap/access.rb
View file @
44507069
...
@@ -12,7 +12,7 @@ module Gitlab
...
@@ -12,7 +12,7 @@ module Gitlab
# if instance does not use group_base setting
# if instance does not use group_base setting
return
true
unless
Gitlab
.
config
.
ldap
[
'group_base'
].
present?
return
true
unless
Gitlab
.
config
.
ldap
[
'group_base'
].
present?
ldap_user
=
Gitlab
::
LDAP
::
Person
.
find
(
user
.
extern_uid
)
ldap_user
=
Gitlab
::
LDAP
::
Person
.
find
_by_dn
(
user
.
extern_uid
)
ldap_groups
=
ldap_user
.
groups
ldap_groups
=
ldap_user
.
groups
ldap_groups_cn
=
ldap_groups
.
map
(
&
:name
)
ldap_groups_cn
=
ldap_groups
.
map
(
&
:name
)
groups
=
::
Group
.
where
(
ldap_cn:
ldap_groups_cn
)
groups
=
::
Group
.
where
(
ldap_cn:
ldap_groups_cn
)
...
...
lib/gitlab/ldap/adapter.rb
View file @
44507069
...
@@ -51,18 +51,18 @@ module Gitlab
...
@@ -51,18 +51,18 @@ module Gitlab
end
end
end
end
def
users
(
opts
)
def
users
(
field
,
value
)
if
opts
.
respond_to?
:key?
if
field
.
to_sym
==
:dn
key
,
uid
=
opts
.
keys
.
first
,
opts
.
values
.
first
options
=
{
base:
value
}
else
else
key
,
uid
=
config
.
uid
,
opts
||
"*"
options
=
{
base:
config
[
'base'
],
filter:
Net
::
LDAP
::
Filter
.
eq
(
field
,
value
)
}
end
end
options
=
{
base:
config
[
'base'
],
filter:
Net
::
LDAP
::
Filter
.
eq
(
key
,
uid
)
}
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
...
@@ -72,8 +72,8 @@ module Gitlab
...
@@ -72,8 +72,8 @@ module Gitlab
end
end
end
end
def
user
(
opt
s
)
def
user
(
*
arg
s
)
users
(
opt
s
).
first
users
(
*
arg
s
).
first
end
end
private
private
...
...
lib/gitlab/ldap/group.rb
View file @
44507069
...
@@ -19,24 +19,14 @@ module Gitlab
...
@@ -19,24 +19,14 @@ module Gitlab
name
.
parameterize
name
.
parameterize
end
end
def
members
def
memberuid?
member_uids
.
map
do
|
opts
|
entry
.
respond_to?
:memberuid
adapter
.
user
(
opts
)
end
.
compact
end
end
def
member_uids
def
member_uids
if
entry
.
respond_to?
:memberuid
entry
.
memberuid
entry
.
memberuid
else
member_dns
.
map
do
|
dn
|
dn_to_opts
(
dn
)
end
end
.
compact
end
end
private
def
member_dns
def
member_dns
if
entry
.
respond_to?
:member
if
entry
.
respond_to?
:member
entry
.
member
entry
.
member
...
@@ -49,6 +39,8 @@ module Gitlab
...
@@ -49,6 +39,8 @@ module Gitlab
end
end
end
end
private
def
entry
def
entry
@entry
@entry
end
end
...
@@ -56,10 +48,6 @@ module Gitlab
...
@@ -56,10 +48,6 @@ module Gitlab
def
adapter
def
adapter
@adapter
||=
Gitlab
::
LDAP
::
Adapter
.
new
@adapter
||=
Gitlab
::
LDAP
::
Adapter
.
new
end
end
def
dn_to_opts
(
dn
)
dn
.
split
(
","
).
first
.
split
(
"="
)
end
end
end
end
end
end
end
lib/gitlab/ldap/person.rb
View file @
44507069
...
@@ -7,10 +7,12 @@
...
@@ -7,10 +7,12 @@
module
Gitlab
module
Gitlab
module
LDAP
module
LDAP
class
Person
class
Person
def
self
.
find
(
user_uid
)
def
self
.
find_by_uid
(
uid
)
id
=
user_uid
.
split
(
","
).
first
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
config
.
uid
,
uid
)
key
,
value
=
id
.
split
(
"="
)
end
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
key
=>
value
)
def
self
.
find_by_dn
(
dn
)
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
'dn'
,
dn
)
end
end
def
initialize
(
entry
)
def
initialize
(
entry
)
...
@@ -29,9 +31,17 @@ module Gitlab
...
@@ -29,9 +31,17 @@ module Gitlab
uid
uid
end
end
def
dn
entry
.
dn
end
def
groups
def
groups
adapter
.
groups
.
select
do
|
group
|
adapter
.
groups
.
select
do
|
group
|
group
.
member_uids
.
include?
(
uid
)
if
group
.
memberuid?
group
.
member_uids
.
include?
(
uid
)
else
group
.
member_dns
.
include?
(
dn
)
end
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