プロジェクト

全般

プロフィール

QA #923

未完了

Redmineカスタムクエリの編集者を制限したい(公開クエリ)

奈良 裕記 さんが約5年前に追加. 約3年前に更新.

ステータス:
新規
優先度:
通常
担当者:
-
カテゴリ:
-
対象バージョン:
-
開始日:
2019/03/05
期日:
進捗率:

0%

予定工数:

説明

■現象/要望

Redmineカスタムクエリの編集者を制限したい(公開クエリ)
PJ内Roleベースで制限は可能だが、複数プロジェクト間の共用を考慮すると、それだけでは誤編集によるトラブル発生のリスクが無視できない。

カスタムクエリ作成者+adminのみ可能にするなど、編集制限を可能にする必要があるのではないか?

従来と互換性も考慮必要

■解決策

(案)
・カスタムクエリに、strict modeを追加し、有効な場合は、カスタムクエリ作成者+adminのみ編集可能にする。
・全PJ用でもロール指定の場合はadmin以外も編集OKにする。(ロール割当はOpt-In)

■対応状況

■補足


関連するチケット 2 (2件未完了0件完了)

関連している Unofficial Redmine Cooking - QA #250: Redmineカスタムクエリの公開範囲を指定したい(複数PJ)回答済2016/12/01

操作
関連している Unofficial Redmine Cooking - QA #946: PJ間共用カスタムクエリをadmin以外が作成/編集したい。回答済2019/05/04

操作

奈良 裕記 さんが約5年前に更新

ソース関連個所

/app/controllers/queries_controller.rb


  def update_query_from_params
    @query.project = params[:query_is_for_all] ? nil : @project
    @query.build_from_params(params)
    @query.column_names = nil if params[:default_columns]
    @query.sort_criteria = params[:query] && params[:query][:sort_criteria]
    @query.name = params[:query] && params[:query][:name]
    if User.current.allowed_to?(:manage_public_queries, @query.project) || User.current.admin?
      @query.visibility = (params[:query] && params[:query][:visibility]) || Query::VISIBILITY_PRIVATE
      @query.role_ids = params[:query] && params[:query][:role_ids]
    else
      @query.visibility = Query::VISIBILITY_PRIVATE
    end
    @query
  end

/app/models/query.rb

 class Query < ActiveRecord::Base

 attr_protected :project_id, :user_id

   # Scope of visible queries, can be used from subclasses only.
  # Unlike other visible scopes, a class methods is used as it
  # let handle inheritance more nicely than scope DSL.
  def self.visible(*args)

  # Returns true if the query is visible to +user+ or the current user.
  def visible?(user=User.current)

  def editable_by?(user)
    return false unless user
    # Admin can edit them all and regular users can edit their private queries
    return true if user.admin? || (is_private? && self.user_id == user.id)
    # Members can not edit public queries that are for all project (only admin is allowed to)
    is_public? && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
  end

奈良 裕記 さんが約5年前に更新

奈良 裕記 さんが約5年前に更新

  • 関連している QA #250: Redmineカスタムクエリの公開範囲を指定したい(複数PJ) を追加

奈良 裕記 さんが約5年前に更新

奈良 裕記 さんが約5年前に更新

関連個所

models/query.rb:


  def editable_by?(user)
    return false unless user
    # Admin can edit them all and regular users can edit their private queries
    return true if user.admin? || (is_private? && self.user_id == user.id)
    # Members can not edit public queries that are for all project (only admin is allowed to)
    is_public? && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
  end

  # Returns true if the query is visible to +user+ or the current user.
  def visible?(user=User.current)
    return true if user.admin?
    return false unless project.nil? || user.allowed_to?(self.class.view_permission, project)
    case visibility
    when VISIBILITY_PUBLIC
      true
    when VISIBILITY_ROLES
      if project
        (user.roles_for_project(project) & roles).any?
      else
        user.memberships.joins(:member_roles).where(:member_roles => {:role_id => roles.map(&:id)}).any?
      end
    else
      user == self.user
    end
  end

奈良 裕記 さんが約5年前に更新

これで対応可能か?


  def editable_by?(user)
    return false unless user
    # Admin can edit them all and regular users can edit their private queries
    return true if user.admin? || (is_private? && self.user_id == user.id)

    # added
    return true if is_public? && user.allowed_to?(:manage_public_queries, project)

    # role check 必要では?

    # Members can not edit public queries that are for all project (only admin is allowed to)
    is_public? && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
  end

奈良 裕記 さんが約5年前に更新

http://www.redmine.org/issues/31010 起票した。

本対応に関連して、下記障害(と思われる)を発見した。
手元環境が改造版なので、一時的に保管

標準で操作不可のシナリオに対してバグレポ上げたら話にならん。

ーーーーーーーーーーーーーーー
subject
他人が作成した共用カスタムクエリの表示範囲を「自分のみ」に変更すると、「自分」ではなく「作成者」のみ利用可能となる。

障害内容

他人が作成したカスタムクエリのVisibilityを [to these roles only] から[to me only ] に変更したとき、
操作している自分ではなく、カスタムクエリ作成者のみ利用可能になる。
表示内容が誤っており、誤操作を招くと思われる。

「to me only」から「to author only」に変更した方が良いのではないか。

ーーーーーー
再現シナリオ

admin

user-A,user-Bを作成する。
adminの権限は割り当てない。
issueの参照及び、プロジェクトのカスタムクエリ作成・管理の権限を割り当てる。
(クエリの保存、公開クエリの管理)

user-A
PJ内共用のカスタムクエリを作成する。 query-userA-shared

user-B
user-Aの作成した共用カスタムクエリを編集する。
「Visibleを、 [to these roles only] から[to me only ] に変更してsaveする。

この操作は、自分(user-B)のみが使用できるようにすることを意図して行っている。

結果: user-Aのみが利用可能となる。

query tableのuserid は、user-Aを指している。

---
If you change the display range of a shared custom query created by another person to "Only me", only "creator" can be used instead of "me".

shared custom query

When changing the Visibility of a custom query created by someone from "to these roles only" to "to me only"
It becomes available only to the custom query creator, not the one who is manipulating it.
It seems that display content is wrong and it leads to erroneous operation.

It may be better to change from "to me only" to "to author only".


Steps to reproduce:

admin:

1.Create user-A and user-B.

Do not assign admin privileges.

2.Assign the following authority of the project to user-A, user-B.

Reference to issue
Custom query creation
Custom query management
(Save Query, Manage Public Query)

user-A:

3.Create custom queries shared within PJ.

visibility:[to these roles only]

user-B:

4.Edit the shared custom query created by user-A.

Change "Visible" from [to these roles only] to [to me only] and save.

This operation is intended to make it available only to me (user-B).

Result: Only user-A becomes available.

The userid of queries table points to user-A.

奈良 裕記 さんが4年以上前に更新

  • 関連している QA #946: PJ間共用カスタムクエリをadmin以外が作成/編集したい。 を追加

奈良 裕記 さんが4年以上前に更新

奈良 裕記 さんが4年以上前に更新

奈良 裕記 さんが約3年前に更新

他の形式にエクスポート: Atom PDF