Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    [HOWTO] Captive portal + FreeRADIUS + local MySQL user friendly single step

    Scheduled Pinned Locked Moved Captive Portal
    154 Posts 47 Posters 104.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      deajan
      last edited by

      @dhipo Did you set up a correct zone name in pfSense GUI ?
      Also, which version have you tried ? Can you try with latest git master tree ?

      You asked for a "glue", I can't give you that, but the latest dev snapshot should stick toghether with 2.3.2 without problems :)

      @sanketgroup
      The archive contains some sql files (in sql directory) that you must run on your mysql server.
      Btw, also use latest github sql files because of an error in previous versions.

      NetPOWER.fr - some opensource stuff for IT people

      1 Reply Last reply Reply Quote 0
      • S
        sanketgroup
        last edited by

        where can i find latest github sql files?

        I got schema from https://wiki.freeradius.org/config/MySQL-DDL-script
        However there were some mismatch in column names.

        1 Reply Last reply Reply Quote 0
        • D
          deajan
          last edited by

          See https://github.com/deajan/pfSense-cp-auth-onestep

          NetPOWER.fr - some opensource stuff for IT people

          1 Reply Last reply Reply Quote 0
          • S
            sanketgroup
            last edited by

            perfect, this schema worked.
            BUT
            how can i add internet username and passwords in sql.

            for e.g In current setup, user  'testu' has been created PFSense>Services>FreeRadius>Users

            if i delete this user here, it does not go to my sql to check the user.
            And also i do not know in which table and now i can create users in MySQL.
            Pls let me know.

            Thanks a lot

            1 Reply Last reply Reply Quote 0
            • D
              deajan
              last edited by

              @sanketgroup:

              how can i add internet username and passwords in sql.

              for e.g In current setup, user  'testu' has been created PFSense>Services>FreeRadius>Users

              if i delete this user here, it does not go to my sql to check the user.
              And also i do not know in which table and now i can create users in MySQL.
              Pls let me know.

              Thanks a lot

              That's not how this captive portal is supposed to work.
              It creates the user accounts on the fly.
              If you don't want that behavior, just check the code of ozy-captive.php that creates the user in order to disable it and create them manually in the same manner the code does.

              NetPOWER.fr - some opensource stuff for IT people

              1 Reply Last reply Reply Quote 0
              • S
                sanketgroup
                last edited by

                On ozy-captive.php page.
                when i fill in Email, Family Name, Surname and click connect - I get following error.

                Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in C:\xampp\htdocs\PFSense-cp-auth\ozy-captive.php:35 Stack trace: #0 C:\xampp\htdocs\PFSense-cp-auth\ozy-captive.php(65): cleanInput('en') #1 {main} thrown in C:\xampp\htdocs\PFSense-cp-auth\ozy-captive.php on line 35

                === Mainly i want to store username password generated from my CRM application to radius database.
                I have own CRM application which i can modify to store username password of hotspot users into radius database.
                And then captive portal will verify that user in radius mysql database.
                But I do not know in which table and column i have to insert usertname password.
                And may be their plan like 1gb per day, or 2 hours access etc

                Thanks

                1 Reply Last reply Reply Quote 0
                • D
                  dhipo
                  last edited by

                  @deajan

                  i got the latest git files and works perfect ..

                  i did some mods on sql tables(more fields, to administrative purposes) and working too

                  i'm using pf 2.3.2p1

                  i used toghther Squid and LightSquid to do Reports and work too

                  great Job

                  Dhix Networks
                  Everything Secure

                  http://www.dhix.com.br

                  1 Reply Last reply Reply Quote 0
                  • S
                    sanketgroup
                    last edited by

                    Ok, i found the table name. It is radcheck.
                    Captive Portal is successfully authenticating username password stored in this table.

                    Now one question: how do i set usage type to users.

                    for e.g I want some user to have
                    1GB per day  or
                    2 HR access  or
                    100MB for 2 Hrs
                    etc.

                    1 Reply Last reply Reply Quote 0
                    • D
                      deajan
                      last edited by

                      @sanketgroup This is out of the captive portal discussion but after a short google request I found this one:

                      INSERT INTO radcheck ( id , UserName , Attribute , op , Value ) VALUES ( NULL , 'user', 'user-password', '==', 'user');
                      INSERT INTO radreply (username, attribute, op, value) VALUES ('user', 'Rate-Limit', '=', '1024k/1024k');
                      

                      It may be adapted to fit actual radius table scheme, you may find info on how to configure it on freeradius documentation.

                      NetPOWER.fr - some opensource stuff for IT people

                      1 Reply Last reply Reply Quote 0
                      • A
                        ardorin
                        last edited by

                        First of all, amazing job, it works perfectly.
                        However I have a small problem: in french and in spanish accents dont work.
                        I use UTF-8 in HTML header.
                        It only works if for example I replace á with á in the config file
                        Im also using the files from your github

                        Is there anything that should be added?

                        1 Reply Last reply Reply Quote 0
                        • D
                          deajan
                          last edited by

                          @ardorin Strange, I actually developped this on french computers and did never get any trouble. What navigator do you use to check this ?

                          Also, can you try to add the following after line 327 ?

                          NetPOWER.fr - some opensource stuff for IT people

                          1 Reply Last reply Reply Quote 0
                          • A
                            ardorin
                            last edited by

                            I tried adding that line and then in both Chrome and Firefox without any luck.
                            If I type any input in the HTML file with accents, it works, so the HTML header seems fine. The problem are the accents in the strings of the config file, for some reason they are not being coded correctly when introduced in the main file. Characters with accents are being replaced by a question mark.
                            I did edit your code a bit, but I didnt touch anything of the HTML part.

                            1 Reply Last reply Reply Quote 0
                            • D
                              deajan
                              last edited by

                              @ardorin What platform are you running ?
                              I hope you didn't copy paste some of the code :)
                              Please check that all files are UTF-8 without BOM encoded.

                              NetPOWER.fr - some opensource stuff for IT people

                              1 Reply Last reply Reply Quote 0
                              • A
                                ardorin
                                last edited by

                                I edited the database part, so those changes I made should not be irrelevant (and that part is working perfectly) 
                                Yes, every file is UTF without BOM encoded

                                1 Reply Last reply Reply Quote 0
                                • A
                                  Alexandre4sol
                                  last edited by

                                  Dear, I have the problem "/index.php: Submission to captiveportal with unknown parameter zone:".
                                  I got the newest files and still the error continues.
                                  I looked over the correction post and I also could not solve it.
                                  Home page opens to register the form and fell on a white page with the url: http://192.168.123.1:8002/index.php?zone=&redirurl=&language=en.
                                  In the log the message "/index.php: Submission to captiveportal with unknown parameter zone:"
                                  Can someone help me I'm out of ideas?

                                  1 Reply Last reply Reply Quote 0
                                  • D
                                    deajan
                                    last edited by

                                    @ardorin: out of ideas here. Have tested it on linux / windows, using various languages and systems. Didn't happen to me. Maybe start with a fresh install and try again ?
                                    @Alexandre4sol: Are you running on 2.2 ? Cause zone parameter was introduced in 2.3. Also, what's your exact zone name ?

                                    NetPOWER.fr - some opensource stuff for IT people

                                    1 Reply Last reply Reply Quote 0
                                    • A
                                      Alexandre4sol
                                      last edited by

                                      @deajan: Hi, thanks for helping me out.
                                      I'm using version 2.3.2-RELEASE (i386)
                                      the captive portal zone is "guest"
                                      This is the link to open the registration form. http://192.168.123.1:8002/index.php?zone=guest&redirurl=http%3A%2F%2Fwww.gstatic.com%2Fgenerate_204

                                      ![Captura de Tela 2017-02-04 a?s 10.28.56.png](/public/imported_attachments/1/Captura de Tela 2017-02-04 a?s 10.28.56.png)
                                      ![Captura de Tela 2017-02-04 a?s 10.28.56.png_thumb](/public/imported_attachments/1/Captura de Tela 2017-02-04 a?s 10.28.56.png_thumb)

                                      1 Reply Last reply Reply Quote 0
                                      • D
                                        deajan
                                        last edited by

                                        @Alexandre4sol: I think dhipo on this thread did have the same error. Maybe you should talk to him to see how he managed to solve this. As for me I'll have to make some tests because I never encountered that problem.

                                        NetPOWER.fr - some opensource stuff for IT people

                                        1 Reply Last reply Reply Quote 0
                                        • G
                                          guterkerl
                                          last edited by

                                          Hi had issues with the one downloaded from git.

                                          https://codeload.github.com/deajan/pfSense-cp-auth-onestep/zip/master
                                          

                                          The old version worked fine but the new one didn't.

                                          http://netpower.fr/sites/default/files/soft/bin/pfSense-cp-auth-onestep.gz
                                          

                                          Fatal error: Call to undefined function mysql_real_escape_string() in /var/etc/captiveportal_wifi.html on line 35 Call Stack: 0.0002 226208 1. {main}() /usr/local/captiveportal/index.php:0 0.0170 1469432 2. portal_reply_page() /usr/local/captiveportal/index.php:288 0.0171 1469680 3. get_include_contents() /etc/inc/captiveportal.inc:1944 0.0172 1487664 4. include('/var/etc/captiveportal_wifi.html') /etc/inc/pfsense-utils.inc:2601 0.0277 1500240 5. cleanInput() /var/etc/captiveportal_wifi.html:45 PHP ERROR: Type: 1, File: /var/etc/captiveportal_wifi.html, Line: 35, Message: Call to undefined function mysql_real_escape_string()

                                          1 Reply Last reply Reply Quote 0
                                          • D
                                            deajan
                                            last edited by

                                            @guterkerl That's why releases exist on github, in order to not pick up a project at a random moment in the dev process. You should take release v0.46 on github which is latest and functionnal.

                                            NetPOWER.fr - some opensource stuff for IT people

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.