Netgate SG-1000 microFirewall

Author Topic: [HOWTO] Captive portal + FreeRADIUS + local MySQL user friendly single step  (Read 36761 times)

0 Members and 2 Guests are viewing this topic.

Offline Gertjan

  • Hero Member
  • *****
  • Posts: 2021
  • Karma: +165/-9
    • View Profile
* CP Post Login.png (23.07 kB, 1920x1032 - viewed 0 times.)

That image shows the problem very well.
http://192.168.56.200:8002/?
isn't a valid URL (IP is ok, port 8002 also - but with the file called '?' the web server (Nginx) will yell ... euh log something and show you the file not found error - also known as world's famous "404".

Knowing that the correct URL will be build with "$PORTAL_ACTION$" I wonder what your this variable is in your case.

Edit your portal.html (and portal.php or whatever  files are used to create te loggin page, and add this " html code ":
Code: [Select]
...
<p>PORTAL_ACTION == [$PORTAL_ACTION$]</p>
....

With my portal, this line shows :
Code: [Select]
PORTAL_ACTION == [https://brit-hotel-fumel.net:8003/index.php?zone=cpzone1]
and this is a valid URL (works with my pfSense setup - I'm using https, this explains the "8003" port - and the zone name is 'cpzone1')

So, what about showing your "portal login html files" ?

edit : I didn't test-drive, but this :
https://github.com/deajan/pfSense-cp-auth-onestep/blob/master/ozy-captive.php#L331
looks fine to me.
« Last Edit: July 05, 2017, 08:18:22 am by Gertjan »

Offline giovani.junior

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Good morning Gertjan!
I am sending the index.php file.
Sincerly, I don't know what to do.  I read a lot of docs about captive portal and followed the advices from other people with the same problem, but nothing is working.
My best regards and thanks by your attention!

Offline srvrgt

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
heyy guys, first of all thank you Deajan for the amazing work, really, it helps alot, now to my problem, i am currently on pfsense 2.3.4, and everything seems to be working fine except for the radius login part, i can see the users in the MYSQL database but they are all Rejected, the configuration of the ports on the radius server is ok, i was able to find this in the logs

 "Invalid user (sql1: Failed to create the pair: Invalid vendor name in attribute name "Password"): [123] (from client tester port 2010 cli "

i believe from what ive read that there is no such thing as apassword atribute, it must be Cleartext-Password, the problem is that i cant seem to find where to change the value, could you please help me out?,   

FYI if i use the test user and test password i can log in no problem and the mysql database also reflects that, so im guessing its just some sintaxis problem.

thanks

Offline Gertjan

  • Hero Member
  • *****
  • Posts: 2021
  • Karma: +165/-9
    • View Profile
I'd like to mention that I'm NOT using Freeradius and MySQL to handle te Captive portal clients.
(I just 'stole' somewhat the GUI part).
I'm running the Captive portal for a hotel for many years now - just using the local client database, built into pfSense.

I tend to keep it simple, which guarantees that my portal is always available, which is THE most important thing for my clients.

Tracking or accounting my clients is not one of my priorities - I'm not selling Internet access - I just offer it.



Offline srvrgt

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
FOLLOWUP, in case anyone is hitting the same problem as me, the problem is with freeradius3, so first of all you need to change the attribute type on the file ozy-captive :

From :    "INTO radcheck (username, attribute, value) VALUES (?, 'Password', ?)")) "   

TO:   INTO radcheck (username, attribute, value) VALUES (?, 'Cleartext-Password', ?)"))

And then you need to change the file    Schema.sql  BEFORE you add it to the radius database

FROM:
 CREATE TABLE radcheck (
  id int(11) unsigned NOT NULL auto_increment,
  username varchar(64) NOT NULL default '',
  attribute varchar(64)  NOT NULL default '',
  op char(2) NOT NULL DEFAULT '==',
  value varchar(253) NOT NULL default '',
  PRIMARY KEY  (id),
  KEY username (username(32))
) ;


TO:

CREATE TABLE radcheck (
  id int(11) unsigned NOT NULL auto_increment,
  username varchar(64) NOT NULL default '',
  attribute varchar(64)  NOT NULL default '',
  op char(2) NOT NULL DEFAULT ':=',
  value varchar(253) NOT NULL default '',
  PRIMARY KEY  (id),
  KEY username (username(32))
) ;

I hope this helps anyone  My problem was with pfsense 2.3.4   FRERADIUS 3 

Offline alpax

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
@deajan thanks for the easy to follow tutorial. do you have tutorial on a case which users are limited to a certain amount of data?

Offline charlesbiesseki

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Good morning guys, I'm having this problem.

PHP ERROR: Type: 1, File: /var/etc/captiveportal_publicwifi.html, Line: 157, Message: Class 'mysqli' not found   @ 2017-08-11 08:54:53

Offline Gertjan

  • Hero Member
  • *****
  • Posts: 2021
  • Karma: +165/-9
    • View Profile
Good morning guys, I'm having this problem.

PHP ERROR: Type: 1, File: /var/etc/captiveportal_publicwifi.html, Line: 157, Message: Class 'mysqli' not found   @ 2017-08-11 08:54:53
This is what the error says :
Your are using "PHP mysqli extension" command(s) in your own portal login page. You can't. The PHP msqli extension library should be installed first.
 I can't tell you how to do that on pfgSense. It might be possible.


Offline mastrus

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Hi everyone, I want to changhe the page after portal login, with putting some image to make it more readable.

I see that there are two variable in captiveportal-config.php $continue_string, $noScript_string, but i can't see it in the php main page.

Someone can me say where these variables are used, and where is the page after the portal login?

Offline mackykulitz

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: [HOWTO] Captive portal + FreeRADIUS + local MySQL user friendly single step
« Reply #129 on: September 04, 2017, 07:59:03 am »
Good morning guys, I'm having this problem.

PHP ERROR: Type: 1, File: /var/etc/captiveportal_publicwifi.html, Line: 157, Message: Class 'mysqli' not found   @ 2017-08-11 08:54:53
This is what the error says :
Your are using "PHP mysqli extension" command(s) in your own portal login page. You can't. The PHP msqli extension library should be installed first.
 I can't tell you how to do that on pfgSense. It might be possible.

Install mysqli with pkg

Offline mackykulitz

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: [HOWTO] Captive portal + FreeRADIUS + local MySQL user friendly single step
« Reply #130 on: October 07, 2017, 04:12:49 am »
Hi Deajan,

I have configured your setup on my pfsense perfectly.

may i ask how can i set the time limit of the newly registered users and reset the time

ex: new user register, it will have access to internet for 3 hours then disconnect and can only reconnect without having to re-register after lets say after 12 hours.

and thanks for a great guide very much appreciated..  :)