def main(argv=sys.argv[1:]): try: con_str = pynimbusauthz.get_db_connection_string() db_obj = DB(con_str=con_str) (opts, args) = setup_options(argv) if len(args) > 0: u_pattern = args[0] else: u_pattern = "" if opts.bya: usa = User.find_alias(db_obj, u_pattern) users = [] for ua in usa: users.append(ua.get_canonical_user()) else: users = User.find_user(db_obj, u_pattern) if users == None: pynimbusauthz.print_msg(opts, 0, "No users in list") return 1 for u in users: list_user(opts, u) except AuthzException, ae: print ae return ae.get_rc()
def main(argv=sys.argv[1:]): try: con_str = pynimbusauthz.get_db_connection_string() db_obj = DB(con_str=con_str) (opts,args) = setup_options(argv) if len(args) > 0: u_pattern = args[0] else: u_pattern = "" if opts.bya: usa = User.find_alias(db_obj, u_pattern) users = [] for ua in usa: users.append(ua.get_canonical_user()) else: users = User.find_user(db_obj, u_pattern) if users == None: pynimbusauthz.print_msg(opts, 0, "No users in list") return 1 for u in users: list_user(opts, u) except AuthzException, ae: print ae return ae.get_rc()
def __init__(self, alias_name, con_str): self.db_obj = DB(con_str=con_str) alias = User.find_alias(self.db_obj, alias_name, pynimbusauthz.alias_type_s3) a_list = list(alias) if len(a_list) < 1: raise cbException('AccessDenied') # pick the first one, hmmm XXX self.alias = a_list[0] self.user = self.alias.get_canonical_user()
def grant(self, user_id, bucketName, objectName=None, perms="Rr"): try: uf = self.get_uf(bucketName, objectName) new_alias_iter = User.find_alias(self.db_obj, user_id, pynimbusauthz.alias_type_s3) new_alias_list = list(new_alias_iter) new_alias = new_alias_list[0] new_user = new_alias.get_canonical_user() uf.chmod(perms, user=new_user) finally: self.db_obj.commit()
def get_user_object_by_access_id(self, access_id): """Get a new connection every time this is called to make sure it is cleaned up""" db = DB(self._cumulus_db) user_alias = User.find_alias(db, access_id) if not user_alias: raise PhantomAWSException('InvalidClientTokenId') l = list(user_alias) db.close() if l < 1: raise PhantomAWSException('InvalidClientTokenId') return PhantomUserObject(access_id, l[0].get_data(), l[0].get_friendly_name())
def grant(self, user_id, bucketName, objectName=None, perms="Rr"): pycb.log(logging.INFO, "===== def grant of cbAuthzSecurity.py") try: uf = self.get_uf(bucketName, objectName) new_alias_iter = User.find_alias(self.db_obj, user_id, pynimbusauthz.alias_type_s3) new_alias_list = list(new_alias_iter) new_alias = new_alias_list[0] new_user = new_alias.get_canonical_user() uf.chmod(perms, user=new_user) finally: self.db_obj.commit()