Im having some trouble sending the login information back to the MT hotspot device. I got all the redirecting done to my external server. In the form part of the html i tried :
That only redirected my back to the external page so then i decided to tried to implement my own automatic login page using code from the original login.html on the MT device. For some reason my values aren’t being translated right by the MT. Just to test this, in the form of my automatic login page, i used :
and i get a textbox with the word ‘$(username)’ in it. I’ve also tried variations like <?=$_POST['username']?>, $username, %username%…i am not very experienced in html, so im not sure what is wrong. Does mikrotik use different syntax to retrieve posted values?
Oh, btw, i read the manual with the redirect to external and back to login. I get the same thing where is sends me back tot he external server.
Not sure what’s happening, you need to make sure it all happens between the client and the NAS. Here’s what I use, which is very similar to what’s in the manual:
Server IP: 2.2.2.2
NAS IP (client facing/hotspot): 1.1.1.1
The values are substituted for the real ones by the NAS and submitted to the external server. The script on the server uses the values provided to do various things and then displays the following back to the user for them to submit (you can have this automatically submit as above if you want, up to you)
On the external server (which is loaded by the client’s browser):
So when i use that external script what prohibits the NAS(client) from being redirected back to the external server. The redirect script from above is named login.html correct? If thats the case do i just force the hotspot unauth users to redirect.html and leave the login.html the same? Im just not too clear on this procedure.
To log a client in, you need to get them to submit their credentials to the ‘login’ script on the NAS. If it makes it easier to understand, you can refer to it as login.cgi too.
Ok, so just to clarify this. On my hotspot device, i have the redirect script saved as login.html. And on the external server, i have the script you specified saved as login.cgi. Therefore, the process is :
User opens web browser.
User redirected to external login.
User inputs info and hits submit.
the username and password are sent to the hotspot device?
then the hotspot device does its thing with radius.
The whole step 4 is foggy. FYI, i have this thing working without the external server. I’m just not sure how the hotspot device grabs the values being posted to it from the external login page. When i tried this, the page on my hotspot device didn’t know what those values were. Or at least i didn’t know the syntax for grabbing posted values.
Also, i have a version of the login.html that automatically submits itself with a hardcoded user/pass. When i rename this file say to autologin.html and create the redirect in the old login.html it won’t login. It gives me an error ‘document.sendin.username’ is null or not an object
I’ve done a bit of programming and this just strikes me as very odd…
This is the code, probably ugly. 8^) just learning this html and javascript stuff.
Here’s a image I threw together that illustrates the process:
The remote server code I posted above isn’t the whole thing - there is more involved - essentially grabbing the values passed from the Router and building a form the user can click on to log in with.
I might actually knock up a quick and dirty perl cgi script that demonstrates this.
On the external code i kinda figured that. I have a working login.php on my external server that grabs the values from the redirect with <?=_POST['values of whatever']?> Its just when i post information back to the MT i can’t seem to grab the values or hardcode the values in my own page that automatically submits. Also, does Mikrotik support php script? Thanks again.