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

Add checkbox to captive portal config

Scheduled Pinned Locked Moved Development
6 Posts 2 Posters 1.6k 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.
  • T
    tb59427
    last edited by Nov 27, 2016, 4:53 PM

    Hi,

    I have changed my captive portal login to authenticate against a REST service we run in my network. Ideally I'd like to make the use of that service an option in the configuration of the captive portal. Found all the files that make up the UI and I guess I have understood how to add one more option to the Authenticate section of the Captive Portal config UI. What I have not understood is how such additional config items make it to pfsense's XML config file. Any pointers welcome.

    thanks
    Torsten

    1 Reply Last reply Reply Quote 0
    • H
      heper
      last edited by Nov 27, 2016, 10:26 PM

      some easy examples of how to read/write to the config are shown here:
      https://doc.pfsense.org/index.php/Using_the_PHP_pfSense_Shell

      1 Reply Last reply Reply Quote 0
      • T
        tb59427
        last edited by Nov 28, 2016, 1:49 PM

        Thanks for that hint. Checked it out - but maybe I am blind. I need to understand how I can ADD new config items to the xml (i.e. my checkbox and its value). And I can't seem to find that information covered in the doc you are referencing.

        Ploughing through the gazillions of php scripts in /etc/inc and /usr/local/www it appears there are functions somewhere to accomodate my needs. I just can't seem to find them :-(

        regards
        Torsten

        1 Reply Last reply Reply Quote 0
        • H
          heper
          last edited by Nov 28, 2016, 4:02 PM Nov 28, 2016, 3:59 PM

          below are some examples from within the developers-shell. The exact same things can be done from any GUI page (like the CP-edit page)

          printing part of the config

          
          pfSense shell: print_r($config['captiveportal']);
          pfSense shell: exec
          Array
          (
              [avc] => Array
                  (
                      [zone] => avc
                      [descr] => 
                      [zoneid] => 2
                      [interface] => opt3
                      [maxproc] => 
                      [timeout] => 
                      [idletimeout] => 
                      [freelogins_count] => 
                      [freelogins_resettimeout] => 
                      [enable] => 
                      [auth_method] => 
                      [reauthenticateacct] => 
                      [httpsname] => 
                      [preauthurl] => 
                      [blockedmacsurl] => 
                      [bwdefaultdn] => 
                      [bwdefaultup] => 
                      [certref] => 4f4919db8f141
                      [radius_protocol] => 
                      [redirurl] => 
                      [radiusip] => 
                      [radiusip2] => 
                      [radiusip3] => 
                      [radiusip4] => 
                      [radiusport] => 
                      [radiusport2] => 
                      [radiusport3] => 
                      [radiusport4] => 
                      [radiusacctport] => 
                      [radiuskey] => 
                      [radiuskey2] => 
                      [radiuskey3] => 
                      [radiuskey4] => 
                      [radiusvendor] => default
                      [radiussrcip_attribute] => wan
                      [radmac_format] => default
                      [radiusnasid] => 
                      [page] => 
                  )
          
          )
          
          

          adding a variable to the config

          
          pfSense shell: $config['captiveportal']['avc']['SomeTestVar'] = 123;
          pfSense shell: print_r($config['captiveportal']);
          pfSense shell: exec
          Array
          (
              [avc] => Array
                  (
                      [zone] => avc
                      [descr] => 
                      [zoneid] => 2
                      [interface] => opt3
                      [maxproc] => 
                      [timeout] => 
                      [idletimeout] => 
                      [freelogins_count] => 
                      [freelogins_resettimeout] => 
                      [enable] => 
                      [auth_method] => 
                      [reauthenticateacct] => 
                      [httpsname] => 
                      [preauthurl] => 
                      [blockedmacsurl] => 
                      [bwdefaultdn] => 
                      [bwdefaultup] => 
                      [certref] => 4f4919db8f141
                      [radius_protocol] => 
                      [redirurl] => 
                      [radiusip] => 
                      [radiusip2] => 
                      [radiusip3] => 
                      [radiusip4] => 
                      [radiusport] => 
                      [radiusport2] => 
                      [radiusport3] => 
                      [radiusport4] => 
                      [radiusacctport] => 
                      [radiuskey] => 
                      [radiuskey2] => 
                      [radiuskey3] => 
                      [radiuskey4] => 
                      [radiusvendor] => default
                      [radiussrcip_attribute] => wan
                      [radmac_format] => default
                      [radiusnasid] => 
                      [page] => 
                      [SomeTestVar] => 123
                  )
          
          )
          
          

          removing/unsetting variable

          
          pfSense shell: unset($config['captiveportal']['avc']['SomeTestVar']);
          pfSense shell: print_r($config['captiveportal']);
          pfSense shell: exec
          Array
          (
              [avc] => Array
                  (
                      [zone] => avc
                      [descr] => 
                      [zoneid] => 2
                      [interface] => opt3
                      [maxproc] => 
                      [timeout] => 
                      [idletimeout] => 
                      [freelogins_count] => 
                      [freelogins_resettimeout] => 
                      [enable] => 
                      [auth_method] => 
                      [reauthenticateacct] => 
                      [httpsname] => 
                      [preauthurl] => 
                      [blockedmacsurl] => 
                      [bwdefaultdn] => 
                      [bwdefaultup] => 
                      [certref] => 4f4919db8f141
                      [radius_protocol] => 
                      [redirurl] => 
                      [radiusip] => 
                      [radiusip2] => 
                      [radiusip3] => 
                      [radiusip4] => 
                      [radiusport] => 
                      [radiusport2] => 
                      [radiusport3] => 
                      [radiusport4] => 
                      [radiusacctport] => 
                      [radiuskey] => 
                      [radiuskey2] => 
                      [radiuskey3] => 
                      [radiuskey4] => 
                      [radiusvendor] => default
                      [radiussrcip_attribute] => wan
                      [radmac_format] => default
                      [radiusnasid] => 
                      [page] => 
                  )
          
          )
          
          

          if you create a new .php page from scratch you would also need to write to xml. If you just make edits to the current php files, its not needed because a "save' button is probably already in place.

          
          write_config();
          
          
          1 Reply Last reply Reply Quote 0
          • T
            tb59427
            last edited by Nov 29, 2016, 7:15 AM

            very helpful - thanks a million….

            cheers
            Torsten

            1 Reply Last reply Reply Quote 0
            • H
              heper
              last edited by Nov 29, 2016, 1:35 PM

              glad to be of some use, every once in a while  8)

              1 Reply Last reply Reply Quote 0
              6 out of 6
              • First post
                6/6
                Last post
              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                This community forum collects and processes your personal information.
                consent.not_received