OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
add permission checks for overview page requests and added related specs
Jonas Jabari0648e5d1b794
diff --git a/modules/overviews/app/controllers/overviews/overviews_controller.rb b/modules/overviews/app/controllers/overviews/overviews_controller.rbindex fc316d16c80..e4261ac4072 100644--- a/modules/overviews/app/controllers/overviews/overviews_controller.rb+++ b/modules/overviews/app/controllers/overviews/overviews_controller.rb@@ -2,6 +2,7 @@ module ::Overviewsclass OverviewsController < ::Grids::BaseInProjectControllerinclude OpTurbo::ComponentStream+ before_action :authorizebefore_action :jump_to_project_menu_itembefore_action :check_project_attributes_feature_enabled,only: %i[attributes_sidebar attribute_section_dialog update_attributes]@@ -9,7 +10,6 @@ module ::Overviewsmenu_item :overviewdef attributes_sidebar- # TODO: check permissionsrender(ProjectCustomFields::SidebarComponent.new(project: @project,@@ -21,7 +21,6 @@ module ::Overviewsenddef attribute_section_dialog- # TODO: check permissions@section = find_project_custom_field_sectionrender(diff --git a/modules/overviews/lib/overviews/engine.rb b/modules/overviews/lib/overviews/engine.rbindex 646ce96ae77..5213afab5ad 100644--- a/modules/overviews/lib/overviews/engine.rb+++ b/modules/overviews/lib/overviews/engine.rb@@ -48,23 +48,27 @@ module Overviews.controller_actions.push('overviews/overviews/show',- 'overviews/overviews/attributes_sidebar',+ 'overviews/overviews/attributes_sidebar'+ )++ OpenProject::AccessControl.permission(:edit_project)+ .controller_actions+ .push('overviews/overviews/attribute_section_dialog','overviews/overviews/update_attributes')OpenProject::AccessControl.permission(:view_work_packages)- .controller_actions- .push('overviews/overviews/show')+ .controller_actions+ .push('overviews/overviews/show')OpenProject::AccessControl.map do |ac_map|ac_map.project_module nil do |map|map.permission :manage_overview,{ 'overviews/overviews':[- 'show', 'attributes_sidebar', 'attribute_section_dialog', 'update_attributes'- ]- },+ 'show'+ ] },permissible_on: :project,require: :memberenddiff --git a/spec/permissions/manage_project_custom_values.rb b/spec/permissions/manage_project_custom_values.rbnew file mode 100644index 00000000000..c045bb47617--- /dev/null+++ b/spec/permissions/manage_project_custom_values.rb@@ -0,0 +1,45 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require 'spec_helper'+require File.expand_path('../support/permission_specs', __dir__)++RSpec.describe Overviews::OverviewsController, 'manage_project_custom_values permission',+ type: :controller do+ include PermissionSpecs++ # render sidebar on project overview page with view_project permission+ # TODO: prevents calling overviews/overviews#attributes_sidebar when not having the permission view_project (FAILED - 1)+ check_permission_required_for('overviews/overviews#attributes_sidebar', :view_project)++ # render dialog with inputs for editing project attributes with edit_project permission+ check_permission_required_for('overviews/overviews#attribute_section_dialog', :edit_project)++ # update project attributes with edit_project permission, deeper permission check via contract in place+ check_permission_required_for('overviews/overviews#update_attributes', :edit_project)+end