Add checkbox to captive portal config
-
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 -
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 -
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 -
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();
-
very helpful - thanks a million….
cheers
Torsten -
glad to be of some use, every once in a while 8)