Commit bba4adc0 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'dz-dependency-proxy-permissions' into 'master'

Allow developers to configure dependency proxy

See merge request gitlab-org/gitlab-ee!13899
parents 04a55c8f f0ac71bb
...@@ -18,4 +18,8 @@ module DependencyProxyAccess ...@@ -18,4 +18,8 @@ module DependencyProxyAccess
def authorize_read_dependency_proxy! def authorize_read_dependency_proxy!
access_denied! unless can?(current_user, :read_dependency_proxy, group) access_denied! unless can?(current_user, :read_dependency_proxy, group)
end end
def authorize_admin_dependency_proxy!
access_denied! unless can?(current_user, :admin_dependency_proxy, group)
end
end end
...@@ -4,7 +4,7 @@ module Groups ...@@ -4,7 +4,7 @@ module Groups
class DependencyProxiesController < Groups::ApplicationController class DependencyProxiesController < Groups::ApplicationController
include DependencyProxyAccess include DependencyProxyAccess
before_action :authorize_admin_group!, only: :update before_action :authorize_admin_dependency_proxy!, only: :update
before_action :dependency_proxy before_action :dependency_proxy
def show def show
......
...@@ -45,6 +45,9 @@ module EE ...@@ -45,6 +45,9 @@ module EE
rule { can?(:read_group) & dependency_proxy_available } rule { can?(:read_group) & dependency_proxy_available }
.enable :read_dependency_proxy .enable :read_dependency_proxy
rule { developer & dependency_proxy_available }
.enable :admin_dependency_proxy
rule { can?(:read_group) & epics_available }.enable :read_epic rule { can?(:read_group) & epics_available }.enable :read_epic
rule { reporter & epics_available }.policy do rule { reporter & epics_available }.policy do
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= s_('Create a local proxy for storing frequently used upstream images. %{link_start}Learn more%{link_end} about dependency proxies.').html_safe % { link_start: link_start, link_end: '</a>'.html_safe } = s_('Create a local proxy for storing frequently used upstream images. %{link_start}Learn more%{link_end} about dependency proxies.').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
- if @group.public? - if @group.public?
- if can?(current_user, :admin_group, @group) - if can?(current_user, :admin_dependency_proxy, @group)
= form_for(@dependency_proxy, method: :put, url: group_dependency_proxy_path(@group)) do |f| = form_for(@dependency_proxy, method: :put, url: group_dependency_proxy_path(@group)) do |f|
.form-group .form-group
.js-dependency-proxy-toggle-area .js-dependency-proxy-toggle-area
......
---
title: Allow developers to configure dependency proxy
merge_request: 13899
author:
type: changed
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
require 'spec_helper' require 'spec_helper'
describe 'Group Dependency Proxy' do describe 'Group Dependency Proxy' do
let(:owner) { create(:user) }
let(:developer) { create(:user) } let(:developer) { create(:user) }
let(:reporter) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:path) { group_dependency_proxy_path(group) } let(:path) { group_dependency_proxy_path(group) }
before do before do
group.add_owner(owner)
group.add_developer(developer) group.add_developer(developer)
group.add_reporter(reporter)
enable_feature enable_feature
stub_licensed_features(dependency_proxy: true) stub_licensed_features(dependency_proxy: true)
...@@ -29,9 +29,9 @@ describe 'Group Dependency Proxy' do ...@@ -29,9 +29,9 @@ describe 'Group Dependency Proxy' do
end end
context 'feature is available', :js do context 'feature is available', :js do
context 'when logged in as group owner' do context 'when logged in as group developer' do
before do before do
sign_in(owner) sign_in(developer)
visit path visit path
end end
...@@ -57,9 +57,9 @@ describe 'Group Dependency Proxy' do ...@@ -57,9 +57,9 @@ describe 'Group Dependency Proxy' do
end end
end end
context 'when logged in as group developer' do context 'when logged in as group reporter' do
before do before do
sign_in(developer) sign_in(reporter)
visit path visit path
end end
...@@ -72,7 +72,7 @@ describe 'Group Dependency Proxy' do ...@@ -72,7 +72,7 @@ describe 'Group Dependency Proxy' do
context 'feature is not avaible' do context 'feature is not avaible' do
before do before do
sign_in(owner) sign_in(developer)
end end
context 'group is private' do context 'group is private' do
......
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