Community discussions

MikroTik App
 
colinhowlin
just joined
Topic Author
Posts: 3
Joined: Fri May 16, 2014 3:52 pm

Automatically create users for MAC authentication

Fri Jul 15, 2016 2:57 pm

Hi

We're looking to set up a hotspot solution but it will be free and simply require users to agree to terms & conditions.
I have this working currently by having login.html pass a pre-determined value for username and password:
<label class="control-label">To proceed, please read and accept the Terms of Use below.</label>
<input style="width: 80px" name="username" type="hidden" value="open_net"/> 
<input style="width: 80px" name="password" type="hidden" value="open_net"/>
<input type="submit" value="OK" 
What I want to do is have the Mikrotik (or User-Manager) automatically create user based on their MAC address.
Is this possible?
 
User avatar
rcourtney
Frequent Visitor
Frequent Visitor
Posts: 61
Joined: Wed May 22, 2013 10:55 pm

Re: Automatically create users for MAC authentication

Sat Jul 16, 2016 12:00 am

The challenge is to execute a CGI program or script from an external web server that does not expose
API controls to the user.

I would almost say write a program in C++ C# .NET  etc that acts as a web server.

Once the user posts the Accepted terms, issue API or telnet commands to add a local user.
Username, could use the date/time to make it easier to remove users at the end of the day.

Perhaps use a Raspberry Pi platform to host the program.
 
fernando1787
just joined
Posts: 9
Joined: Mon Apr 11, 2016 6:32 pm

Re: Automatically create users for MAC authentication

Sat Jul 16, 2016 5:54 am

Do you really need create a username/password? If you only want user aceept term to access hotspot service you can try create a local username/password without shared users limit and edit form to user this username/password.
 
User avatar
rcourtney
Frequent Visitor
Frequent Visitor
Posts: 61
Joined: Wed May 22, 2013 10:55 pm

Re: Automatically create users for MAC authentication

Sun Jul 17, 2016 7:52 pm

I am thinking the name cannot be empty when adding a mac entry in the hotspot user list.
Password is not used if method (login-by) is mac.
Name could be generated from the current date time by the client php code.

So the user only needs to accept terms. The two important fields (mac and name) are generated by client code and then posted to the server.

The server being a separate machine that has been wall gardened.
The server sends out the accept page. The server receives the mac and name fields then opens a separate connection to the Mikrotik.
Through the API it issues a command to add a new user.  The server then sends a redirect page back to the user.
The Mikrotik now sees the mac is in the authorized user list allows the user through.

Using a date in the user name allows a nightly script to clean out users if desired.
Last edited by rcourtney on Mon Jul 18, 2016 9:02 pm, edited 1 time in total.
 
User avatar
rcourtney
Frequent Visitor
Frequent Visitor
Posts: 61
Joined: Wed May 22, 2013 10:55 pm

Re: Automatically create users for MAC authentication

Mon Jul 18, 2016 8:58 pm

Do you really need create a username/password? If you only want user accept term to access hotspot service you can try create a local username/password without shared users limit and edit form to user this username/password.
Yes, the original poster is using "open_net" for both the username and password with unlimited use.
Using MAC is nice as you can restrict someone if they abuse the free WiFi or if you later want them to pay for additional time.