Title: [opsview] [10389] merge in 10388 - permission restricted keywords in events filtering
Revision
10389
Author
aburzynski
Date
2012-10-10 17:01:29 +0100 (Wed, 10 Oct 2012)

Log Message

merge in 10388 - permission restricted keywords in events filtering

Modified Paths


Property Changed


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/DEV-capside/release-3.9.0:6365-6370
/branches/DEV-extra-notification-data:6734-6746
/branches/DEV-odw-calculations:9016-9160
/branches/DEV-restapi-monitoringservers:9778
/branches/DEV-snmp-multi:7324-7376
/branches/US187:9403-9479
/branches/US198b:8875-8994
/branches/US310:9851-9873
/branches/enterprise/BRAN-3.14:6874,6882,6956
/branches/enterprise/DEV-professional:6494-8475,8477-8478,8486,8490,8492,8494,8499-8500,8515,8518-8519,8524,8527-8529,8531-8532,8536,8538,8540-8544,8547-8552,8554,8557,8600-8601,8637,8749,8772,8897,8917,8944-8945,8947,8950-8952,8967,8969,8979,8982,8987,8998,9006,9008,9011,9013,9026,9033-9036,9038,9040,9042,9044,9048,9050-9053,9062,9064-9065,9069,9078,9081,9088,9096,9099-9101,9103,9105,9115,9118,9347,9353-9354,9411,9432,9445,9486,9538-9550,9569-9571,9620,9635,9637-9638,9645-9647,9693,9699,9721,9814,9825,9857,9879,9881,9939,10002,10029,10038-10041,10070,10086,10093,10345,10347
/branches/nagvis-iframe:9764-9786
/branches/us168:8759,8762-8763,8766-8768,8770,8774-8777,8794,8798-8799,8801-8803,8821-8822,8834,8837-8838,8932,8937,8947,8969,8977,8981,9004,9007,9009-9010,9012,9024,9049
/commercial/branches/US306-slaves:9804-9823
/commercial/branches/US307-network-map:9685-9837
   + /branches/DEV-capside/release-3.9.0:6365-6370
/branches/DEV-extra-notification-data:6734-6746
/branches/DEV-odw-calculations:9016-9160
/branches/DEV-restapi-monitoringservers:9778
/branches/DEV-snmp-multi:7324-7376
/branches/US187:9403-9479
/branches/US198b:8875-8994
/branches/US310:9851-9873
/branches/enterprise/BRAN-3.14:6874,6882,6956
/branches/enterprise/DEV-professional:6494-8475,8477-8478,8486,8490,8492,8494,8499-8500,8515,8518-8519,8524,8527-8529,8531-8532,8536,8538,8540-8544,8547-8552,8554,8557,8600-8601,8637,8749,8772,8897,8917,8944-8945,8947,8950-8952,8967,8969,8979,8982,8987,8998,9006,9008,9011,9013,9026,9033-9036,9038,9040,9042,9044,9048,9050-9053,9062,9064-9065,9069,9078,9081,9088,9096,9099-9101,9103,9105,9115,9118,9347,9353-9354,9411,9432,9445,9486,9538-9550,9569-9571,9620,9635,9637-9638,9645-9647,9693,9699,9721,9814,9825,9857,9879,9881,9939,10002,10029,10038-10041,10070,10086,10093,10345,10347,10388
/branches/nagvis-iframe:9764-9786
/branches/us168:8759,8762-8763,8766-8768,8770,8774-8777,8794,8798-8799,8801-8803,8821-8822,8834,8837-8838,8932,8937,8947,8969,8977,8981,9004,9007,9009-9010,9012,9024,9049
/commercial/branches/US306-slaves:9804-9823
/commercial/branches/US307-network-map:9685-9837

Modified: trunk/opsview-web/lib/Opsview/Web/Controller/Event.pm
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/Controller/Event.pm	2012-10-10 15:58:42 UTC (rev 10388)
+++ trunk/opsview-web/lib/Opsview/Web/Controller/Event.pm	2012-10-10 16:01:29 UTC (rev 10389)
@@ -260,15 +260,15 @@
         my @servicenames = map { $_->servicename } ( $rs->search );
 
         # get list of all live keywords
-        my @keyword_rs = $c->model("OpsviewSchema::Keywords")->search(
+        my $keyword_rs =
+          $c->forward( "/rest/config/keyword/restricted_keyword_rs" );
+        my @keywords = map { $_->name } $keyword_rs->search(
             undef,
             {
                 order_by => \'name',
                 columns  => ['name']
             }
-        );
-        my @keywords = ();
-        foreach (@keyword_rs) { push( @keywords, $_->name ); }
+        )->all;
 
         # get list of all host groups
         # This uses the configuration information, just because it is quicker

Modified: trunk/opsview-web/lib/Opsview/Web/Controller/REST/Config/Keyword.pm
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/Controller/REST/Config/Keyword.pm	2012-10-10 15:58:42 UTC (rev 10388)
+++ trunk/opsview-web/lib/Opsview/Web/Controller/REST/Config/Keyword.pm	2012-10-10 16:01:29 UTC (rev 10389)
@@ -32,5 +32,35 @@
   ACLDetachTo(/access_denied) {
 }
 
+sub restricted_keyword_rs : Private {
+    my ( $self, $c ) = @_;
+    my $keyword_rs =
+      $c->model("OpsviewSchema::Keywords")->search( { enabled => 1 } );
+
+    # Apply keyword authentication
+    if ( !$c->user_exists ) {
+        $keyword_rs = $keyword_rs->search( { public => 1 } );
+    }
+    else {
+        unless ( $c->user->can_view_all || $c->user->role->all_keywords ) {
+            $keyword_rs->set_roleid( $c->user->role->id );
+            $keyword_rs = $keyword_rs->search(
+                {
+                    "-or" => [
+                        {
+                            "keywordroles_or_public.roleid" =>
+                              $c->user->role->id
+                        },
+                        { "public" => 1 }
+                    ]
+                },
+                { join => "keywordroles_or_public" }
+            );
+        }
+    }
+
+    $keyword_rs;
+}
+
 __PACKAGE__->meta->make_immutable;
 1;

Modified: trunk/opsview-web/lib/Opsview/Web/Controller/Viewport.pm
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/Controller/Viewport.pm	2012-10-10 15:58:42 UTC (rev 10388)
+++ trunk/opsview-web/lib/Opsview/Web/Controller/Viewport.pm	2012-10-10 16:01:29 UTC (rev 10389)
@@ -32,41 +32,12 @@
     return $c->forward( "/check_public_or_user_access", ["VIEWPORTACCESS"] );
 }
 
-sub setup_keyword_rs {
-    my ( $self, $c ) = @_;
-    my $keyword_rs =
-      $c->model("OpsviewSchema::Keywords")->search( { enabled => 1 } );
-
-    # Apply keyword authentication
-    if ( !$c->user_exists ) {
-        $keyword_rs = $keyword_rs->search( { public => 1 } );
-    }
-    else {
-        unless ( $c->user->can_view_all || $c->user->role->all_keywords ) {
-            $keyword_rs->set_roleid( $c->user->role->id );
-            $keyword_rs = $keyword_rs->search(
-                {
-                    "-or" => [
-                        {
-                            "keywordroles_or_public.roleid" =>
-                              $c->user->role->id
-                        },
-                        { "public" => 1 }
-                    ]
-                },
-                { join => "keywordroles_or_public" }
-            );
-        }
-    }
-
-    $keyword_rs;
-}
-
 sub check : Private {
     my ( $self, $c ) = @_;
-    my $name       = $c->req->params->{keyword};
-    my $keyword_rs = $self->setup_keyword_rs($c);
-    my $keyword    = $keyword_rs->search( { name => $name } )->first;
+    my $name = $c->req->params->{keyword};
+    my $keyword_rs =
+      $c->forward( "/rest/config/keyword/restricted_keyword_rs" );
+    my $keyword = $keyword_rs->search( { name => $name } )->first;
     unless ($keyword) {
         $c->stash( error => $c->loc( "messages.keyword.notFound [_1]", $name )
         );
@@ -133,7 +104,8 @@
     push( @{ $c->stash->{extra_javascript} },
         "jquery.noConflict", "prototypextensions", "viewports" );
 
-    my $keyword_rs             = $self->setup_keyword_rs($c);
+    my $keyword_rs =
+      $c->forward( "/rest/config/keyword/restricted_keyword_rs" );
     my @active_viewports       = $keyword_rs->search;
     my @keywords               = ();
     my %keywords_with_services = map { ( $_->keyword => 1 ) } (

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to