Changeset 1f6a573 for fedd/federation


Ignore:
Timestamp:
Nov 30, 2010 4:45:00 PM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master
Children:
4692a16
Parents:
c002cb2
Message:

Support for priorities and export projects

Location:
fedd/federation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/access.py

    rc002cb2 r1f6a573  
    5353            self.value = value
    5454            self.priority = pri
     55        def __str__(self):
     56            return "%s: %s (%d)" % (self.attr, self.value, self.priority)
    5557
    5658    def __init__(self, config=None, auth=None):
     
    140142        """
    141143
    142         map_re = re.compile("(\S+)\s+->\s+(.*)");
     144        map_re = re.compile("(\S+)\s+->\s+(.*)")
     145        priority_re = re.compile("([^,]+),\s*(\d+)")
     146
    143147        if access_obj is None:
    144148            access_obj = lambda(x): "%s" % x
    145149
    146150        self.access = []
     151        priorities = { }
    147152
    148153        f = open(fn, 'r')
     
    160165                    continue
    161166
     167                # If a priority is found, collect them
     168                m = priority_re.match(line)
     169                if m:
     170                    try:
     171                        priorities[m.group(1)] = int(m.group(2))
     172                    except ValueError, e:
     173                        if self.log:
     174                            self.log.debug("Bad priority in %s line %d" % \
     175                                    (fn, lineno))
     176                    continue
     177
    162178                # Nothing matched to here: unknown line - raise exception
    163179                # (finally will close f)
     
    167183        finally:
    168184            if f: f.close()
     185
     186        # Set priorities
     187        for a in self.access:
     188            if a.attr in priorities:
     189                a.priority = priorities[a.attr]
    169190
    170191    def write_state(self):
  • fedd/federation/emulab_access.py

    rc002cb2 r1f6a573  
    488488                        s.get('visibility', '') == 'export':
    489489                    if not rv:
    490                         for a in s.get('feddAttr', []):
     490                        for a in s.get('fedAttr', []):
    491491                            if a.get('attribute', '') == 'project' \
    492492                                    and 'value' in a:
     
    504504            raise service_error(service_error.req, "No request!?")
    505505
    506         alog = open("./auth.log", 'w')
    507         print >>alog, self.auth
    508         print >> alog, "after"
     506        # if this includes a project export request, construct a filter such
     507        # that only the ABAC attributes mapped to that project are checked for
     508        # access.
     509        if 'service' in req:
     510            ep = get_export_project(req['service'])
     511            pf = lambda(a): a.value[0] == ep
     512        else:
     513            ep = None
     514            pf = None
     515
    509516        if self.auth.import_credentials(
    510517                data_list=req.get('abac_credential', [])):
    511518            self.auth.save()
    512         print >>alog, self.auth
    513         alog.close()
    514519
    515520        if self.auth_type == "legacy":
    516521            found, dyn, owners = self.legacy_lookup_access(req, fid)
    517522        elif self.auth_type == 'abac':
    518             found, dyn, owners = self.lookup_access(req, fid)
     523            found, dyn, owners = self.lookup_access(req, fid, filter=pf)
    519524        else:
    520525            raise service_error(service_error.internal,
     
    522527        ap = None
    523528
    524         # if this includes a project export request and the exported
    525         # project is not the access project, access denied.
    526         if 'service' in req:
    527             ep = get_export_project(req['service'])
    528             if ep and ep != found[0]:
    529                 raise service_error(service_error.access,
    530                         "Cannot export %s" % ep)
     529        # This only happens in legacy lookups, but if this user has access to
     530        # the testbed but not the project to be exported, raise the error.
     531        if ep and ep != found[0]:
     532            raise service_error(service_error.access,
     533                    "Cannot export %s" % ep)
    531534
    532535        if self.ssh_pubkey_file:
Note: See TracChangeset for help on using the changeset viewer.