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
5a4ea5ee
Commit
5a4ea5ee
authored
Dec 29, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'grapify-ldap-api' into 'master'
Grapify the LDAP API See merge request !1003
parents
09d78a38
78863f87
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
lib/api/ldap.rb
lib/api/ldap.rb
+20
-16
No files found.
lib/api/ldap.rb
View file @
5a4ea5ee
module
API
# groups API
class
Ldap
<
Grape
::
API
before
{
authenticate!
}
resource
:ldap
do
helpers
do
def
get_group_list
(
provider
,
search
)
search
||=
""
search
=
Net
::
LDAP
::
Filter
.
escape
(
search
)
Gitlab
::
LDAP
::
Adapter
.
new
(
provider
).
groups
(
"
#{
search
}
*"
,
20
)
end
params
:search_params
do
optional
:search
,
type:
String
,
default:
''
,
desc:
'Search for a specific LDAP group'
end
end
# Get a LDAP groups list. Limit size to 20 of them.
# Filter results by name using search param
#
# Example Request:
# GET /ldap/groups
desc
'Get a LDAP groups list. Limit size to 20 of them.'
do
success
Entities
::
LdapGroup
end
params
do
use
:search_params
end
get
'groups'
do
provider
=
Gitlab
::
LDAP
::
Config
.
servers
.
first
[
'provider_name'
]
@
groups
=
get_group_list
(
provider
,
params
[
:search
])
present
@
groups
,
with:
Entities
::
LdapGroup
groups
=
get_group_list
(
provider
,
params
[
:search
])
present
groups
,
with:
Entities
::
LdapGroup
end
# Get a LDAP groups list by the requested provider. Lited size to 20 of them.
# Filter results by name using search param
#
# Example Request:
# GET /ldap/ldapmain/groups
desc
'Get a LDAP groups list by the requested provider. Limit size to 20 of them.'
do
success
Entities
::
LdapGroup
end
params
do
use
:search_params
end
get
':provider/groups'
do
@
groups
=
get_group_list
(
params
[
:provider
],
params
[
:search
])
present
@
groups
,
with:
Entities
::
LdapGroup
groups
=
get_group_list
(
params
[
:provider
],
params
[
:search
])
present
groups
,
with:
Entities
::
LdapGroup
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