Community discussions

MikroTik App
 
pjulian
Member Candidate
Member Candidate
Topic Author
Posts: 267
Joined: Mon May 31, 2004 12:16 pm
Location: Sydney, Australia

Redirect hotspot user to different page

Mon Feb 12, 2007 4:36 pm

Hi, I want to redirect my hotspot users to the status page instead of the page they originally tried to go to after login, and then have a link on the status page for them to continue on to where they orginally wanted to go.
I can get the redirect to the status page to work fine, but how do I carry across the address if the original page requested by the user and put that into a hyperlink on the status page ?

I have tried playing around with the link-orig variable, but it only seems valid up until I leave the login page.

I'm sure I have seen how to do this somewhere but can't find it !

Thanks
Paul
 
User avatar
bjohns
Member Candidate
Member Candidate
Posts: 271
Joined: Sat May 29, 2004 4:11 am
Location: Sippy Downs, Australia
Contact:

Tue Feb 13, 2007 12:24 am

On the login page you will need to 'capture' the link-orig var and save it somewhere, like in the users session/cookie. Then you can recall it from the status screen.

The MT lets go as soon as it submits the form data, so it wouldn't know anything about your status screen.
 
pjulian
Member Candidate
Member Candidate
Topic Author
Posts: 267
Joined: Mon May 31, 2004 12:16 pm
Location: Sydney, Australia

Tue Feb 13, 2007 12:30 am

Thanks, just figured it out this morning.
What I did was in the redirect from the login.html page to the status page, I sent the link-orig parameter with the redirect to my status page, then I grabbed that paramater again to use in the hyperlink.

Thanks for your help

Regards
Paul
 
onboardpartners
just joined
Posts: 13
Joined: Tue Feb 19, 2008 10:45 pm

Re: Redirect hotspot user to different page

Wed Feb 20, 2008 9:03 pm

Hi Paul, I can see that you have been working on exactly the same issue that I'm facing, bringing the $(link-orig) to the status.html for a hyperlink (or just opening an extra window) for the client.

Unfortunately I cannot completely understand your reply to Sergejs, can I ask you to please specify the solution you found.

I'm absolutely new to Mikrotik and the scripting, so if you could show an example it would most definitely be worth a Beer next time you are around Gibraltar :lol:

Thanks in advance.
Jens
 
pjulian
Member Candidate
Member Candidate
Topic Author
Posts: 267
Joined: Mon May 31, 2004 12:16 pm
Location: Sydney, Australia

Re: Redirect hotspot user to different page

Thu Feb 21, 2008 1:19 am

OK, firstly we modified the login.html page to redirect to our login page script:

*****login.html****
<html>
<title>...</title>
body>
<form name="redirect" action="https://yoururl/scriptname.cgi" method="post">
<input type="hidden" name="mac" value="$(mac)">
<input type="hidden" name="ip" value="$(ip)">
<input type="hidden" name="user" value="$(username)">
<input type="hidden" name="link-login" value="$(link-login)">
<input type="hidden" name="origurl" value="$(link-orig)">
<input type="hidden" name="error" value="$(error)">
<input type="hidden" name="hostname" value="$(hostname)">
<input type="hidden" name="identity" value="$(identity)">
<input type="hidden" name="chapid" value="$(chap-id)">
<input type="hidden" name="chapchallenge" value="$(chap-challenge)">

</form>
<script language="JavaScript">
<!--
document.redirect.submit();
//-->
</script>
</body>
</html>
****************

This page redirects to our cgi script running on our webserver, don't forget you need to allow access to your webserver using the walled garden feature in the hotspot.

Once we are running our cgi script we bring in the parameters passed from the login.html page using the appropriate cgi commands and use them in our script. If we need to proceed past that script we build another webpage with CGI from within the script and use a form in the webpage that submits the parameters we need to carry through as hidden fields.

Here is an excerpt from the script we redirect to from the login.html page which shows the type of html page we are generating, you just need to keep passing the parameters through and reading them with the next script for as long as you need to. We end up running about 3 scripts before the user finally gets logged in, and the login details are captured by one of our scripts and then passed to the hotspot for authentication. Scripts are great tools as you can do so much with them, for example we log all access by hotspot and userID, not to mention that fact that we can log every time one of our customers ads appear and manage our advertising so much better doing it this way, because ultimately the user clicks their way through which means you can use popups and stuff if you want as it is all user initiated.

This is how we get the parameters to use in our scripts and pass onto other scripts, standard perl CGI

**** CGI Script ****
##### Get field values parsed from login page
$$mac = param("mac");
$$ipaddress = param("ip");
$$user = param("user");
$$loginurl = param("link-login");
$$origurl = param("origurl");
$$hserror = param("error");
$$hostname = param("hostname");
$$id = param("identity");
$$chapid = param("chapid");
$$chapchallenge = param("chapchallenge");
*******************

*** Here is example of the html form generated inside the script for eventual login****
<input type="text" name="username" value="">
<input type="password" name="password" value="">
<input type="hidden" name="domain" value="">
<input type="hidden" name="dst" value="https://yourauthserver/yourscript.cgi">


I hope this helps, I have spent hundreds of hours getting our systems perfect, there is a lot of mucking around, and when you use CGI to generate your pages it does get a bit time consuming getting all your pages looking right as it's all hand coded :-)

Regards
Paul
 
onboardpartners
just joined
Posts: 13
Joined: Tue Feb 19, 2008 10:45 pm

Re: Redirect hotspot user to different page

Mon Feb 25, 2008 6:12 pm

Thanks a lot Paul, gives me good materiel to work from, I've got a lot of ideas, but I'm also very new to Mikrotik and the scripting (bought an extra RB 532A, so I've got a test environment to work on).

Your help is appreciated very much.

Best regards,
Jens
 
jmlalley
just joined
Posts: 20
Joined: Tue Jan 30, 2007 11:08 pm

Re: Redirect hotspot user to different page

Mon Mar 17, 2008 3:32 am

Greetings

How do you get the mikrotik to authenticate once you have created the radius user?

What page(s) do you call on the TIK hotspot?
 
pjulian
Member Candidate
Member Candidate
Topic Author
Posts: 267
Joined: Mon May 31, 2004 12:16 pm
Location: Sydney, Australia

Re: Redirect hotspot user to different page

Mon Mar 17, 2008 7:10 am

Those questions are answered easiest by downloading the PDF for hotspot and reading through the customisations and learn how it hangs together, there are examples there which are helpful, but at the early stage you are probably at I recommend reading that first and foremost.

Regards
Paul
 
jmlalley
just joined
Posts: 20
Joined: Tue Jan 30, 2007 11:08 pm

Re: Redirect hotspot user to different page

Mon Mar 17, 2008 1:22 pm

Hi

I have spent hours reading the 2.9 ref manual and looking at online posts. I am still stuck. Is there another reference I should look for?

I modified login html and added two more forms to handle users who do not have a login and need to purchase one. At this point in the hosts tab of the hotspot. the status if the user is "H". After I successfully add their mac address to the radius database, I try to log them in with this form on my "walled garden" enrollment server.

<form name="login" action="http://10.239.27.1/login" method="post">
<input type="text" name="username" value="#mac#">
<input type="text" name="mac" value="#mac#">
<input type="text" name="dst" value="http://www.nytimes.com/">
<input type="text" name="chap-id" value="#chap_id#" >
<input type="text" name="chap-challenge" value="#chap_challenge#">
<input type="submit" name="login" value="log in">
</form>
The actual variables are used for #variables#
As I read the documentation, this should cause a radius authentication to occur and send the user to http://www.nytimes.com.

Instead, I get "web browser did not send challenge response (try again, enable JavaScipt). All I want to do is force the hotspot to try mac authentication again now that the mac is valid. It does not happen because the host status is still "H".

If I delete the host from the hotspot, then the user can mac authenticate and life is good.

Here is what I think the the desired sequence of events is:
invalid mac address redirects user to login page
user host status is set to "H" by TIK
user hits button to go to external "walled garden" enrollment server that creates radius user = mac address
user is sent back to tik router where mac-authentication occurs. user host status is set to "A" by TIK
user can now use internet

What Am I missing?

Thank you
 
pjulian
Member Candidate
Member Candidate
Topic Author
Posts: 267
Joined: Mon May 31, 2004 12:16 pm
Location: Sydney, Australia

Re: Redirect hotspot user to different page

Mon Mar 17, 2008 3:14 pm

You know what, I had that same error and I can't remember what I did to fix it.....

I will see what I can find.

Regards
Paul
 
pbundschuh
just joined
Posts: 4
Joined: Fri Apr 11, 2008 1:07 am

Re: Redirect hotspot user to different page

Tue Apr 15, 2008 8:21 pm

I have changed out login.html to redirect the user to our remote Login-Script.
But what I don't understand is:

- How can I modify the RAIDUS-Database (User-Manager)?
- What URL ("form action")do I have to call from our Login-Script on the remote server to authenticate the user?
- Could you post the relevant parts of your CGI-Script?

Regards,
Philipp
 
jmlalley
just joined
Posts: 20
Joined: Tue Jan 30, 2007 11:08 pm

Re: Redirect hotspot user to different page

Tue Apr 15, 2008 10:07 pm

Greetings

I developed a solution which I am in the process of documenting. I will try to post it in the next few days.

Cheers

Joe
 
pbundschuh
just joined
Posts: 4
Joined: Fri Apr 11, 2008 1:07 am

Re: Redirect hotspot user to different page

Wed Apr 16, 2008 11:29 am

Could you please send me your scripts (or the relevant part of them)?
email: info (at) comit-gmbh.de

regards,
philipp
 
onboardpartners
just joined
Posts: 13
Joined: Tue Feb 19, 2008 10:45 pm

Re: Redirect hotspot user to different page

Sat Jun 14, 2008 12:04 am

Greetings Joe,

I would appreciate if you would send a copy of your scripts to me too, I'm still playing around with a few ideas.

Thanks in advance.

Best regards
Jens

Skype: onboardpartners
mail: j.kaersgaard(at)onboardpartners.com
 
onboardpartners
just joined
Posts: 13
Joined: Tue Feb 19, 2008 10:45 pm

Re: Redirect hotspot user to different page

Tue Aug 26, 2008 6:39 pm

Hi pjulian,

Since you wrote the response below, we have started rolling out in other countries and a few Mikrotik questions has become like one million !!

Now, my question is: The engenious solution you have spent a lot of time creating, is that by any chance for sale ?

I'll tell you why, until now we have only been in Gibraltar but are now expanding to Spain, Portugal and Morocco and I would need a solution for login to the mikrotik box (the set of html pages in the MT532A) that will allow me to use more languages and advertising (separat advertising in each marina) and all of it centrally controlled.

Please let me know if you will consider selling a license to your solution and I will be spared the time it takes to learn the MT boxes, the used language and the time it takes to invent a similar solution.

Best regards,
Jens
j.kaersgaard {at} yachtconnect.com



OK, firstly we modified the login.html page to redirect to our login page script:

*****login.html****
<html>
<title>...</title>
body>
<form name="redirect" action="https://yoururl/scriptname.cgi" method="post">
<input type="hidden" name="mac" value="$(mac)">
<input type="hidden" name="ip" value="$(ip)">
<input type="hidden" name="user" value="$(username)">
<input type="hidden" name="link-login" value="$(link-login)">
<input type="hidden" name="origurl" value="$(link-orig)">
<input type="hidden" name="error" value="$(error)">
<input type="hidden" name="hostname" value="$(hostname)">
<input type="hidden" name="identity" value="$(identity)">
<input type="hidden" name="chapid" value="$(chap-id)">
<input type="hidden" name="chapchallenge" value="$(chap-challenge)">

</form>
<script language="JavaScript">
<!--
document.redirect.submit();
//-->
</script>
</body>
</html>
****************

This page redirects to our cgi script running on our webserver, don't forget you need to allow access to your webserver using the walled garden feature in the hotspot.

Once we are running our cgi script we bring in the parameters passed from the login.html page using the appropriate cgi commands and use them in our script. If we need to proceed past that script we build another webpage with CGI from within the script and use a form in the webpage that submits the parameters we need to carry through as hidden fields.

Here is an excerpt from the script we redirect to from the login.html page which shows the type of html page we are generating, you just need to keep passing the parameters through and reading them with the next script for as long as you need to. We end up running about 3 scripts before the user finally gets logged in, and the login details are captured by one of our scripts and then passed to the hotspot for authentication. Scripts are great tools as you can do so much with them, for example we log all access by hotspot and userID, not to mention that fact that we can log every time one of our customers ads appear and manage our advertising so much better doing it this way, because ultimately the user clicks their way through which means you can use popups and stuff if you want as it is all user initiated.

This is how we get the parameters to use in our scripts and pass onto other scripts, standard perl CGI

**** CGI Script ****
##### Get field values parsed from login page
$$mac = param("mac");
$$ipaddress = param("ip");
$$user = param("user");
$$loginurl = param("link-login");
$$origurl = param("origurl");
$$hserror = param("error");
$$hostname = param("hostname");
$$id = param("identity");
$$chapid = param("chapid");
$$chapchallenge = param("chapchallenge");
*******************

*** Here is example of the html form generated inside the script for eventual login****
<input type="text" name="username" value="">
<input type="password" name="password" value="">
<input type="hidden" name="domain" value="">
<input type="hidden" name="dst" value="https://yourauthserver/yourscript.cgi">


I hope this helps, I have spent hundreds of hours getting our systems perfect, there is a lot of mucking around, and when you use CGI to generate your pages it does get a bit time consuming getting all your pages looking right as it's all hand coded :-)

Regards
Paul

Who is online

Users browsing this forum: No registered users and 74 guests