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
b1150883
Commit
b1150883
authored
Sep 09, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'improve/gitlab_ldap' of /home/git/repositories/gitlab/gitlab-ee
parents
397282b4
44507069
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
32 deletions
+39
-32
lib/gitlab/ldap/access.rb
lib/gitlab/ldap/access.rb
+1
-1
lib/gitlab/ldap/adapter.rb
lib/gitlab/ldap/adapter.rb
+14
-8
lib/gitlab/ldap/group.rb
lib/gitlab/ldap/group.rb
+5
-13
lib/gitlab/ldap/person.rb
lib/gitlab/ldap/person.rb
+19
-10
No files found.
lib/gitlab/ldap/access.rb
View file @
b1150883
...
...
@@ -12,7 +12,7 @@ module Gitlab
# if instance does not use group_base setting
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_cn
=
ldap_groups
.
map
(
&
:name
)
groups
=
::
Group
.
where
(
ldap_cn:
ldap_groups_cn
)
...
...
lib/gitlab/ldap/adapter.rb
View file @
b1150883
...
...
@@ -51,14 +51,20 @@ module Gitlab
end
end
def
users
(
uid
=
"*"
)
options
=
{
base:
config
[
'base'
],
filter:
Net
::
LDAP
::
Filter
.
eq
(
config
.
uid
,
uid
)
}
def
users
(
field
,
value
)
if
field
.
to_sym
==
:dn
options
=
{
base:
value
}
else
options
=
{
base:
config
[
'base'
],
filter:
Net
::
LDAP
::
Filter
.
eq
(
field
,
value
)
}
end
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
(
*
args
)
users
(
*
args
).
first
end
private
...
...
lib/gitlab/ldap/group.rb
View file @
b1150883
...
...
@@ -19,24 +19,14 @@ module Gitlab
name
.
parameterize
end
def
members
member_uids
.
map
do
|
uid
|
adapter
.
user
(
uid
)
end
.
compact
def
memberuid?
entry
.
respond_to?
:memberuid
end
def
member_uids
if
entry
.
respond_to?
:memberuid
entry
.
memberuid
else
member_dns
.
map
do
|
dn
|
$1
if
dn
=~
/uid=([a-zA-Z0-9.-]+)/
end
end
.
compact
entry
.
memberuid
end
private
def
member_dns
if
entry
.
respond_to?
:member
entry
.
member
...
...
@@ -49,6 +39,8 @@ module Gitlab
end
end
private
def
entry
@entry
end
...
...
lib/gitlab/ldap/person.rb
View file @
b1150883
...
...
@@ -7,15 +7,12 @@
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
def
self
.
find_by_uid
(
uid
)
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
config
.
uid
,
uid
)
end
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
uid
)
def
self
.
find_by_dn
(
dn
)
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
'dn'
,
dn
)
end
def
initialize
(
entry
)
...
...
@@ -27,16 +24,24 @@ module Gitlab
end
def
uid
entry
.
uid
.
join
(
" "
)
entry
.
send
(
config
.
uid
)
.
join
(
" "
)
end
def
username
uid
end
def
dn
entry
.
dn
end
def
groups
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
...
...
@@ -49,6 +54,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