Squid 3.3.10 + Captive Portal



  • Amigos,

    Estou utilizando o Squid 3.3.10 no meu Pfsense 2.1.3 em modo transparente com autenticação integrada via Captive Portal no Squid.

    Meu problema e que o Squid só está conseguindo se autenticar a 1 Captive Portal.

    Por exemplo, tenho configurado

    CAPTIVE1 com o user1 e user2 autenticados, estes consegue passar para pelo proxy autenticado corretamente
    CAPTIVE2 com o user3 autenticado, não consegue passar pelo proxy.

    Se eu remover o CAPTIVE1 o CAPTIVE2 funciona corretamente, parece que o Squid só consegue se autenticar a 1 Captive Portal.

    Por enquanto deixei a autenticação desabilitada, porém eu preciso dela ativa por conta do relatório do SARG.

    Obrigado

    P.S = Squid 3.3.10 transparente HTTP/HTTPS simplesmente fantástico.



  • cp.php

    #!/usr/local/bin/php -q
    /* $Id$ */
    /*
    	check_ip.php
    	Copyright (C) 2013-2014 Marcello Coutinho		
    	All rights reserved.
    
    	Redistribution and use in source and binary forms, with or without
    	modification, are permitted provided that the following conditions are met:
    
    	1\. Redistributions of source code must retain the above copyright notice,
    	   this list of conditions and the following disclaimer.
    
    	2\. Redistributions in binary form must reproduce the above copyright
    	   notice, this list of conditions and the following disclaimer in the
    	   documentation and/or other materials provided with the distribution.
    
    	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
    	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
    	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    	POSSIBILITY OF SUCH DAMAGE.
    */
    error_reporting(0);
    // stdin loop
    /*if (! defined(STDIN)) {
            define("STDIN", fopen("php://stdin", "r"));
    }
    if (! defined(STDOUT)){
            define("STDOUT", fopen('php://stdout', 'w'));
            }
    while( !feof(STDIN)){
            $line = trim(fgets(STDIN));
            // %SRC
    */        
    $pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
    unset($cp_db);
    if ($pf_version > 2.0){
    	$dir="/var/db";
    	$files=scandir($dir);
    	foreach ($files as $file){
    		if (preg_match("/captive.*db/",$file)){
                            print "$dir/$file\n";
    			$dbhandle = sqlite_open("$dir/$file", 0666, $error);
    			if ($dbhandle){
    				$query = "select * from captiveportal";
    				$result = sqlite_array_query($dbhandle, $query, SQLITE_ASSOC);
                                    var_dump($result);
    				if ($result){
    					foreach ($result as $rownum => $row){
    						$cp_db[$rownum]=implode(",",$row);
    						}
    					sqlite_close($dbhandle);
    					}
                                    var_dump($cp_db);
    				}
    			}
            }
    	}
    else{
           $filename="/var/db/captiveportal.db";
           if (file_exists($filename))
            	$cp_db=file($filename);	
    }
     /*
            $usuario="";
            // 1376630450,2,172.16.3.65,00:50:56:9c:00:c7,admin,e1779ea20d0a11c7,,,,
            if (is_array($cp_db)){
    	        foreach ($cp_db as $cpl){
    	        	$fields=explode(",",$cpl);
    	        	if ($fields[2] != "" && $fields[2]==$line)
    	        		$usuario=$fields[4];
    	        }
            }
            if ($usuario !="")
                $resposta="OK user={$usuario}";
            else
                $resposta="ERR";
            fwrite (STDOUT, "{$resposta}\n");
            unset($cp_db);
    }
    */
    ?>
    
    

    rode este php na console e veja se o usuário dos dois captives aparecem na lista.

    @rlljorge:

    P.S = Squid 3.3.10 transparente HTTP/HTTPS simplesmente fantástico.

    Também acho  :) Por isso ainda gasto tanto tempo melhorando a gui dele no pfsense.



  • Marcelo,

    Rodei o Script, sim aparece os usuários dos 2 captives.



  • @rlljorge:

    Rodei o Script, sim aparece os usuários dos 2 captives.

    Então era para estar funcionando, pode colar o resultado do ultimo array onde mostra um usuario por linha?



  • Aqui está a saida na integra.

    
    Content-type: text/html
    
    /var/db/captiveportal_radius_xxxxxx.db
    bool(false)
    NULL
    /var/db/captiveportalyyyy.db
    array(1) {
      [0]=>
      array(12) {
        ["allow_time"]=>
        string(10) "1401230926"
        ["pipeno"]=>
        string(4) "2090"
        ["ip"]=>
        string(13) "192.168.1.123"
        ["mac"]=>
        string(17) "00:19:21:65:4d:8c"
        ["username"]=>
        string(7) "rodrigo"
        ["sessionid"]=>
        string(16) "38d62a1d34f6193e"
        ["bpassword"]=>
        string(0) ""
        ["session_timeout"]=>
        NULL
        ["idle_timeout"]=>
        NULL
        ["session_terminate_time"]=>
        NULL
        ["interim_interval"]=>
        NULL
        ["radiusctx"]=>
        string(5) "first"
      }
    }
    array(1) {
      [0]=>
      string(83) "1401230926,2090,192.168.1.123,00:19:21:65:4d:8c,rodrigo,38d62a1d34f6193e,,,,,,first"
    }
    /var/db/captiveportalxxxxxx.db
    array(1) {
      [0]=>
      array(12) {
        ["allow_time"]=>
        string(10) "1401230684"
        ["pipeno"]=>
        string(4) "2088"
        ["ip"]=>
        string(13) "192.168.10.99"
        ["mac"]=>
        string(17) "00:1f:d0:fb:8a:bf"
        ["username"]=>
        string(5) "erick"
        ["sessionid"]=>
        string(16) "12277c752ef6575c"
        ["bpassword"]=>
        string(20) "TDB5MGwxKmIxdGlzdDE="
        ["session_timeout"]=>
        NULL
        ["idle_timeout"]=>
        NULL
        ["session_terminate_time"]=>
        NULL
        ["interim_interval"]=>
        NULL
        ["radiusctx"]=>
        string(5) "first"
      }
    }
    array(1) {
      [0]=>
      string(101) "1401230684,2088,192.168.10.99,00:1f:d0:fb:8a:bf,erick,12277c752ef6575c,TDB5MGwxKmIxdGlzdDE=,,,,,first"
    }
    
    


  • Pessoal, alguma sugestão ?



  • Qualquer sugestão é bem vinda !

    :-)


Log in to reply