Page 1 of 1

Radius does not recognize external login page

Posted: Tue Jun 12, 2012 12:22 pm
by fruiz002
Hello all,

I'm trying to set up an external login page; if I follow the MKT tuthorial everything works perfectly, but if I go from the login.html in my MKT to another page first (for example laguage choice) and then to the login.php in my server, the freeradius server does not get any data and I cannot login.

Anybody has a clue of how to solve it?

Thanks in advance.

Regards

Re: Radius does not recognize external login page

Posted: Tue Jun 12, 2012 1:20 pm
by SurferTim
Are you forwarding all the variables through to the remote login page? You know, these:
<?php
   $mac=$_POST['mac'];
   $ip=$_POST['ip'];
   $username=$_POST['username'];
   $linklogin=$_POST['link-login'];
   $linkorig=$_POST['link-orig'];
   $error=$_POST['error'];
   $chapid=$_POST['chap-id'];
   $chapchallenge=$_POST['chap-challenge'];
   $linkloginonly=$_POST['link-login-only'];
   $linkorigesc=$_POST['link-orig-esc'];
   $macesc=$_POST['mac-esc'];
?>
You need to send them on from the intermediate page to the remote login page like this:
<form name="redirect" action="http://xx.xx.xx.xx/login.php" method="post">
<input type="hidden" name="mac" value="<?php echo $mac ?>">
<input type="hidden" name="ip" value="<?php echo $ip ?>">
<input type="hidden" name="username" value="<?php echo $username ?>">
<input type="hidden" name="link-login" value="<?php echo $linklogin ?>">
<input type="hidden" name="link-orig" value="<?php echo $linkorig ?>">
<input type="hidden" name="error" value="<?php echo $error ?>">
<input type="hidden" name="chap-id" value="<?php echo $chapid ?>">
<input type="hidden" name="chap-challenge" value="<?php echo $chapchallenge ?>">
<input type="hidden" name="link-login-only" value="<?php echo $linkloginonly ?>">
<input type="hidden" name="link-orig-esc" value="<?php echo $linkorigesc ?>">
<input type="hidden" name="mac-esc" value="<?php echo $macesc ?>">
<input type="submit" value="continue">
</form>
There may be some info here that may help you.
http://wiki.mikrotik.com/wiki/HotSpot_e ... login_page

add: The RADIUS Access-Reject may cause some confusion. If the user enters an incorrect user or password, the intermediate page will be called again to display the error message and the new login page. I also forgot the "<?php echo" part.

On second thought, have you considered putting the questions you want on the original login.html page on the router? Just don't use the javascript routine to submit the form automatically. Then forward all that to the external login.php page. That would eliminate the need for the intermediate page.

Re: Radius does not recognize external login page

Posted: Tue Jun 12, 2012 5:56 pm
by fruiz002
Hello,

Thnaks for the answer, I found it by chance cause I don't know why I did not get it in my e-mail thought I configured it... well, I'll try it, but then, can I post the code you sent me in a nother page in my server and send it to the login.ph in teh same saerver?


Could you post the whole code? cause you said you had forgotten something. right?

Thanks

Regards

Re: Radius does not recognize external login page

Posted: Tue Jun 12, 2012 6:09 pm
by fruiz002
Hello,

Sorry, but I don't understand... Could you explain it better, please? thanks!

I know that the login.php is failing cause it does not get the proper info, but I don't know what exactly fails...

regards

Re: Radius does not recognize external login page

Posted: Tue Jun 12, 2012 6:15 pm
by SurferTim
I recommend using only the remote login.php page to start. It is confusing enough.

Did you read the wiki article link above? When you replace the standard login.html, it resends the form to the login.php page. It is up to you at that point to retrieve the form variables and insert those into the login.php page. Examples are there.

Re: Radius does not recognize external login page

Posted: Tue Jun 12, 2012 6:22 pm
by fruiz002
I did it already, when I go directly as explained in the forum it works perfectly, but if for example I want to embed my page and improve it, I cannot do it in the router, tha's why I send it to the server.
I have read already the wiki you sent me a few ties but it does not have enough information...

Regards

Re: Radius does not recognize external login page

Posted: Tue Jun 12, 2012 7:04 pm
by fruiz002
I understand now, the question is that I have to send the parameters to the login.php page, but the question is how...?

Regards

Re: Radius does not recognize external login page

Posted: Tue Jun 12, 2012 8:31 pm
by SurferTim
The login.php page shows how to retrieve the POST form fields and use them.

Re: Radius does not recognize external login page

Posted: Wed Jun 13, 2012 4:56 pm
by fruiz002
What do you mean? I understand that I have to send the values to the login.php, right? the the login.php will send them to the Router for loging, right? the question is how cause I have done a HTML form to send the values and I get an error from th login.php which is: serveraddress/$(link-login-only) and it says that the page is not found in the server....

Thanks for the feedbak.

Regards

Re: Radius does not recognize external login page

Posted: Wed Jun 13, 2012 8:46 pm
by SurferTim
(snip)...and I get an error from th login.php which is: serveraddress/$(link-login-only) and it says that the page is not found in the server....
There is no $(link-login-only) in the php server. That is the variable in the Mikrotik router OS. That would be $linkloginonly on the login.php page.

These are the variables in the php server retrieved by the login.php page (sent by the router login.html form).
<?php
   $mac=$_POST['mac'];
   $ip=$_POST['ip'];
   $username=$_POST['username'];
   $linklogin=$_POST['link-login'];
   $linkorig=$_POST['link-orig'];
   $error=$_POST['error'];
   $chapid=$_POST['chap-id'];
   $chapchallenge=$_POST['chap-challenge'];
   $linkloginonly=$_POST['link-login-only'];
   $linkorigesc=$_POST['link-orig-esc'];
   $macesc=$_POST['mac-esc'];
?>