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
7b740b2f
Commit
7b740b2f
authored
Feb 08, 2022
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add enforce_auth_checks_on_uploads feature flag
parent
bbdfbd23
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
7 deletions
+67
-7
app/controllers/concerns/uploads_actions.rb
app/controllers/concerns/uploads_actions.rb
+8
-0
app/controllers/groups/uploads_controller.rb
app/controllers/groups/uploads_controller.rb
+2
-0
app/controllers/projects/uploads_controller.rb
app/controllers/projects/uploads_controller.rb
+3
-1
config/feature_flags/development/enforce_auth_checks_on_uploads.yml
...ture_flags/development/enforce_auth_checks_on_uploads.yml
+8
-0
spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb
...d_examples/controllers/uploads_actions_shared_examples.rb
+46
-6
No files found.
app/controllers/concerns/uploads_actions.rb
View file @
7b740b2f
...
...
@@ -142,6 +142,14 @@ module UploadsActions
uploader
&&
uploader
.
exists?
&&
uploader
.
embeddable?
end
def
bypass_auth_checks_on_uploads?
if
::
Feature
.
enabled?
(
:enforce_auth_checks_on_uploads
,
default_enabled: :yaml
)
false
else
action_name
==
'show'
&&
embeddable?
end
end
def
find_model
nil
end
...
...
app/controllers/groups/uploads_controller.rb
View file @
7b740b2f
...
...
@@ -4,6 +4,8 @@ class Groups::UploadsController < Groups::ApplicationController
include
UploadsActions
include
WorkhorseRequest
skip_before_action
:group
,
if:
->
{
bypass_auth_checks_on_uploads?
}
before_action
:authorize_upload_file!
,
only:
[
:create
,
:authorize
]
before_action
:verify_workhorse_api!
,
only:
[
:authorize
]
...
...
app/controllers/projects/uploads_controller.rb
View file @
7b740b2f
...
...
@@ -5,7 +5,9 @@ class Projects::UploadsController < Projects::ApplicationController
include
WorkhorseRequest
# These will kick you out if you don't have access.
#
skip_before_action
:project
,
:repository
,
if:
->
{
bypass_auth_checks_on_uploads?
}
before_action
:authorize_upload_file!
,
only:
[
:create
,
:authorize
]
before_action
:verify_workhorse_api!
,
only:
[
:authorize
]
...
...
config/feature_flags/development/enforce_auth_checks_on_uploads.yml
0 → 100644
View file @
7b740b2f
---
name
:
enforce_auth_checks_on_uploads
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/80117
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/352291
milestone
:
'
14.8'
type
:
development
group
:
group::code review
default_enabled
:
false
spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb
View file @
7b740b2f
...
...
@@ -205,10 +205,30 @@ RSpec.shared_examples 'handle uploads' do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:image?
).
and_return
(
true
)
end
it
"responds with status 302"
do
show_upload
context
"extract_mr_diff_commit_deletions feature flag"
do
context
"with flag enabled"
do
before
do
stub_feature_flags
(
enforce_auth_checks_on_uploads:
true
)
end
it
"responds with status 302"
do
show_upload
expect
(
response
).
to
have_gitlab_http_status
(
:redirect
)
end
end
expect
(
response
).
to
have_gitlab_http_status
(
:redirect
)
context
"with flag disabled"
do
before
do
stub_feature_flags
(
enforce_auth_checks_on_uploads:
false
)
end
it
"responds with status 200"
do
show_upload
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
...
...
@@ -276,10 +296,30 @@ RSpec.shared_examples 'handle uploads' do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:image?
).
and_return
(
true
)
end
it
"responds with status 404"
do
show_upload
context
"extract_mr_diff_commit_deletions feature flag"
do
context
"with flag enabled"
do
before
do
stub_feature_flags
(
enforce_auth_checks_on_uploads:
true
)
end
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
it
"responds with status 404"
do
show_upload
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
"with flag disabled"
do
before
do
stub_feature_flags
(
enforce_auth_checks_on_uploads:
false
)
end
it
"responds with status 200"
do
show_upload
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
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