debian-mirror-gitlab/lib/gitlab/git_access_design.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.5 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module Gitlab
class GitAccessDesign < GitAccess
2020-10-24 23:57:45 +05:30
extend ::Gitlab::Utils::Override
2023-07-09 08:55:56 +05:30
# TODO Re-factor so that correct container is passed to the constructor
# and this method can be removed from here
# https://gitlab.com/gitlab-org/gitlab/-/issues/409454
def initialize(
actor, container, protocol, authentication_abilities:, repository_path: nil, redirected_path: nil,
auth_result_type: nil)
super(
actor,
select_container(container),
protocol,
authentication_abilities: authentication_abilities,
repository_path: repository_path,
redirected_path: redirected_path,
auth_result_type: auth_result_type
)
end
2020-05-24 23:13:21 +05:30
def check(_cmd, _changes)
check_protocol!
check_can_create_design!
success_result
end
2020-10-24 23:57:45 +05:30
override :push_ability
def push_ability
:create_design
end
2020-05-24 23:13:21 +05:30
private
2023-07-09 08:55:56 +05:30
def select_container(container)
container.is_a?(::DesignManagement::Repository) ? container.project : container
end
2020-05-24 23:13:21 +05:30
def check_protocol!
if protocol != 'web'
raise ::Gitlab::GitAccess::ForbiddenError, "Designs are only accessible using the web interface"
end
end
def check_can_create_design!
2020-10-24 23:57:45 +05:30
unless user_can_push?
2020-05-24 23:13:21 +05:30
raise ::Gitlab::GitAccess::ForbiddenError, "You are not allowed to manage designs of this project"
end
end
end
end
2021-06-08 01:23:25 +05:30
Gitlab::GitAccessDesign.prepend_mod_with('Gitlab::GitAccessDesign')