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
c52d1453
Commit
c52d1453
authored
Jan 31, 2018
by
Robert Speicher
Committed by
Robert Speicher
Feb 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'sh-ldap-lock-down-api-admin-10-4' into 'security-10-4-ee'
Restrict LDAP API to admins only - 10.4 port
parent
b0df5ac7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
4 deletions
+24
-4
changelogs/unreleased-ee/sh-lock-down-ldap-api-admin.yml
changelogs/unreleased-ee/sh-lock-down-ldap-api-admin.yml
+5
-0
ee/lib/api/ldap.rb
ee/lib/api/ldap.rb
+1
-1
spec/requests/api/ldap_spec.rb
spec/requests/api/ldap_spec.rb
+18
-3
No files found.
changelogs/unreleased-ee/sh-lock-down-ldap-api-admin.yml
0 → 100644
View file @
c52d1453
---
title
:
Restrict LDAP API to admins only
merge_request
:
author
:
type
:
security
ee/lib/api/ldap.rb
View file @
c52d1453
module
API
module
API
class
Ldap
<
Grape
::
API
class
Ldap
<
Grape
::
API
before
{
authenticate!
}
before
{
authenticate
d_as_admin
!
}
resource
:ldap
do
resource
:ldap
do
helpers
do
helpers
do
...
...
spec/requests/api/ldap_spec.rb
View file @
c52d1453
...
@@ -4,7 +4,8 @@ describe API::Ldap do
...
@@ -4,7 +4,8 @@ describe API::Ldap do
include
ApiHelpers
include
ApiHelpers
include
LdapHelpers
include
LdapHelpers
let
(
:user
)
{
create
(
:user
)
}
set
(
:user
)
{
create
(
:user
)
}
set
(
:admin
)
{
create
(
:admin
)
}
let
(
:adapter
)
{
ldap_adapter
}
let
(
:adapter
)
{
ldap_adapter
}
before
do
before
do
...
@@ -27,8 +28,15 @@ describe API::Ldap do
...
@@ -27,8 +28,15 @@ describe API::Ldap do
end
end
context
"when authenticated as user"
do
context
"when authenticated as user"
do
it
"returns a
n array of ldap groups
"
do
it
"returns a
uthentication error
"
do
get
api
(
"/ldap/groups"
,
user
)
get
api
(
"/ldap/groups"
,
user
)
expect
(
response
.
status
).
to
eq
403
end
end
context
"when authenticated as admin"
do
it
"returns an array of ldap groups"
do
get
api
(
"/ldap/groups"
,
admin
)
expect
(
response
.
status
).
to
eq
200
expect
(
response
.
status
).
to
eq
200
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
2
expect
(
json_response
.
length
).
to
eq
2
...
@@ -46,8 +54,15 @@ describe API::Ldap do
...
@@ -46,8 +54,15 @@ describe API::Ldap do
end
end
context
"when authenticated as user"
do
context
"when authenticated as user"
do
it
"returns a
n array of ldap groups
"
do
it
"returns a
uthentication error
"
do
get
api
(
"/ldap/ldapmain/groups"
,
user
)
get
api
(
"/ldap/ldapmain/groups"
,
user
)
expect
(
response
.
status
).
to
eq
403
end
end
context
"when authenticated as admin"
do
it
"returns an array of ldap groups"
do
get
api
(
"/ldap/ldapmain/groups"
,
admin
)
expect
(
response
.
status
).
to
eq
200
expect
(
response
.
status
).
to
eq
200
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
2
expect
(
json_response
.
length
).
to
eq
2
...
...
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