BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0d35b081
Commit
0d35b081
authored
Aug 01, 2017
by
Lin Jen-Shin (godfat)
Committed by
Rémy Coutable
Aug 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow logged in users to read user list under public restriction
parent
cfa41e62
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
18 deletions
+28
-18
global_policy.rb
app/policies/global_policy.rb
+1
-1
35697-allow-logged-in-user-to-read-user-list.yml
...released/35697-allow-logged-in-user-to-read-user-list.yml
+4
-0
users_spec.rb
spec/requests/api/users_spec.rb
+23
-17
No files found.
app/policies/global_policy.rb
View file @
0d35b081
...
...
@@ -44,7 +44,7 @@ class GlobalPolicy < BasePolicy
prevent
:log_in
end
rule
{
admin
|
~
restricted_public_level
}.
policy
do
rule
{
~
(
anonymous
&
restricted_public_level
)
}.
policy
do
enable
:read_users_list
end
end
changelogs/unreleased/35697-allow-logged-in-user-to-read-user-list.yml
0 → 100644
View file @
0d35b081
---
title
:
Allow any logged in users to read_users_list even if it's restricted
merge_request
:
13201
author
:
spec/requests/api/users_spec.rb
View file @
0d35b081
...
...
@@ -16,38 +16,44 @@ describe API::Users do
it
"returns authorization error when the `username` parameter is not passed"
do
get
api
(
"/users"
)
expect
(
response
).
to
have_http_status
(
403
)
expect
(
response
).
to
have_
gitlab_
http_status
(
403
)
end
it
"returns the user when a valid `username` parameter is passed"
do
user
=
create
(
:user
)
get
api
(
"/users"
),
username:
user
.
username
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_
gitlab_
http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
[
0
][
'id'
]).
to
eq
(
user
.
id
)
expect
(
json_response
[
0
][
'username'
]).
to
eq
(
user
.
username
)
end
it
"returns authorization error when the `username` parameter refers to an inaccessible user"
do
user
=
create
(
:user
)
stub_application_setting
(
restricted_visibility_levels:
[
Gitlab
::
VisibilityLevel
::
PUBLIC
])
get
api
(
"/users"
),
username:
user
.
username
expect
(
response
).
to
have_http_status
(
403
)
end
it
"returns an empty response when an invalid `username` parameter is passed"
do
get
api
(
"/users"
),
username:
'invalid'
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_
gitlab_
http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
0
)
end
context
"when public level is restricted"
do
before
do
stub_application_setting
(
restricted_visibility_levels:
[
Gitlab
::
VisibilityLevel
::
PUBLIC
])
end
it
"returns authorization error when the `username` parameter refers to an inaccessible user"
do
get
api
(
"/users"
),
username:
user
.
username
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
it
"returns authorization error when the `username` parameter is not passed"
do
get
api
(
"/users"
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
end
context
"when authenticated"
do
...
...
@@ -58,10 +64,10 @@ describe API::Users do
end
context
'when authenticate as a regular user'
do
it
"renders
403
"
do
it
"renders
200
"
do
get
api
(
"/users"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
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