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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
bdee9e84
Commit
bdee9e84
authored
Mar 22, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow guest users from accessing Releases
As they do not have a permission to read git tag
parent
61b2f70f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
3 deletions
+46
-3
app/policies/project_policy.rb
app/policies/project_policy.rb
+1
-1
changelogs/unreleased/disallow-guests-to-access-releases.yml
changelogs/unreleased/disallow-guests-to-access-releases.yml
+5
-0
spec/policies/project_policy_spec.rb
spec/policies/project_policy_spec.rb
+2
-2
spec/requests/api/releases_spec.rb
spec/requests/api/releases_spec.rb
+38
-0
No files found.
app/policies/project_policy.rb
View file @
bdee9e84
...
...
@@ -177,7 +177,6 @@ class ProjectPolicy < BasePolicy
enable
:read_cycle_analytics
enable
:award_emoji
enable
:read_pages_content
enable
:read_release
end
# These abilities are not allowed to admins that are not members of the project,
...
...
@@ -203,6 +202,7 @@ class ProjectPolicy < BasePolicy
enable
:read_deployment
enable
:read_merge_request
enable
:read_sentry_issue
enable
:read_release
end
# We define `:public_user_access` separately because there are cases in gitlab-ee
...
...
changelogs/unreleased/disallow-guests-to-access-releases.yml
0 → 100644
View file @
bdee9e84
---
title
:
Disallow guest users from accessing Releases
merge_request
:
author
:
type
:
security
spec/policies/project_policy_spec.rb
View file @
bdee9e84
...
...
@@ -15,7 +15,7 @@ describe ProjectPolicy do
read_project_for_iids read_issue_iid read_label
read_milestone read_project_snippet read_project_member read_note
create_project create_issue create_note upload_file create_merge_request_in
award_emoji
read_release
award_emoji
]
end
...
...
@@ -24,7 +24,7 @@ describe ProjectPolicy do
download_code fork_project create_project_snippet update_issue
admin_issue admin_label admin_list read_commit_status read_build
read_container_image read_pipeline read_environment read_deployment
read_merge_request download_wiki_code read_sentry_issue
read_merge_request download_wiki_code read_sentry_issue
read_release
]
end
...
...
spec/requests/api/releases_spec.rb
View file @
bdee9e84
...
...
@@ -4,12 +4,14 @@ describe API::Releases do
let
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let
(
:maintainer
)
{
create
(
:user
)
}
let
(
:reporter
)
{
create
(
:user
)
}
let
(
:guest
)
{
create
(
:user
)
}
let
(
:non_project_member
)
{
create
(
:user
)
}
let
(
:commit
)
{
create
(
:commit
,
project:
project
)
}
before
do
project
.
add_maintainer
(
maintainer
)
project
.
add_reporter
(
reporter
)
project
.
add_guest
(
guest
)
project
.
repository
.
add_tag
(
maintainer
,
'v0.1'
,
commit
.
id
)
project
.
repository
.
add_tag
(
maintainer
,
'v0.2'
,
commit
.
id
)
...
...
@@ -66,6 +68,24 @@ describe API::Releases do
end
end
context
'when user is a guest'
do
it
'responds 403 Forbidden'
do
get
api
(
"/projects/
#{
project
.
id
}
/releases"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
context
'when project is public'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
it
'responds 200 OK'
do
get
api
(
"/projects/
#{
project
.
id
}
/releases"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
context
'when user is not a project member'
do
it
'cannot find the project'
do
get
api
(
"/projects/
#{
project
.
id
}
/releases"
,
non_project_member
)
...
...
@@ -189,6 +209,24 @@ describe API::Releases do
end
end
end
context
'when user is a guest'
do
it
'responds 403 Forbidden'
do
get
api
(
"/projects/
#{
project
.
id
}
/releases/v0.1"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
context
'when project is public'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
it
'responds 200 OK'
do
get
api
(
"/projects/
#{
project
.
id
}
/releases/v0.1"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
context
'when specified tag is not found in the project'
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