summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSam Battalio <sambattalio99@gmail.com>2019-06-24 22:12:42 +0000
committerNick Thomas <nick@gitlab.com>2019-06-24 22:12:42 +0000
commit3457695b1e3d2c6e5a10cff6e24a08f7cbb38503 (patch)
treea57f3cc980e709155034e12fa75063a1d9abf02a /lib
parent9e6c3f56fdc90d743db5af12414e955d7a101e5e (diff)
downloadgitlab-ce-3457695b1e3d2c6e5a10cff6e24a08f7cbb38503.tar.gz
Change HTTP Status Code when repository disabled
Diffstat (limited to 'lib')
-rw-r--r--lib/api/branches.rb5
-rw-r--r--lib/api/commits.rb5
-rw-r--r--lib/api/helpers.rb4
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index 65d7f68bbf9..c3821630b6b 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -8,7 +8,10 @@ module API
BRANCH_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(branch: API::NO_SLASH_URL_PART_REGEX)
- before { authorize! :download_code, user_project }
+ before do
+ require_repository_enabled!
+ authorize! :download_code, user_project
+ end
helpers do
params :filter_params do
diff --git a/lib/api/commits.rb b/lib/api/commits.rb
index 80913f4ca07..eebded87ebc 100644
--- a/lib/api/commits.rb
+++ b/lib/api/commits.rb
@@ -6,7 +6,10 @@ module API
class Commits < Grape::API
include PaginationParams
- before { authorize! :download_code, user_project }
+ before do
+ require_repository_enabled!
+ authorize! :download_code, user_project
+ end
helpers do
def user_access
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 6382d295f79..8ae42c6dadd 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -250,6 +250,10 @@ module API
authorize! :update_build, user_project
end
+ def require_repository_enabled!(subject = :global)
+ not_found!("Repository") unless user_project.feature_available?(:repository, current_user)
+ end
+
def require_gitlab_workhorse!
unless env['HTTP_GITLAB_WORKHORSE'].present?
forbidden!('Request should be executed via GitLab Workhorse')