「公開」プロジェクトに特定の Non member をアクセス制限したい

505 views
Skip to first unread message

anemone

unread,
Mar 10, 2009, 11:50:22 AM3/10/09
to redmine-...@googlegroups.com
こんにちは。

Redmineは複数プロジェクトの連携ができる点が、非常に便利だと感じてお
ります。
プロジェクトの「公開」「非公開」について、有効に使えないか考えてお
ります。

原則「公開」にしたときに、プロパーの社員にとってはNon memberのプロ
ジェクトのチケットを参照できるのは非常に有用なのですが、社外の協力
会社さんのように、特定のユーザーらに対しては、Non memberの「公開」
プロジェクトにはアクセスできないように設定いたいと思っております。

こういう場合、皆さんはどのように対応されているでしょうか?

私の職場では原則プロジェクトを「非公開」にして、プロパー社員はすべ
てのプロジェクトに登録するという運用にしていますが、
・メンバー登録が煩雑
・メンバーが増えるとWatcher指定のリストにたくさん表示され、使いにく
くなる
などのデメリットがでています。

usersテーブルに確かtypeというカラムがあったので、これを使って改造で
きないかなぁとも、何となく思っています。

toy

unread,
Mar 13, 2009, 3:19:37 AM3/13/09
to Redmine Users (japanese)
それに該当する機能は version 0.9 での実装を目指しているみたいです.
http://www.redmine.org/issues/show/1018

0.9 のロードマップにはいろいろ野心的な目標が並んでますね.
個人的に嬉しいのは
http://www.redmine.org/versions/show/6
> Feature #594: Remove limit on subproject nesting
> Feature #1018: Group or company feature.
あたりでしょうか.

0.7 が去年の4月にリリースで 0.8 が12月でしたから,単純に計算すれば
8月ごろが 0.9 のリリースとか?
いまの勢いで 4月ごろに 0.9 電撃リリースとか?

anemone

unread,
Mar 14, 2009, 3:40:46 AM3/14/09
to redmine-...@googlegroups.com
toyさん。コメントありがとうございます。
表題の件は、0.9で実現されそうですね。

とりあえず、それまでのつなぎとして、考えてみました。

・/app/models/project.rb の visible_by と allowed_to_condition で公開プロジェクトを外す
・/appp/models/user.rb の allowed_to で 公開プロジェクトを外す

ようにしたら、公開/非公開に関わらずメンバー外のプロジェクトにアクセスできないことをざっと確認できました(抜け穴があるかもしれませんが)。

限定ユーザーを条件分岐で判断するため、DBのusersテーブルにlimitというカラムを追加し、限定ユーザーに1を入れるようにしました。

project.rbでは、adminの条件区分の仕方にに習い、次のようにすると動作しました。
def self.visible_by(user=nil)
<略>
elsif user && user.limit?
return "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}
AND (#{Project.table_name}.id IN (#{user.memberships.collect{|m|
m.project_id}.join(',')}))"

ところが、user.rbではうまく判別されず、internal error になってしまいました。

rubyの基本的なことが解っていないので、、、
まだまだ、思考中です


09/03/13 toy <mahershal...@gmail.com>:

anemone

unread,
Mar 21, 2009, 2:02:16 AM3/21/09
to Redmine Users (japanese)
自己レスですが、次の対応で、公開/非公開に関わらずメンバー外のプロジェクトにアクセスできない設定にすることができました。

・DBのusersテーブルにlimitというカラムを追加し、限定ユーザーに1にする。
・以下の3カ所を修正する。
--
Index: /app/models/user.rb
===================================================================
--- /app/models/user.rb (revision **)
+++ /app/models/user.rb (revision **)
@@ -238,7 +238,12 @@

role = role_for_project(project)
return false unless role
- role.allowed_to?(action) && (project.is_public? ||
role.member?)
+ # Limit-user cannot access the project non-member, whether or
not project is public.
+ if limit?
+ role.allowed_to?(action) && (role.member?)
+ else
+ role.allowed_to?(action) && (project.is_public? ||
role.member?)
+ end

elsif options[:global]
# authorize if user has at least one role that has this
permission
Index: /app/models/project.rb
===================================================================
--- /app/models/project.rb (revision **)
+++ /app/models/project.rb (revision **)
@@ -100,6 +100,9 @@
user ||= User.current
if user && user.admin?
return "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"
+ # Limit-user cannot access the project non-member, whether or not
project is public.
+ elsif user && user.limit?
+ return "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}
AND (#{Project.table_name}.id IN (#{user.memberships.collect{|m|
m.project_id}.join(',')}))"
elsif user && user.memberships.any?
return "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}
AND (#{Project.table_name}.is_public = #{connection.quoted_true} or #
{Project.table_name}.id IN (#{user.memberships.collect{|m|
m.project_id}.join(',')}))"
else
@@ -126,7 +129,10 @@
else
statements << "1=0"
if user.logged?
- statements << "#{Project.table_name}.is_public = #
{connection.quoted_true}" if Role.non_member.allowed_to?(permission)
+ # Limit-user cannot access the project non-member, whether or
not project is public.
+ unless user.limit?
+ statements << "#{Project.table_name}.is_public = #
{connection.quoted_true}" if Role.non_member.allowed_to?(permission)
+ end
allowed_project_ids = user.memberships.select {|m|
m.role.allowed_to?(permission)}.collect {|m| m.project_id}
statements << "#{Project.table_name}.id IN (#
{allowed_project_ids.join(',')})" if allowed_project_ids.any?
elsif Role.anonymous.allowed_to?(permission)
Reply all
Reply to author
Forward
0 new messages