Home
Help
Search
Login
Register
OPNsense Forum
»
English Forums
»
General Discussion
»
Captive portal API
« previous
next »
Print
Pages: [
1
]
Author
Topic: Captive portal API (Read 7918 times)
robx
Newbie
Posts: 4
Karma: 2
Captive portal API
«
on:
January 19, 2016, 02:13:54 pm »
I'm trying to use the API to interface with the captive portal. I can't decide if I'm doing something wrong, or if this functionality hasn't been implemented yet.
I log into the captive portal. In the GUI I can see that a session has been established. It displays the client's IP, MAC address etc. However, calling '/api/captiveportal/session/list' returns an empty array. Actually, calling any of the captive portal related API functions returns an empty result.
Am I doing something wrong or does this API functionality not exist yet?
On a related note, I'd like to be able to perform a 'masquerade' login - ie tell OPNsense via the API "This user is now logged in from this IP. Let them through". Essentially I'm trying to have OPNsense linked to Active Directory so that when you log into AD it allows you to the Internet. I had a quick look and can't see that this functionality already exists. Presumably other people might find it of use and you'd be interested in a pull request?
Logged
AdSchellevis
Administrator
Hero Member
Posts: 907
Karma: 184
Re: Captive portal API
«
Reply #1 on:
January 20, 2016, 09:52:22 am »
Hi Robx,
Are you using the development version? it should dump all registered clients/hosts.
At the moment there is no function to add hosts dynamically, although it probably won't be very hard to implement it into the already existing controller.
You might want to add a feature request in GitHub (
https://github.com/opnsense/core/issues/
), although I can't promise when it will be in there.
Regards,
Ad
Logged
robx
Newbie
Posts: 4
Karma: 2
Re: Captive portal API
«
Reply #2 on:
January 20, 2016, 03:06:58 pm »
Thanks. I'd completely overlooked the development version. I've now installed it and the captive portal API is working as I expect.
I've written a API function that enables the 'masquerade'/dynamic logon that I mentioned. However, it doesn't seem like AccessController.php is the place for this - since it bypasses authentication when called via the portal Lighttpd 'proxy' functionality. Consequently, it would be possible to call my function directly and bypass the portal authentication.
Also, I can't see how session restrictions defined at the zone level are populated into sessions. The code in logonAction() clearly copies a timeout from the authentication server. However, I can't see how to populate the 'acc_session_timeout' session property.
Also, thanks for forking pfsense and putting so much effort into making it look nice and making it what it should have been!
Logged
franco
Administrator
Hero Member
Posts: 17665
Karma: 1611
Re: Captive portal API
«
Reply #3 on:
January 20, 2016, 04:30:06 pm »
Would you mind sharing a diff with us so that we can review? Github works too, it's actually better because we can comment inline if needed.
Logged
AdSchellevis
Administrator
Hero Member
Posts: 907
Karma: 184
Re: Captive portal API
«
Reply #4 on:
January 20, 2016, 07:15:24 pm »
A short note (I'm in a bit of a hurry
), the SessionController is the place for session data, the AccessController is the one accessed from the end user (which should always be able to authenticate).
Logged
robx
Newbie
Posts: 4
Karma: 2
Re: Captive portal API
«
Reply #5 on:
February 24, 2016, 02:38:48 pm »
I've now implemented this and created a PR here:
https://github.com/opnsense/core/pull/792
Logged
fabian
Hero Member
Posts: 2769
Karma: 200
OPNsense Contributor (Language, VPN, Proxy, etc.)
Re: Captive portal API
«
Reply #6 on:
March 13, 2016, 04:21:03 pm »
hello robx (@zvs44),
I changed your code and you forgot to add your copyright in the license so it is missing in my changes too.
Can you please add the information you would like to have to the new pull request so I can add it to the file?
Kind regards,
Fabian
Logged
AdSchellevis
Administrator
Hero Member
Posts: 907
Karma: 184
Re: Captive portal API
«
Reply #7 on:
March 13, 2016, 04:33:51 pm »
Hi Fabian, robx,
Can we please first determine what functionality we are missing exactly, like I asked in the original pull request?
I have no objection in adding extra functionality in this area, it certainly looks useful, but a copy of our original class with some additions into a new one might not be the best solution here
Regards,
Ad
Logged
robx
Newbie
Posts: 4
Karma: 2
Re: Captive portal API
«
Reply #8 on:
October 18, 2018, 11:42:01 pm »
Apologies for the significant (2 year) delay. I've now found a similar project that requires this functionality. I've raised a second pull-request (
https://github.com/opnsense/core/pull/2823
) that incorporates the comments from the first. Hope this meets with your approval.
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
English Forums
»
General Discussion
»
Captive portal API