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
1fd0639a
Commit
1fd0639a
authored
Oct 01, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ldap_groups_select' of /home/git/repositories/gitlab/gitlab-ee
parents
5cd06603
89654431
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
108 additions
and
5 deletions
+108
-5
app/assets/javascripts/api.js.coffee
app/assets/javascripts/api.js.coffee
+19
-3
app/assets/javascripts/ldap_groups_select.js.coffee
app/assets/javascripts/ldap_groups_select.js.coffee
+26
-0
app/views/groups/edit.html.haml
app/views/groups/edit.html.haml
+1
-1
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/entities.rb
lib/api/entities.rb
+4
-0
lib/api/ldap.rb
lib/api/ldap.rb
+18
-0
lib/gitlab/ldap/adapter.rb
lib/gitlab/ldap/adapter.rb
+3
-1
spec/requests/api/ldap_spec.rb
spec/requests/api/ldap_spec.rb
+36
-0
No files found.
app/assets/javascripts/api.js.coffee
View file @
1fd0639a
...
...
@@ -2,13 +2,14 @@
users_path
:
"/api/:version/users.json"
user_path
:
"/api/:version/users/:id.json"
notes_path
:
"/api/:version/projects/:id/notes.json"
ldap_groups_path
:
"/api/:version/ldap/groups.json"
# Get 20 (depends on api) recent notes
# Get 20 (depends on api) recent notes
# and sort the ascending from oldest to newest
notes
:
(
project_id
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
notes_path
)
url
=
url
.
replace
(
':id'
,
project_id
)
$
.
ajax
(
url
:
url
,
data
:
...
...
@@ -37,7 +38,7 @@
# Only active users retrieved
users
:
(
query
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
users_path
)
$
.
ajax
(
url
:
url
data
:
...
...
@@ -52,3 +53,18 @@
buildUrl
:
(
url
)
->
url
=
gon
.
relative_url_root
+
url
if
gon
.
relative_url_root
?
return
url
.
replace
(
':version'
,
gon
.
api_version
)
# Return LDAP groups list. Filtered by query
ldap_groups
:
(
query
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
ldap_groups_path
)
$
.
ajax
(
url
:
url
data
:
private_token
:
gon
.
api_token
search
:
query
per_page
:
20
active
:
true
dataType
:
"json"
).
done
(
groups
)
->
callback
(
groups
)
app/assets/javascripts/ldap_groups_select.js.coffee
0 → 100644
View file @
1fd0639a
$
->
ldapGroupResult
=
(
group
)
->
group
.
cn
groupFormatSelection
=
(
group
)
->
group
.
cn
$
(
'.ajax-ldap-groups-select'
).
each
(
i
,
select
)
->
$
(
select
).
select2
id
:
(
group
)
->
group
.
cn
placeholder
:
"Search for a LDAP group"
minimumInputLength
:
1
query
:
(
query
)
->
Api
.
ldap_groups
query
.
term
,
(
groups
)
->
data
=
{
results
:
groups
}
query
.
callback
(
data
)
initSelection
:
(
element
,
callback
)
->
id
=
$
(
element
).
val
()
if
id
isnt
""
callback
(
cn
:
id
)
formatResult
:
ldapGroupResult
formatSelection
:
groupFormatSelection
dropdownCssClass
:
"ajax-groups-dropdown"
app/views/groups/edit.html.haml
View file @
1fd0639a
...
...
@@ -76,7 +76,7 @@
=
f
.
label
:ldap_cn
do
LDAP Group cn
.controls
=
f
.
text_field
:ldap_cn
,
placeholder:
"Ex. QA group"
,
class:
"xxlarge lef
t"
=
f
.
hidden_field
:ldap_cn
,
placeholder:
"Ex. QA group"
,
class:
"xxlarge ajax-ldap-groups-selec
t"
.control-group
=
f
.
label
:ldap_access
do
...
...
lib/api/api.rb
View file @
1fd0639a
...
...
@@ -38,5 +38,6 @@ module API
mount
ProjectSnippets
mount
DeployKeys
mount
ProjectHooks
mount
Ldap
end
end
lib/api/entities.rb
View file @
1fd0639a
...
...
@@ -136,5 +136,9 @@ module API
expose
:target_id
,
:target_type
,
:author_id
expose
:data
,
:target_title
end
class
LdapGroup
<
Grape
::
Entity
expose
:cn
end
end
end
lib/api/ldap.rb
0 → 100644
View file @
1fd0639a
module
API
# groups API
class
Ldap
<
Grape
::
API
before
{
authenticate!
}
resource
:ldap
do
# Get a LDAP groups list. Limit size to 20 of them.
# Filter results by name using search param
#
# Example Request:
# GET /ldap/groups
get
'groups'
do
@groups
=
Gitlab
::
LDAP
::
Adapter
.
new
.
groups
(
"
#{
params
[
:search
]
}
*"
,
20
)
present
@groups
,
with:
Entities
::
LdapGroup
end
end
end
end
lib/gitlab/ldap/adapter.rb
View file @
1fd0639a
...
...
@@ -40,12 +40,14 @@ module Gitlab
# Ex.
# groups("dev*") # return all groups start with 'dev'
#
def
groups
(
cn
=
"*"
)
def
groups
(
cn
=
"*"
,
size
=
nil
)
options
=
{
base:
config
[
'group_base'
],
filter:
Net
::
LDAP
::
Filter
.
eq
(
"cn"
,
cn
)
}
options
.
merge!
(
size:
size
)
if
size
ldap
.
search
(
options
).
map
do
|
entry
|
Gitlab
::
LDAP
::
Group
.
new
(
entry
)
end
...
...
spec/requests/api/ldap_spec.rb
0 → 100644
View file @
1fd0639a
require
'spec_helper'
describe
API
::
API
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
before
do
groups
=
[
OpenStruct
.
new
(
cn:
'developers'
),
OpenStruct
.
new
(
cn:
'students'
)
]
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
groups:
groups
)
end
describe
"GET /ldap/groups"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
get
api
(
"/ldap/groups"
)
response
.
status
.
should
==
401
end
end
context
"when authenticated as user"
do
it
"should return an array of ldap groups"
do
get
api
(
"/ldap/groups"
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
length
.
should
==
2
json_response
.
first
[
'cn'
].
should
==
'developers'
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