Commit 01fd0f78 authored by Etienne Baqué's avatar Etienne Baqué

Added Deploy Keys on prot branches FF in GitAccess

parent 20837751
...@@ -37,7 +37,6 @@ class ProtectedBranch::PushAccessLevel < ApplicationRecord ...@@ -37,7 +37,6 @@ class ProtectedBranch::PushAccessLevel < ApplicationRecord
end end
def enabled_deploy_key_for_user?(deploy_key, user) def enabled_deploy_key_for_user?(deploy_key, user)
DeployKey.with_write_access_for_project(protected_branch.project, deploy_key: deploy_key).any? && deploy_key.user_id == user.id && DeployKey.with_write_access_for_project(protected_branch.project, deploy_key: deploy_key).any?
deploy_key.user_id == user.id
end end
end end
...@@ -319,8 +319,10 @@ module Gitlab ...@@ -319,8 +319,10 @@ module Gitlab
end end
def check_change_access! def check_change_access!
return if deploy_key? && !deploy_keys_on_protected_branches_enabled?
if changes == ANY if changes == ANY
can_push = deploy_key? || can_push = (deploy_key? && deploy_keys_on_protected_branches_enabled?) ||
user_can_push? || user_can_push? ||
project&.any_branch_allows_collaboration?(user_access.user) project&.any_branch_allows_collaboration?(user_access.user)
...@@ -447,7 +449,7 @@ module Gitlab ...@@ -447,7 +449,7 @@ module Gitlab
CiAccess.new CiAccess.new
elsif user && request_from_ci_build? elsif user && request_from_ci_build?
BuildAccess.new(user, container: container) BuildAccess.new(user, container: container)
elsif deploy_key? elsif deploy_key? && deploy_keys_on_protected_branches_enabled?
DeployKeyAccess.new(deploy_key, container: container) DeployKeyAccess.new(deploy_key, container: container)
else else
UserAccess.new(user, container: container) UserAccess.new(user, container: container)
...@@ -526,6 +528,10 @@ module Gitlab ...@@ -526,6 +528,10 @@ module Gitlab
def size_checker def size_checker
container.repository_size_checker container.repository_size_checker
end end
def deploy_keys_on_protected_branches_enabled?
Feature.enabled?(:deploy_keys_on_protected_branches, project)
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment