Community discussions

MikroTik App
 
User avatar
tevolo
Member Candidate
Member Candidate
Topic Author
Posts: 114
Joined: Sun Mar 29, 2009 8:39 pm

Redirect Hotspot Login Page

Sun Jan 10, 2010 12:41 am

We use RouterOS Hotspot service with an externally located Radius server. Right now users have to login through the hotspot login page to access the internet, and if they haven't paid for service, then they have to go to our radius server website to login (with the same hotspot credentials) and purchase credits. (By the way we are using DMA Softlab's RadiusManager).
We would like to change this so there are less steps and just one login for both interfaces. Is that possible?

Has anyone out there did some programming to make this work or is it simple and I'm just missing something?
 
fewi
Forum Guru
Forum Guru
Posts: 7734
Joined: Tue Aug 11, 2009 3:19 am

Re: Redirect Hotspot Login Page

Sun Jan 10, 2010 12:49 am

Are you asking if you can host the Hotspot login page on an external server? If so, sure, it's fairly simple.

The 3.0 manual contains a detailed write up of resources that are used for the login screen display/login process, but here's a short run down that assumes there are no other files in the Hotspot directory as differently named files may be loaded first if they exist (refer to the documentation for details).

Make a login.html that redirects to your external page:
<html><head>
<meta http-equiv="refresh" content="0; url=http://my.external.splashpage.com/index.html">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
</head><body></body></html>
And both redirect.html and logout.html contain the same HTML, they just loop back to login.html:
<html><head>
<meta http-equiv="refresh" content="0; url=login.html">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
</head><body></body></html>
</html>
Make a alogin.html that redirects to the "You are now connected" page displayed after a successful login:
<html><head>
<meta http-equiv="refresh" content="0; url=http://my.external.splashpage.com/connected.html">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
</head><body></body></html>
The external login page should redirect back to "/login?username=username&password=password" on the Hotspot router. You'll also have to permit the external page in the walled garden so unauthorized users can get there.

Hope that helps and that I'm not misunderstanding the question.
 
User avatar
tevolo
Member Candidate
Member Candidate
Topic Author
Posts: 114
Joined: Sun Mar 29, 2009 8:39 pm

Re: Redirect Hotspot Login Page

Sun Jan 10, 2010 5:43 pm

Yes, that is what I was looking for, but will it work if the external login page doesn't use the code the original login page uses in the login form and javascript:

Here is the hotspot login code:
$(if chap-id)
<form name="sendin" action="$(link-login-only)" method="post">
<input type="hidden" name="username" />
<input type="hidden" name="password" />
<input type="hidden" name="dst" value="$(link-orig)" />
<input type="hidden" name="popup" value="true" />
</form>

<script type="text/javascript" src="/md5.js"></script>
<script type="text/javascript">
<!--
function doLogin() {
document.sendin.username.value = document.login.username.value;
document.sendin.password.value = hexMD5('$(chap-id)' + document.login.password.value + '$(chap-challenge)');
document.sendin.submit();
return false;
}
//-->
</script>
$(endif)
and the form:
<form name="login" action="$(link-login-only)" method="post"
$(if chap-id) onSubmit="return doLogin()" $(endif)>
<input type="hidden" name="dst" value="$(link-orig)" />
<input type="hidden" name="popup" value="true" />

<table width="100" style="background-color: #ffffff">
<tr><td align="right">login</td>
<td><input style="width: 80px" name="username" type="text" value="$(username)"/></td>
</tr>
<tr><td align="right">password</td>
<td><input style="width: 80px" name="password" type="password"/></td>
</tr>
<tr><td>&nbsp;</td>
<td><input type="submit" value="OK" /></td>
</tr>
</table>
</form>
If the above code needs to be in the external login page, I suppose I could add it, but my external login page already uses it's own code to authenticate users. Can they be merged so it logs in the user in both locations or is that not feasible. Basically we want just one login page for both the radius server and hotspot login so it authenticates the user on the router so they could use the Internet (if they have credits), and view the status of their account on the radius server - one login for two places.

The code for the external login page is:
<form name="form1" method="post" action="user.php?cont=login" onSubmit="return login(this);">
<table border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td colspan="2"><div align="center"><img src="images/logo_small.gif" width="120" height="96"></div></td>
</tr>
<tr>
<td colspan="2"><p class="title2">{UCPLOGIN0}</p>
<p align="center" class="normal"><font color="#8DA4D3"><strong>{UCPLOGIN4}</strong></font></p>
<p class="title2"> <font color="#FF0000">{ERROR}</font></p></td>
</tr>
<tr>
<td class="normal"><div align="right">{UCPLOGIN6}:</div></td>
<td><select name="lang" class="normal" id="lang" onChange="change_lang()">
{LANGLIST}</select></td>
</tr>
<tr>
<td class="normal"><div align="right">{UCPLOGIN1}:</div></td>
<td><input name="username" type="text" class="normal" id="username" value="{USERNAME}" size="20" maxlength="32"></td>
</tr>
<tr>
<td class="normal"><div align="right">{UCPLOGIN2}:</div></td>
<td><input name="password" type="password" class="normal" id="password" size="20" maxlength="32"></td>
</tr>
<tr>
<td colspan="2" class="normal"><div align="center">
<input type="submit" name="Submit" value="{UCPLOGIN3}">
<SCRIPT type=text/javascript><!--
if (document.form1.username.value == "")
focusField("username");
else
focusField("password");
function focusField(name) {
for(var i = 0; i < document.forms.length; ++i) {
var obj = document.forms.elements[name];
if (obj) {
if (obj.length) { obj = obj[0]; }
if (obj.focus) { obj.focus(); }
}
}
}
//--> </SCRIPT>
<script src="md5.js"></script>
<script language="JavaScript"><!--
function login(form)
{
form['md5'].value = hex_hmac_md5(form['username'].value, hex_md5(form['password'].value) );
form['password'].value = '';
return true;
}
function change_lang()
{
len = document.form1.lang.length;

for (i = 0; i < len; i++)
{
if (document.form1.lang.selected)
lang = document.form1.lang.text;
}
window.location="user.php?cont=change_lang&lang=" + lang;
}
//--></script>
<input type="hidden" name="md5" value="">
</div></td>
</tr>
<tr>
<td colspan="2" class="normal">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="normal"><div align="center">{REGISTER}</div></td>
</tr>
</table>
</form>


Thanks for any help.
 
fewi
Forum Guru
Forum Guru
Posts: 7734
Joined: Tue Aug 11, 2009 3:19 am

Re: Redirect Hotspot Login Page

Sun Jan 10, 2010 5:55 pm

a) none of the variables for the router hosted page will be available since the router won't be interpolating them, things like $(link-login-only) etc. will have to be passed on to the external page in the redirect and then re-interpreted by a dynamic scripting language on the server
b) you can't log into two things at once. To log into the router Hotspot you _must_ redirect the customer back to /login?username=username&password=password on the router, which takes the user away from the external server. You can have the user log into the server, and then have the server check if the user has uptime. If not, the server displays a page that lets the user purchase uptime and redirects the user back to the router for login on successful transaction. If the user already has uptime, just redirect back to the router login.
 
birendersinghbudhwar
Frequent Visitor
Frequent Visitor
Posts: 98
Joined: Thu Oct 29, 2009 5:15 am
Location: Rohtak, HR, INDIA

Re: Redirect Hotspot Login Page

Mon Jan 11, 2010 1:04 pm

We use RouterOS Hotspot service with an externally located Radius server. Right now users have to login through the hotspot login page to access the internet, and if they haven't paid for service, then they have to go to our radius server website to login (with the same hotspot credentials) and purchase credits. (By the way we are using DMA Softlab's RadiusManager).
We would like to change this so there are less steps and just one login for both interfaces. Is that possible?

Has anyone out there did some programming to make this work or is it simple and I'm just missing something?
Hi we also using hotpot system for our clients..., we are using a customer radius server a product of Wifi4india it uses radius server and a web based user management were all database and their accounting related data stores like traffic and bills.

in our case now peoples signup for the service and after paying the charges their account will be activated they will be login to hotspot login page and asking them to login please in order to use internet.

in that web management we can define n number of NAS and porxy, plans, group, attributes, user and their password etc...

They provide service based on subscription or one time ownership based we are on subscription based yearly subscription no monthly fixed charges no revenue sharing policy.

Its very simple and user friendly with online help for configuring the components and modules.
Birender Singh Budhwar
Network / Server Administration
 
H2009
Member Candidate
Member Candidate
Posts: 137
Joined: Tue Oct 26, 2010 8:46 am

Re: Redirect Hotspot Login Page

Fri Jun 28, 2013 7:42 pm

Are you asking if you can host the Hotspot login page on an external server? If so, sure, it's fairly simple.

The 3.0 manual contains a detailed write up of resources that are used for the login screen display/login process, but here's a short run down that assumes there are no other files in the Hotspot directory as differently named files may be loaded first if they exist (refer to the documentation for details).

Make a login.html that redirects to your external page:
<html><head>
<meta http-equiv="refresh" content="0; url=http://my.external.splashpage.com/index.html">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
</head><body></body></html>
And both redirect.html and logout.html contain the same HTML, they just loop back to login.html:
<html><head>
<meta http-equiv="refresh" content="0; url=login.html">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
</head><body></body></html>
</html>
Make a alogin.html that redirects to the "You are now connected" page displayed after a successful login:
<html><head>
<meta http-equiv="refresh" content="0; url=http://my.external.splashpage.com/connected.html">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
</head><body></body></html>
The external login page should redirect back to "/login?username=username&password=password" on the Hotspot router. You'll also have to permit the external page in the walled garden so unauthorized users can get there.

Hope that helps and that I'm not misunderstanding the question.
I know this is an old thread but fewi can you show the code what should be on the external login page - index.html (which If I've understood should be on the server).

Thank you
To show support for those with food allergies/intolerances please download the application from www.biteappy.com
 
H2009
Member Candidate
Member Candidate
Posts: 137
Joined: Tue Oct 26, 2010 8:46 am

Re: Redirect Hotspot Login Page

Fri Jun 28, 2013 8:08 pm

Update:

Ok here is the link you need to get this to work using php

http://wiki.mikrotik.com/wiki/HotSpot_e ... login_page
To show support for those with food allergies/intolerances please download the application from www.biteappy.com

Who is online

Users browsing this forum: bpwl, linguax, MSN [Bot], sindy and 184 guests