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
8dbea582
Commit
8dbea582
authored
Nov 18, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check download privilege more specifically and
add another error message for the new error.
parent
e72e2f9b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
+29
-29
git_access.rb
lib/gitlab/git_access.rb
+29
-29
No files found.
lib/gitlab/git_access.rb
View file @
8dbea582
...
...
@@ -7,7 +7,10 @@ module Gitlab
ERROR_MESSAGES
=
{
upload:
'You are not allowed to upload code for this project.'
,
download:
'You are not allowed to download code from this project.'
,
deploy_key:
'This deploy key does not have write access to this project.'
,
deploy_key_upload:
'This deploy key does not have write access to this project.'
,
deploy_key:
'This deploy key does not have access to this project.'
,
no_repo:
'A repository for this project does not exist yet.'
}
...
...
@@ -44,29 +47,36 @@ module Gitlab
end
def
download_access_check
if
deploy_key
deploy_key
.
has_access_to?
(
project
)
elsif
user
user_download_access_check
end
||
Guest
.
can?
(
:download_code
,
project
)
||
raise
(
UnauthorizedError
,
ERROR_MESSAGES
[
:download
])
passed
=
if
deploy_key
deploy_key
.
has_access_to?
(
project
)
elsif
user
user_can_download_code?
||
build_can_download_code?
end
||
Guest
.
can?
(
:download_code
,
project
)
unless
passed
message
=
if
deploy_key
ERROR_MESSAGES
[
:deploy_key
]
else
ERROR_MESSAGES
[
:download
]
end
raise
UnauthorizedError
,
message
end
end
def
push_access_check
(
changes
)
if
deploy_key
deploy_key_push_access_check
(
changes
)
deploy_key_push_access_check
elsif
user
user_push_access_check
(
changes
)
user_push_access_check
else
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:upload
]
end
end
def
user_download_access_check
unless
user_can_download_code?
||
build_can_download_code?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:download
]
end
return
if
changes
.
blank?
# Allow access.
check_repository_existence!
check_change_access!
(
changes
)
end
def
user_can_download_code?
...
...
@@ -77,25 +87,15 @@ module Gitlab
authentication_abilities
.
include?
(
:build_download_code
)
&&
user_access
.
can_do_action?
(
:build_download_code
)
end
def
user_push_access_check
(
changes
)
def
user_push_access_check
unless
authentication_abilities
.
include?
(
:push_code
)
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:upload
]
end
if
changes
.
blank?
return
# Allow access.
end
check_repository_existence!
check_change_access!
(
changes
)
end
def
deploy_key_push_access_check
(
changes
)
if
deploy_key
.
can_push_to?
(
project
)
check_repository_existence!
check_change_access!
(
changes
)
else
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:deploy_key
]
def
deploy_key_push_access_check
unless
deploy_key
.
can_push_to?
(
project
)
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:deploy_key_upload
]
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