Community discussions

MikroTik App
 
hiad
just joined
Topic Author
Posts: 9
Joined: Tue Jul 10, 2018 6:38 am

New Mikrotik - Using API to log users instead of RADIUS server

Tue Jul 10, 2018 6:44 am

Hello everyone,

Nice to meet you, my name is Hector Alcazar, I am a fullstack developer and I have a requirement to work on the creation of a login portal. Sincerely I have not worked with RADIUS and I want to skip that step, through the API, is it possible to log users using my own database?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: New Mikrotik - Using API to log users instead of RADIUS server

Sat Jul 14, 2018 6:04 pm

I assume you mean hotspot users.

Yes, it's possible, but how easy it is depends on your topology.

On successful authentication with your database, you'll need to create a temporary hotspot user with the API using the "/ip hotspot user add" command, then call the "/ip hotspot active login" command to then bind that user to the internal IP address of the device the user is on. Ideally, you want to add an "on-logout" script at their profile that will remove the user from hotspot as soon as they log out.

If your router is in the same network as your web server, your web server will just know the IP address. If the router has a public IP, but your web server is not in the same network, you'll need to lookup the "/ip firewall connections" menu for their connection to your web server. Your server can tell you the IP and port the client is using at the router, which is enough to uniquely identify them in there, and from there, you'll get their private IP.

If your router does not have a public IP (i.e. you have a "double NAT" situation), and your web server is outside of the network, you'll need to setup a VPN between the router and web server, and then proceed to use the VPN IP as if it's a public one AND make sure users enter your web page through the VPN connection (so that you can look them up in the "/ip firewall connections").
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 897
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: New Mikrotik - Using API to log users instead of RADIUS server

Mon Oct 01, 2018 7:00 pm

Please don't re-post your question over-and-over again.

viewtopic.php?f=9&t=139738&p=689207#p689207
viewtopic.php?f=9&t=139860&p=689798#p689798

User danikf has answered your question regarding C#:
viewtopic.php?t=99954&p=689812#p689812
of course ...
...
... if you are able to read previous posts ...
var user = new HotspotUser()
{
    Name = "TEST",
    LimitUptime = "1:00:00",
    Password = "secretpass"
};
_connection.Save(user);

Who is online

Users browsing this forum: No registered users and 22 guests