Project

General

Profile

Actions

Bug #2454

closed

Captive portal return wrong authentication URL

Added by Mathieu Déom almost 12 years ago. Updated over 11 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
Captive Portal
Target version:
Start date:
05/25/2012
Due date:
% Done:

90%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.1
Affected Architecture:
amd64

Description

Since the last update "Built On: Sun May 13 02:42:10 EDT 2012" our captive portal doesn't work anymore.

The redirection URL seems to be wrong.

Instead of a thing like : "10.0.54.1:8000/index.php?zone=myzonename&..."

We have :

"hostnameDomainName/index.php?zone=1&..." ( moreover there's a dot missing between the hostname and the domain name in the URL)

So Pfsense seems not being able to find the correct zonename of the portal and the correct ip of the interface...

Here, the redirect URL I get :

http://mypfsenseinternal.mycorp.com/index.php?zone=1&redirurl=http%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fwww.google.com%2F

pfsense hostname : mypfsense
pfsense domain : internal.mycorp.com

And I use the default config of the captive portal.

A colleague found a temporary fix :

Original /etc/inc/captiveportal.inc

Code:
function portal_ip_from_client_ip($cliip) {
    global $config, $cpzone;

    $interfaces = explode(",", $config['captiveportal'][$cpzone]['interface']);
    foreach ($interfaces as $cpif) {
        $ip = get_interface_ip($cpif);
        $sn = get_interface_subnet($cpif);
        if (ip_in_subnet($cliip, "{$ip}/{$sn}"))
            return $ip;

    }

New one

Code:
function portal_ip_from_client_ip($cliip) {
    global $config, $cpzone;
        foreach ($config['captiveportal'] as $cpkey => $cp) {
        $cpzone = $cpkey; 

        $interfaces = explode(",", $config['captiveportal'][$cpzone]['interface']);
        foreach ($interfaces as $cpif) {
            $ip = get_interface_ip($cpif);
            $sn = get_interface_subnet($cpif);
            if (ip_in_subnet($cliip, "{$ip}/{$sn}"))
                return $ip;
        }
        }

Original /usr/local/captiveportal/index.php

Code:
$cpzone = $_REQUEST['zone'];
$cpcfg = $config['captiveportal'][$cpzone];

$orig_host = $_ENV['HTTP_HOST'];
$orig_request = $_REQUEST['redirurl'];
$clientip = $_SERVER['REMOTE_ADDR'];

if (!$clientip) {
    /* not good - bail out */
    log_error("Captive portal could not determine client's IP address.");
    $error_message = "An error occurred.  Please check the system logs for more information.";
    portal_reply_page($redirurl, "error", $errormsg);
    exit;
}

New One

Code:
$orig_host = $_ENV['HTTP_HOST'];
$orig_request = $_REQUEST['redirurl'];
$clientip = $_SERVER['REMOTE_ADDR'];

global $cpzone;
#$cpzone = $_REQUEST['zone'];
$ifip = portal_ip_from_client_ip($clientip);
$cpcfg = $config['captiveportal'][$cpzone];

if (!$clientip) {
    /* not good - bail out */
    log_error("Captive portal could not determine client's IP address.");
    $error_message = "An error occurred.  Please check the system logs for more information.";
    portal_reply_page($redirurl, "error", $errormsg);
    exit;
}
Actions #1

Updated by Warren Baker almost 12 years ago

  • Status changed from New to Feedback
  • % Done changed from 0 to 100
Actions #2

Updated by Warren Baker almost 12 years ago

  • % Done changed from 100 to 90
Actions #3

Updated by Chris Buechler over 11 years ago

  • Status changed from Feedback to Resolved
Actions

Also available in: Atom PDF