Ignore:
Timestamp:
Nov 30, 2010 10:48:51 AM (13 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master
Children:
822d31b
Parents:
027b87b
Message:

Move some functions from access to legacy_access. Rename functions so abac is the default

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/emulab_access.py

    r027b87b r78f2668  
    1616
    1717from access import access_base
     18from legacy_access import legacy_access
    1819
    1920from util import *
     
    4142fl.addHandler(nullHandler())
    4243
    43 class access(access_base):
     44class access(access_base, legacy_access):
    4445    """
    4546    The implementation of access control based on mapping users to projects.
     
    119120        if self.auth_type == 'legacy':
    120121            if accessdb:
    121                 self.read_access(accessdb, self.make_access_project)
     122                self.legacy_read_access(accessdb, self.legacy_access_tuple)
    122123        elif self.auth_type == 'abac':
    123124            self.auth = abac_authorizer(load=self.auth_dir)
    124125            if accessdb:
    125                 self.read_abac_access(accessdb, self.make_abac_access_project)
     126                self.read_access(accessdb, self.access_tuple)
    126127        else:
    127128            raise service_error(service_error.internal,
     
    205206
    206207    @staticmethod
    207     def make_access_project(str):
     208    def legacy_access_tuple(str):
    208209        """
    209210        Convert a string of the form (id[:resources:resouces], id, id) into a
     
    235236
    236237    @staticmethod
    237     def make_abac_access_project(str):
     238    def access_tuple(str):
    238239        """
    239240        Convert a string of the form (id, id) into an access_project.  This is
    240         called by read_abac_access to convert to local attributes.  It returns
     241        called by read_access to convert to local attributes.  It returns
    241242        a tuple of the form (project, user, user) where the two users are
    242243        always the same.
     
    255256    # RequestAccess support routines
    256257
    257     def lookup_access(self, req, fid):
     258    def legacy_lookup_access(self, req, fid):
    258259        """
    259260        Look up the local access control information mapped to this fedid and
     
    270271        ru = None
    271272        # This maps a valid user to the Emulab projects and users to use
    272         found, match = self.lookup_access_base(req, fid)
     273        found, match = self.legacy_lookup_access_base(req, fid)
    273274        tb, project, user = match
    274275       
     
    326327                [ fid ]
    327328
    328     def lookup_abac_access(self, req, fid):
     329    def lookup_access(self, req, fid):
     330        """
     331        Check all the attributes that this controller knows how to map and see
     332        if the requester is allowed to use any of them.  If so return one.
     333        """
    329334        # Import request credentials into this (clone later??)
    330         if self.auth.import_credentials(data_list=req.get('abac_credential', [])):
     335        if self.auth.import_credentials(
     336                data_list=req.get('abac_credential', [])):
    331337            self.auth.save()
    332338
    333339        # Check every attribute that we know how to map and take the first
    334340        # success.
    335         print "%s" %self.auth
    336341        for attr in (self.access.keys()):
    337342            if self.auth.check_attribute(fid, attr):
     
    491496
    492497        if self.auth_type == "legacy":
     498            found, dyn, owners = self.legacy_lookup_access(req, fid)
     499        elif self.auth_type == 'abac':
    493500            found, dyn, owners = self.lookup_access(req, fid)
    494         elif self.auth_type == 'abac':
    495             found, dyn, owners = self.lookup_abac_access(req, fid)
    496501        else:
    497502            raise service_error(service_error.internal,
Note: See TracChangeset for help on using the changeset viewer.