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
32a265c3
Commit
32a265c3
authored
Aug 18, 2021
by
Gosia Ksionek
Committed by
Imre Farkas
Aug 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor git http controller to stop referencing auth::result.actor directly
parent
fc0cfaa0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
12 deletions
+17
-12
app/controllers/concerns/lfs_request.rb
app/controllers/concerns/lfs_request.rb
+4
-11
app/controllers/repositories/lfs_api_controller.rb
app/controllers/repositories/lfs_api_controller.rb
+5
-1
app/controllers/repositories/lfs_locks_api_controller.rb
app/controllers/repositories/lfs_locks_api_controller.rb
+4
-0
app/controllers/repositories/lfs_storage_controller.rb
app/controllers/repositories/lfs_storage_controller.rb
+4
-0
No files found.
app/controllers/concerns/lfs_request.rb
View file @
32a265c3
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
# - a `#container` accessor
# - a `#container` accessor
# - a `#project` accessor
# - a `#project` accessor
# - a `#user` accessor
# - a `#user` accessor
# - a `#deploy_token` accessor
# - a `#authentication_result` accessor
# - a `#authentication_result` accessor
# - a `#can?(object, action, subject)` method
# - a `#can?(object, action, subject)` method
# - a `#ci?` method
# - a `#ci?` method
...
@@ -83,26 +84,18 @@ module LfsRequest
...
@@ -83,26 +84,18 @@ module LfsRequest
end
end
def
deploy_token_can_download_code?
def
deploy_token_can_download_code?
deploy_token
_
present?
&&
deploy_token
.
present?
&&
deploy_token
.
project
==
project
&&
deploy_token
.
project
==
project
&&
deploy_token
.
active?
&&
deploy_token
.
active?
&&
deploy_token
.
read_repository?
deploy_token
.
read_repository?
end
end
def
deploy_token_present?
user
&&
user
.
is_a?
(
DeployToken
)
end
def
deploy_token
user
end
def
lfs_upload_access?
def
lfs_upload_access?
strong_memoize
(
:lfs_upload_access
)
do
strong_memoize
(
:lfs_upload_access
)
do
next
false
unless
has_authentication_ability?
(
:push_code
)
next
false
unless
has_authentication_ability?
(
:push_code
)
next
false
if
limit_exceeded?
next
false
if
limit_exceeded?
lfs_deploy_token?
||
can?
(
user
,
:push_code
,
project
)
lfs_deploy_token?
||
can?
(
user
,
:push_code
,
project
)
||
can?
(
deploy_token
,
:push_code
,
project
)
end
end
end
end
...
@@ -111,7 +104,7 @@ module LfsRequest
...
@@ -111,7 +104,7 @@ module LfsRequest
end
end
def
user_can_download_code?
def
user_can_download_code?
has_authentication_ability?
(
:download_code
)
&&
can?
(
user
,
:download_code
,
project
)
&&
!
deploy_token_present?
has_authentication_ability?
(
:download_code
)
&&
can?
(
user
,
:download_code
,
project
)
end
end
def
build_can_download_code?
def
build_can_download_code?
...
...
app/controllers/repositories/lfs_api_controller.rb
View file @
32a265c3
...
@@ -10,6 +10,10 @@ module Repositories
...
@@ -10,6 +10,10 @@ module Repositories
skip_before_action
:lfs_check_access!
,
only:
[
:deprecated
]
skip_before_action
:lfs_check_access!
,
only:
[
:deprecated
]
before_action
:lfs_check_batch_operation!
,
only:
[
:batch
]
before_action
:lfs_check_batch_operation!
,
only:
[
:batch
]
# added here as a part of the refactor, will be removed
# https://gitlab.com/gitlab-org/gitlab/-/issues/328692
delegate
:deploy_token
,
:user
,
to: :authentication_result
,
allow_nil:
true
def
batch
def
batch
unless
objects
.
present?
unless
objects
.
present?
render_lfs_not_found
render_lfs_not_found
...
@@ -141,7 +145,7 @@ module Repositories
...
@@ -141,7 +145,7 @@ module Repositories
end
end
def
lfs_auth_header
def
lfs_auth_header
return
unless
user
.
is_a?
(
User
)
return
unless
user
Gitlab
::
LfsToken
.
new
(
user
).
basic_encoding
Gitlab
::
LfsToken
.
new
(
user
).
basic_encoding
end
end
...
...
app/controllers/repositories/lfs_locks_api_controller.rb
View file @
32a265c3
...
@@ -4,6 +4,10 @@ module Repositories
...
@@ -4,6 +4,10 @@ module Repositories
class
LfsLocksApiController
<
Repositories
::
GitHttpClientController
class
LfsLocksApiController
<
Repositories
::
GitHttpClientController
include
LfsRequest
include
LfsRequest
# added here as a part of the refactor, will be removed
# https://gitlab.com/gitlab-org/gitlab/-/issues/328692
delegate
:deploy_token
,
:user
,
to: :authentication_result
,
allow_nil:
true
def
create
def
create
@result
=
Lfs
::
LockFileService
.
new
(
project
,
user
,
lfs_params
).
execute
@result
=
Lfs
::
LockFileService
.
new
(
project
,
user
,
lfs_params
).
execute
...
...
app/controllers/repositories/lfs_storage_controller.rb
View file @
32a265c3
...
@@ -8,6 +8,10 @@ module Repositories
...
@@ -8,6 +8,10 @@ module Repositories
skip_before_action
:verify_workhorse_api!
,
only: :download
skip_before_action
:verify_workhorse_api!
,
only: :download
# added here as a part of the refactor, will be removed
# https://gitlab.com/gitlab-org/gitlab/-/issues/328692
delegate
:deploy_token
,
:user
,
to: :authentication_result
,
allow_nil:
true
def
download
def
download
lfs_object
=
LfsObject
.
find_by_oid
(
oid
)
lfs_object
=
LfsObject
.
find_by_oid
(
oid
)
unless
lfs_object
&&
lfs_object
.
file
.
exists?
unless
lfs_object
&&
lfs_object
.
file
.
exists?
...
...
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