diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-11-29 16:59:25 -0200 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-11-30 16:02:24 -0200 |
commit | d6b9b21e6db3c32e0f272ab96486876fa8b54d1b (patch) | |
tree | 11392dce46f12f3c0ad236e1a1d143a3b64dceee | |
parent | 467b44cbbfd70c627dca0a8f57966bc5ba0999c3 (diff) | |
download | gitlab-ce-d6b9b21e6db3c32e0f272ab96486876fa8b54d1b.tar.gz |
Allow access to the wiki with git when repository feature disabled
-rw-r--r-- | app/policies/project_policy.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/git_access.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/git_access_wiki.rb | 8 |
3 files changed, 16 insertions, 1 deletions
diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb index 1ee31023e26..8ac4bd9df6d 100644 --- a/app/policies/project_policy.rb +++ b/app/policies/project_policy.rb @@ -50,6 +50,7 @@ class ProjectPolicy < BasePolicy def reporter_access! can! :download_code + can! :download_wiki_code can! :fork_project can! :create_project_snippet can! :update_issue @@ -187,6 +188,7 @@ class ProjectPolicy < BasePolicy unless project.feature_available?(:wiki, user) || project.has_external_wiki? cannot!(*named_abilities(:wiki)) + cannot!(:download_wiki_code) end unless project.feature_available?(:builds, user) && repository_enabled @@ -226,6 +228,7 @@ class ProjectPolicy < BasePolicy can! :read_commit_status can! :read_container_image can! :download_code + can! :download_wiki_code can! :read_cycle_analytics # NOTE: may be overridden by IssuePolicy diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index bcbf6455998..db07b7c5fcc 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -46,7 +46,7 @@ module Gitlab def download_access_check if user user_download_access_check - elsif deploy_key.nil? && !Guest.can?(:download_code, project) + elsif deploy_key.nil? && !guest_can_downlod_code? raise UnauthorizedError, ERROR_MESSAGES[:download] end end @@ -59,6 +59,10 @@ module Gitlab end end + def guest_can_downlod_code? + Guest.can?(:download_code, project) + end + def user_download_access_check unless user_can_download_code? || build_can_download_code? raise UnauthorizedError, ERROR_MESSAGES[:download] diff --git a/lib/gitlab/git_access_wiki.rb b/lib/gitlab/git_access_wiki.rb index f71d3575909..2c06c4ff1ef 100644 --- a/lib/gitlab/git_access_wiki.rb +++ b/lib/gitlab/git_access_wiki.rb @@ -1,5 +1,13 @@ module Gitlab class GitAccessWiki < GitAccess + def guest_can_downlod_code? + Guest.can?(:download_wiki_code, project) + end + + def user_can_download_code? + authentication_abilities.include?(:download_code) && user_access.can_do_action?(:download_wiki_code) + end + def change_access_check(change) if user_access.can_do_action?(:create_wiki) build_status_object(true) |