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
Jérome Perrin
gitlab-ce
Commits
d6b9b21e
Commit
d6b9b21e
authored
Nov 29, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow access to the wiki with git when repository feature disabled
parent
467b44cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
app/policies/project_policy.rb
app/policies/project_policy.rb
+3
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+5
-1
lib/gitlab/git_access_wiki.rb
lib/gitlab/git_access_wiki.rb
+8
-0
No files found.
app/policies/project_policy.rb
View file @
d6b9b21e
...
@@ -50,6 +50,7 @@ class ProjectPolicy < BasePolicy
...
@@ -50,6 +50,7 @@ class ProjectPolicy < BasePolicy
def
reporter_access!
def
reporter_access!
can!
:download_code
can!
:download_code
can!
:download_wiki_code
can!
:fork_project
can!
:fork_project
can!
:create_project_snippet
can!
:create_project_snippet
can!
:update_issue
can!
:update_issue
...
@@ -187,6 +188,7 @@ class ProjectPolicy < BasePolicy
...
@@ -187,6 +188,7 @@ class ProjectPolicy < BasePolicy
unless
project
.
feature_available?
(
:wiki
,
user
)
||
project
.
has_external_wiki?
unless
project
.
feature_available?
(
:wiki
,
user
)
||
project
.
has_external_wiki?
cannot!
(
*
named_abilities
(
:wiki
))
cannot!
(
*
named_abilities
(
:wiki
))
cannot!
(
:download_wiki_code
)
end
end
unless
project
.
feature_available?
(
:builds
,
user
)
&&
repository_enabled
unless
project
.
feature_available?
(
:builds
,
user
)
&&
repository_enabled
...
@@ -226,6 +228,7 @@ class ProjectPolicy < BasePolicy
...
@@ -226,6 +228,7 @@ class ProjectPolicy < BasePolicy
can!
:read_commit_status
can!
:read_commit_status
can!
:read_container_image
can!
:read_container_image
can!
:download_code
can!
:download_code
can!
:download_wiki_code
can!
:read_cycle_analytics
can!
:read_cycle_analytics
# NOTE: may be overridden by IssuePolicy
# NOTE: may be overridden by IssuePolicy
...
...
lib/gitlab/git_access.rb
View file @
d6b9b21e
...
@@ -46,7 +46,7 @@ module Gitlab
...
@@ -46,7 +46,7 @@ module Gitlab
def
download_access_check
def
download_access_check
if
user
if
user
user_download_access_check
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
]
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:download
]
end
end
end
end
...
@@ -59,6 +59,10 @@ module Gitlab
...
@@ -59,6 +59,10 @@ module Gitlab
end
end
end
end
def
guest_can_downlod_code?
Guest
.
can?
(
:download_code
,
project
)
end
def
user_download_access_check
def
user_download_access_check
unless
user_can_download_code?
||
build_can_download_code?
unless
user_can_download_code?
||
build_can_download_code?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:download
]
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:download
]
...
...
lib/gitlab/git_access_wiki.rb
View file @
d6b9b21e
module
Gitlab
module
Gitlab
class
GitAccessWiki
<
GitAccess
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
)
def
change_access_check
(
change
)
if
user_access
.
can_do_action?
(
:create_wiki
)
if
user_access
.
can_do_action?
(
:create_wiki
)
build_status_object
(
true
)
build_status_object
(
true
)
...
...
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