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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8fa70beb
Commit
8fa70beb
authored
Oct 17, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor most EE-specific code out of Gitlab::Git::GitAccess
parent
370fb882
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
22 deletions
+67
-22
ee/lib/ee/gitlab/git_access.rb
ee/lib/ee/gitlab/git_access.rb
+63
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+4
-22
No files found.
ee/lib/ee/gitlab/git_access.rb
0 → 100644
View file @
8fa70beb
module
EE
module
Gitlab
module
GitAccess
def
check
(
cmd
,
changes
)
raise
NotImplementedError
.
new
unless
defined?
(
super
)
check_geo_license!
super
end
def
can_read_project?
raise
NotImplementedError
.
new
unless
defined?
(
super
)
return
geo_node_key
.
active?
if
geo_node_key?
super
end
protected
def
user
raise
NotImplementedError
.
new
unless
defined?
(
super
)
return
nil
if
actor
.
is_a?
(
::
GeoNodeKey
)
super
end
private
def
check_download_access!
raise
NotImplementedError
.
new
unless
defined?
(
super
)
return
if
geo_node_key?
super
end
def
check_active_user!
raise
NotImplementedError
.
new
unless
defined?
(
super
)
return
if
geo_node_key?
super
end
def
check_geo_license!
if
::
Gitlab
::
Geo
.
secondary?
&&
!::
Gitlab
::
Geo
.
license_allows?
raise
::
Gitlab
::
GitAccess
::
UnauthorizedError
,
'Your current license does not have GitLab Geo add-on enabled.'
end
end
def
geo_node_key
actor
if
geo_node_key?
end
def
geo_node_key?
actor
.
is_a?
(
::
GeoNodeKey
)
end
end
end
end
lib/gitlab/git_access.rb
View file @
8fa70beb
...
...
@@ -2,8 +2,10 @@
# class return an instance of `GitlabAccessStatus`
module
Gitlab
class
GitAccess
prepend
::
EE
::
Gitlab
::
GitAccess
include
ActionView
::
Helpers
::
SanitizeHelper
include
PathLocksHelper
UnauthorizedError
=
Class
.
new
(
StandardError
)
NotFoundError
=
Class
.
new
(
StandardError
)
ProjectMovedError
=
Class
.
new
(
NotFoundError
)
...
...
@@ -47,8 +49,6 @@ module Gitlab
check_command_existence!
(
cmd
)
check_repository_existence!
check_geo_license!
case
cmd
when
*
DOWNLOAD_COMMANDS
check_download_access!
...
...
@@ -92,7 +92,7 @@ module Gitlab
end
def
check_active_user!
return
if
deploy_key?
||
geo_node_key?
return
if
deploy_key?
if
user
&&
!
user_access
.
allowed?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:account_blocked
]
...
...
@@ -146,12 +146,6 @@ module Gitlab
end
end
def
check_geo_license!
if
Gitlab
::
Geo
.
secondary?
&&
!
Gitlab
::
Geo
.
license_allows?
raise
UnauthorizedError
,
'Your current license does not have GitLab Geo add-on enabled.'
end
end
def
check_repository_existence!
unless
project
.
repository
.
exists?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:no_repo
]
...
...
@@ -159,7 +153,7 @@ module Gitlab
end
def
check_download_access!
return
if
deploy_key?
||
geo_node_key?
return
if
deploy_key?
passed
=
user_can_download_code?
||
build_can_download_code?
||
...
...
@@ -253,14 +247,6 @@ module Gitlab
actor
.
is_a?
(
DeployKey
)
end
def
geo_node_key
actor
if
geo_node_key?
end
def
geo_node_key?
actor
.
is_a?
(
GeoNodeKey
)
end
def
ci?
actor
==
:ci
end
...
...
@@ -268,8 +254,6 @@ module Gitlab
def
can_read_project?
if
deploy_key?
deploy_key
.
has_access_to?
(
project
)
elsif
geo_node_key?
geo_node_key
.
active?
elsif
user
user
.
can?
(
:read_project
,
project
)
elsif
ci?
...
...
@@ -306,8 +290,6 @@ module Gitlab
case
actor
when
User
actor
when
GeoNodeKey
nil
when
Key
actor
.
user
unless
actor
.
is_a?
(
DeployKey
)
when
:ci
...
...
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