no more __init__ created for now
[sfa.git] / geni / util / auth.py
index a5ef6c1..ed02451 100644 (file)
@@ -1,17 +1,20 @@
 #
 # GeniAPI authentication 
 #
+### $Id$
+### $URL$
 #
 
 import time
+
+from geni.trust.credential import Credential
+from geni.trust.trustedroot import TrustedRootList
+from geni.trust.rights import RightList
 from geni.util.faults import *
-from geni.util.excep import *
-from geni.util.credential import Credential
-from geni.util.trustedroot import TrustedRootList
 from geni.util.hierarchy import Hierarchy
-from geni.util.rights import RightList
 from geni.util.genitable import *
 from geni.util.config import *
+from geni.util.misc import *
 
 class Auth:
     """
@@ -140,6 +143,9 @@ class Auth:
             return
         if name.startswith(object_hrn + "."):
             return
+        if name.startswith(get_authority(name)):
+            return
+    
         raise PermissionError(name)
 
     def determine_user_rights(self, src_cred, record):
@@ -161,13 +167,14 @@ class Auth:
         else:
             # supplying src_cred==None is only valid when obtaining user
             # credentials.
-            assert(type == "user")
+            #assert(type == "user")
+            
             cred_object_hrn = None
 
         rl = RightList()
 
         if type=="slice":
-            researchers = record.get_geni_info().get("researcher", [])
+            researchers = record.get("researcher", [])
             if (cred_object_hrn in researchers):
                 rl.add("refresh")
                 rl.add("embed")
@@ -176,14 +183,13 @@ class Auth:
                 rl.add("info")
 
         elif type == "authority":
-            pis = record.get_geni_info().get("pi", [])
-            operators = record.get_geni_info().get("operator", [])
+            pis = record.get("pi", [])
+            operators = record.get("operator", [])
+            rl.add("authority,sa,ma")
             if (cred_object_hrn in pis):
                 rl.add("sa")
             if (cred_object_hrn in operators):
                 rl.add("ma")
-            if (cred_object_hrn in pis) or (cred_object_hrn in operators):
-                rl.add("authority")
 
         elif type == "user":
             rl.add("refresh")
@@ -204,15 +210,15 @@ class Auth:
         if cred_object_hrn in [self.config.GENI_REGISTRY_ROOT_AUTH]:
             return
         if type=="slice":
-            researchers = record.get_geni_info().get("researcher", [])
+            researchers = record.get("researcher", [])
             if not (cred_object_hrn in researchers):
                 raise PermissionError(cred_object_hrn + " is not in researcher list for " + record.get_name())
         elif type == "sa":
-            pis = record.get_geni_info().get("pi", [])
+            pis = record.get("pi", [])
             if not (cred_object_hrn in pis):
                 raise PermissionError(cred_object_hrn + " is not in pi list for " + record.get_name())
         elif type == "ma":
-            operators = record.get_geni_info().get("operator", [])
+            operators = record.get("operator", [])
             if not (cred_object_hrn in operators):
                 raise PermissionError(cred_object_hrn + " is not in operator list for " + record.get_name())