Ejemplo n.º 1
0
    def add_user_data_for_person(self, person, force=False):
        """
        Creates a line of user data for the passed person.  If force is not
        true, the data will only be created if the person has not been
        provisioned. Returns True for valid users, False otherwise.
        """
        if person.uwregid in self.invalid_users:
            return False

        try:
            valid_net_id(person.uwnetid)
        except UserPolicyException as err:
            self.invalid_users[person.uwregid] = True
            self.logger.info("Skip user %s: %s" % (person.uwregid, err))
            return False

        if force is True:
            self.data.add(UserCSV(person))
        else:
            user = User.objects.add_user(person)
            if user.provisioned_date is None:
                if (self.data.add(UserCSV(person)) and user.queue_id is None):
                    user.queue_id = self.queue_id
                    user.save()
        return True
Ejemplo n.º 2
0
    def add_user_data_for_person(self, person, force=False):
        """
        Creates a line of user data for the passed person.  If force is not
        true, the data will only be created if the person has not been
        provisioned. Returns True for valid users, False otherwise.
        """
        if person.uwregid in self.invalid_users:
            return False

        try:
            valid_net_id(person.uwnetid)
        except UserPolicyException as err:
            self.invalid_users[person.uwregid] = True
            self.logger.info("Skip user {}: {}".format(person.uwregid, err))
            return False

        if force is True:
            self.data.add(UserCSV(person))
        else:
            user = User.objects.get_user(person)
            if user.provisioned_date is None:
                if (self.data.add(UserCSV(person)) and user.queue_id is None):
                    user.queue_id = self.queue_id
                    user.save()
        return True
Ejemplo n.º 3
0
 def _valid_member(login_id):
     try:
         valid_net_id(login_id)
         return 1
     except UserPolicyException:
         try:
             valid_gmail_id(login_id)
             return 1
         except UserPolicyException:
             pass
     return 0
Ejemplo n.º 4
0
def get_sis_import_members():
    valid_members = {}
    group_id = getattr(settings, 'SIS_IMPORT_USERS')
    for member in GWS().get_effective_members(group_id):
        try:
            if member.is_uwnetid():
                valid_net_id(member.name)
                valid_members[member.name] = member
        except UserPolicyException:
            pass

    return list(valid_members.values())
Ejemplo n.º 5
0
def get_sis_import_members():
    gws = GWS()

    valid_members = {}
    for group_id in getattr(settings, "SIS_IMPORT_GROUPS", []):
        for member in gws.get_effective_members(group_id):
            try:
                if member.is_uwnetid():
                    valid_net_id(member.name)
                    valid_members[member.name] = member
            except UserPolicyException as err:
                pass

    return valid_members.values()
Ejemplo n.º 6
0
    def _get_members(group_id):
        valid_members = {}
        invalid_members = {}
        member_group_ids = []

        try:
            valid_group_id(group_id)
            for member in gws.get_members(group_id):
                try:
                    if member.is_uwnetid():
                        valid_net_id(member.name)
                        valid_members[member.name] = member

                    elif member.is_eppn():
                        valid_gmail_id(member.name)
                        valid_members[member.name] = member

                    elif member.is_group():
                        (valid_sub, invalid_sub,
                            member_subgroups) = _get_members(member.name)
                        valid_members.update(valid_sub)
                        invalid_members.update(invalid_sub)
                        member_group_ids += [member.name] + member_subgroups

                except (UserPolicyException, GroupPolicyException) as err:
                    member.error = err
                    invalid_members[member.name] = member

        except DataFailureException as err:
            # Group not found or access denied is ok
            if err.status == 404:
                raise GroupNotFoundException(
                    "Group not found: {}".format(group_id))
            elif err.status == 401:
                raise GroupUnauthorizedException(
                    "Group not permitted for {}: {}".format(
                        gws.act_as, group_id))
            else:
                raise

        except GroupPolicyException as err:
            raise

        except RecursionError as err:
            logger.info("Error: {}, Group: {}, Member groups: {}".format(
                err, group_id, member_group_ids))
            raise

        return (valid_members, invalid_members, member_group_ids)
Ejemplo n.º 7
0
    def _update_group(self, group, member, is_deleted):
        if member.is_group():
            self._update_group_member_group(group, member.name, is_deleted)
        elif member.is_uwnetid() or member.is_eppn():
            try:
                if member.name not in self._valid_members:
                    if member.is_uwnetid():
                        valid_net_id(member.name)
                    elif member.is_eppn():
                        valid_gmail_id(member.name)
                    self._valid_members.append(member.name)

                self._update_group_member(group, member, is_deleted)
            except UserPolicyException:
                self._log.info('%s IGNORE invalid user %s' % (
                    log_prefix, member.name))
        else:
            self._log.info('%s IGNORE member type %s (%s)' % (
                log_prefix, member.member_type, member.name))
Ejemplo n.º 8
0
    def _get_members(group_id):
        valid_members = {}
        invalid_members = {}
        member_group_ids = []

        try:
            valid_group_id(group_id)
            for member in gws.get_members(group_id):
                try:
                    if member.is_uwnetid():
                        valid_net_id(member.name)
                        valid_members[member.name] = member

                    elif member.is_eppn():
                        valid_gmail_id(member.name)
                        valid_members[member.name] = member

                    elif member.is_group():
                        (valid_sub, invalid_sub, member_subgroups) = _get_members(member.name)
                        valid_members.update(valid_sub)
                        invalid_members.update(invalid_sub)
                        member_group_ids += [member.name] + member_subgroups

                except (UserPolicyException, GroupPolicyException) as err:
                    member.error = err
                    invalid_members[member.name] = member

        except DataFailureException as err:
            # Group not found or access denied is ok
            if err.status == 404:
                raise GroupNotFoundException("Group not found: %s" % group_id)
            elif err.status == 401:
                raise GroupUnauthorizedException("Group not permitted for %s: %s" % (gws.actas, group_id))
            else:
                raise

        except GroupPolicyException as err:
            raise

        return (valid_members, invalid_members, member_group_ids)
Ejemplo n.º 9
0
 def _valid_member(net_id):
     try:
         valid_net_id(net_id)
         return True
     except UserPolicyException:
         return False
Ejemplo n.º 10
0
 def netid_from_request(data):
     netid = data.get('net_id', '').strip().lower()
     valid_net_id(netid)
     return netid
Ejemplo n.º 11
0
def netid_from_request(data):
    netid = data.get('net_id', '').strip().lower()
    valid_net_id(netid)
    return netid