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
2c8d2b08
Commit
2c8d2b08
authored
Sep 15, 2016
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ssh key attr to return attrs
parent
7a67ed66
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
6 deletions
+27
-6
lib/ee/gitlab/ldap/adapter.rb
lib/ee/gitlab/ldap/adapter.rb
+7
-1
lib/gitlab/ldap/adapter.rb
lib/gitlab/ldap/adapter.rb
+6
-2
spec/lib/ee/gitlab/ldap/adapter_spec.rb
spec/lib/ee/gitlab/ldap/adapter_spec.rb
+9
-2
spec/requests/api/ldap_spec.rb
spec/requests/api/ldap_spec.rb
+5
-1
No files found.
lib/ee/gitlab/ldap/adapter.rb
View file @
2c8d2b08
# LDAP connection adapter EE mixin
#
# This module is intended to encapsulate EE-specific adapter methods
# and be
included
in the `Gitlab::LDAP::Adapter` class.
# and be
**prepended**
in the `Gitlab::LDAP::Adapter` class.
module
EE
module
Gitlab
module
LDAP
...
...
@@ -39,6 +39,12 @@ module EE
attributes:
%w{dn}
).
map
(
&
:dn
)
end
def
user_attributes
attributes
=
super
attributes
<<
config
.
sync_ssh_keys
if
config
.
sync_ssh_keys
attributes
end
end
end
end
...
...
lib/gitlab/ldap/adapter.rb
View file @
2c8d2b08
...
...
@@ -5,7 +5,7 @@
module
Gitlab
module
LDAP
class
Adapter
include
EE
::
Gitlab
::
LDAP
::
Adapter
prepend
EE
::
Gitlab
::
LDAP
::
Adapter
attr_reader
:provider
,
:ldap
...
...
@@ -76,7 +76,7 @@ module Gitlab
private
def
user_options
(
field
,
value
,
limit
)
options
=
{
attributes:
%W(
#{
config
.
uid
}
cn mail dn)
}
options
=
{
attributes:
user_attributes
}
options
[
:size
]
=
limit
if
limit
if
field
.
to_sym
==
:dn
...
...
@@ -104,6 +104,10 @@ module Gitlab
filter
end
end
def
user_attributes
%W(
#{
config
.
uid
}
cn mail dn)
end
end
end
end
spec/lib/ee/gitlab/ldap/adapter_spec.rb
View file @
2c8d2b08
...
...
@@ -7,9 +7,9 @@ describe Gitlab::LDAP::Adapter, lib: true do
expect
(
Gitlab
::
LDAP
::
Adapter
).
to
include_module
(
EE
::
Gitlab
::
LDAP
::
Adapter
)
end
describe
'#groups'
do
let
(
:adapter
)
{
ldap_adapter
(
'ldapmain'
)
}
let
(
:adapter
)
{
ldap_adapter
(
'ldapmain'
)
}
describe
'#groups'
do
before
do
stub_ldap_config
(
group_base:
'ou=groups,dc=example,dc=com'
,
...
...
@@ -39,4 +39,11 @@ describe Gitlab::LDAP::Adapter, lib: true do
expect
(
results
.
first
.
member_dns
).
to
match_array
(
%w(john mary)
)
end
end
describe
'#user_attributes'
do
it
'appends EE-specific attributes'
do
stub_ldap_config
(
uid:
'uid'
,
sync_ssh_keys:
'sshPublicKey'
)
expect
(
adapter
.
user_attributes
).
to
match_array
(
%w(uid dn cn mail sshPublicKey)
)
end
end
end
spec/requests/api/ldap_spec.rb
View file @
2c8d2b08
...
...
@@ -2,7 +2,10 @@ require 'spec_helper'
describe
API
::
API
do
include
ApiHelpers
include
LdapHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:adapter
)
{
ldap_adapter
}
before
do
groups
=
[
...
...
@@ -10,7 +13,8 @@ describe API::API do
OpenStruct
.
new
(
cn:
'students'
)
]
allow_any_instance_of
(
Gitlab
::
LDAP
::
Adapter
).
to
receive_messages
(
groups:
groups
)
allow
(
Gitlab
::
LDAP
::
Adapter
).
to
receive
(
:new
).
and_return
(
adapter
)
allow
(
adapter
).
to
receive_messages
(
groups:
groups
)
end
describe
"GET /ldap/groups"
do
...
...
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