- fixed allowed roles
authorTony Mack <tmack@cs.princeton.edu>
Mon, 9 Oct 2006 15:41:03 +0000 (15:41 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Mon, 9 Oct 2006 15:41:03 +0000 (15:41 +0000)
PLC/Methods/AddPersonToSlice.py

index 2e9cb60..39df45a 100644 (file)
@@ -13,7 +13,7 @@ class AddPersonToSlice(Method):
     Returns 1 if successful, faults otherwise.
     """
 
-    roles = ['admin']
+    roles = ['admin', 'pi']
 
     accepts = [
         PasswordAuth(),
@@ -40,7 +40,13 @@ class AddPersonToSlice(Method):
 
         slice = slices.values()[0]
 
-        if slice['slice_id'] not in person['slice_ids']:
+        # If we are not admin, make sure the caller is a pi
+        # of the site associated with the slice
+       if 'admin' not in self.caller['roles']:
+               if slice['site_id'] not in self.caller['site_ids']:
+                       raise PLCPermissionDenied, "Not allowed to add users to this slice"
+
+       if slice['slice_id'] not in person['slice_ids']:
             slice.add_person(person)
 
         return 1