[Rt-commit] rt branch, 4.4/group-admin-seegroup-check, created. rt-4.4.3-39-g2ce6798d6

Jim Brandt jbrandt at bestpractical.com
Thu Aug 30 16:26:06 EDT 2018


The branch, 4.4/group-admin-seegroup-check has been created
        at  2ce6798d62a6e755495c9a167f79e421f398649a (commit)

- Log -----------------------------------------------------------------
commit 47891e0bfc6a399499510e482b882f832c320078
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Aug 30 16:12:29 2018 -0400

    Check SeeGroup on individual group admin pages
    
    The ShowConfigTab right is usually granted to RT admins.
    However, in some configurations, users might be given ShowConfigTab to
    grant access to manage group membership, even if the user will only
    manage a sub-set of available groups. The group admin index.html
    page already limits listed groups. Also enforce this individual
    group restriction with SeeGroup on individual pages.

diff --git a/share/html/Admin/Groups/autohandler b/share/html/Admin/Groups/autohandler
new file mode 100644
index 000000000..26dd4731e
--- /dev/null
+++ b/share/html/Admin/Groups/autohandler
@@ -0,0 +1,61 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
+%#                                          <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work 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 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%init>
+
+if ( exists $ARGS{'id'} and length $ARGS{'id'} and $ARGS{'id'} ne 'new' ){
+    my $group = RT::Group->new($session{'CurrentUser'});
+    my ($ret, $msg) = $group->Load($ARGS{'id'});
+    RT::Logger->error("Unable to load group by id " . $ARGS{'id'} . " $msg") unless $ret;
+
+    # Must have SeeGroup for pages that operate on an individual group
+    unless( $group->CurrentUserHasRight('SeeGroup') ){
+        $m->clear_and_abort(403);
+    }
+}
+return $m->call_next(%ARGS)
+</%init>

commit 2ce6798d62a6e755495c9a167f79e421f398649a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Aug 30 16:17:22 2018 -0400

    Add tests for SeeGroup on group admin pages

diff --git a/t/web/group_create.t b/t/web/group_create.t
index f62e56595..4a7bc9cd9 100644
--- a/t/web/group_create.t
+++ b/t/web/group_create.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 13;
+use RT::Test tests => undef;
 
 my ( $baseurl, $m ) = RT::Test->started_ok;
 ok $m->login, 'logged in as root';
@@ -71,3 +71,40 @@ diag "Create a group";
     ok $group_id, "found id of the group in the form, it's #$group_id";
 }
 
+ok($m->logout(), 'Logged out');
+
+{
+    my $tester = RT::Test->load_or_create_user( Name => 'staff1', Password => 'password' );
+    ok $m->login( $tester->Name, 'password' ), 'Logged in';
+
+    $m->get('/Admin/Groups/');
+    is( $m->status, 403, "No access without ShowConfigTab" );
+
+    RT::Test->set_rights(
+        { Principal => $tester->PrincipalObj,
+          Right => [qw(ShowConfigTab)],
+        },
+    );
+
+    $m->get('/Admin/Groups/');
+    is( $m->status, 200, "Can see group admin page" );
+
+    load_group_admin_pages($m, $group_id, '403');
+
+    ok($tester->PrincipalObj->GrantRight(Right => 'SeeGroup', Object => $RT::System), 'Grant SeeGroup');
+
+    load_group_admin_pages($m, $group_id, '200');
+}
+
+sub load_group_admin_pages{
+    my $m = shift;
+    my $group_id = shift;
+    my $status = shift;
+
+    foreach my $page (qw(GroupRights Members Modify History Memberships UserRights)){
+        $m->get("/Admin/Groups/$page.html?id=$group_id");
+        is( $m->status, $status, "Got $status for $page page");
+    }
+}
+
+done_testing();

-----------------------------------------------------------------------


More information about the rt-commit mailing list