コード例 #1
0
ファイル: radius.py プロジェクト: datacenter/ignite
    def authenticate(self, username, password):
        server_list = AAAServer.objects.all().filter(protocol=RADIUS)

        for host in server_list:
            server = [host.server_ip, host.port, str(host.secret)]
            result = self._radius_auth(server, username, password)
            if result:
                user = self.get_django_user(username, password)
                # saving valid AAAUser in table, used this while logout
                aaa = AAAUser()
                aaa.username = username
                aaa.user = user
                aaa.save()
                return user
        return None
コード例 #2
0
ファイル: tacacs.py プロジェクト: datacenter/ignite
    def authenticate(self, username, password):
        server_list = AAAServer.objects.all().filter(protocol=TACACS)
	if server_list is None:
		return None

        is_64bits = sys.maxsize > 2**32
	linux_distribution = str(platform.linux_distribution()).lower()
	if linux_distribution.find("ubuntu") != -1: 
        	if is_64bits:
            		lib1 = CDLL(os.path.join(BASE_DIR, "administration/Ubuntu_64bit_libtac.so.2"))
            		lib = CDLL(os.path.join(BASE_DIR, "administration/Ubuntu_64bit_pam_tacplus.so"))
        	else:
            		lib1 = CDLL(os.path.join(BASE_DIR, "administration/Ubuntu_32bit_libtac.so.2"))
            		lib = CDLL(os.path.join(BASE_DIR, "administration/Ubuntu_32bit_pam_tacplus.so"))
	elif linux_distribution.find("centos") != -1:
		if is_64bits:
                        lib1 = CDLL(os.path.join(BASE_DIR, "administration/CentOS_64bit_libtac.so.2"))
                        lib = CDLL(os.path.join(BASE_DIR, "administration/CentOS_64bit_pam_tacplus.so"))
                else:
                        lib1 = CDLL(os.path.join(BASE_DIR, "administration/CentOS_32bit_libtac.so.2"))
                        lib = CDLL(os.path.join(BASE_DIR, "administration/CentOS_32bit_pam_tacplus.so"))
	else:
		logger.debug("Unsupported linux distribution")
		return None

        for host in server_list:
            result = lib.authenticate_tacacs(str(username), str(password), str(host.server_ip), host.port, str(host.secret))
            if not result:
                try:
                    user = User.objects.get(username=username)
                except User.DoesNotExist:
                    user = User(username=username)
                    user.set_password(password)
                    user.save()

                aaa = AAAUser()
                aaa.username = username
                aaa.user = user
                aaa.save()
                return user

        return None
コード例 #3
0
    def authenticate(self, username, password):
        server_list = AAAServer.objects.all().filter(protocol=TACACS)
        if server_list is None:
            return None

        is_64bits = sys.maxsize > 2**32
        linux_distribution = str(platform.linux_distribution()).lower()
        if linux_distribution.find("ubuntu") != -1:
            if is_64bits:
                lib1 = CDLL(
                    os.path.join(BASE_DIR,
                                 "administration/Ubuntu_64bit_libtac.so.2"))
                lib = CDLL(
                    os.path.join(BASE_DIR,
                                 "administration/Ubuntu_64bit_pam_tacplus.so"))
            else:
                lib1 = CDLL(
                    os.path.join(BASE_DIR,
                                 "administration/Ubuntu_32bit_libtac.so.2"))
                lib = CDLL(
                    os.path.join(BASE_DIR,
                                 "administration/Ubuntu_32bit_pam_tacplus.so"))
        elif linux_distribution.find("centos") != -1:
            if is_64bits:
                lib1 = CDLL(
                    os.path.join(BASE_DIR,
                                 "administration/CentOS_64bit_libtac.so.2"))
                lib = CDLL(
                    os.path.join(BASE_DIR,
                                 "administration/CentOS_64bit_pam_tacplus.so"))
            else:
                lib1 = CDLL(
                    os.path.join(BASE_DIR,
                                 "administration/CentOS_32bit_libtac.so.2"))
                lib = CDLL(
                    os.path.join(BASE_DIR,
                                 "administration/CentOS_32bit_pam_tacplus.so"))
        else:
            logger.debug("Unsupported linux distribution")
            return None

        for host in server_list:
            result = lib.authenticate_tacacs(str(username), str(password),
                                             str(host.server_ip), host.port,
                                             str(host.secret))
            if not result:
                try:
                    user = User.objects.get(username=username)
                except User.DoesNotExist:
                    user = User(username=username)
                    user.set_password(password)
                    user.save()

                aaa = AAAUser()
                aaa.username = username
                aaa.user = user
                aaa.save()
                return user

        return None