diff options
author | Ermal Luçi <eri@pfsense.org> | 2010-03-11 16:14:49 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2010-03-11 16:14:49 +0000 |
commit | dba6bcbf7a02eb543355f1239378ea6ab2998c45 (patch) | |
tree | 8e1c8ad62029cebdadf37f9c31e175bcab89dc6f /usr/local/www | |
parent | 2ca50c87df75ce30e135cfcf1c2d056403a61c47 (diff) | |
download | pfsense-dba6bcbf7a02eb543355f1239378ea6ab2998c45.zip pfsense-dba6bcbf7a02eb543355f1239378ea6ab2998c45.tar.gz |
Improve wizard.
Diffstat (limited to 'usr/local/www')
-rw-r--r-- | usr/local/www/wizards/openvpn_wizard.inc | 141 | ||||
-rw-r--r-- | usr/local/www/wizards/openvpn_wizard.xml | 23 |
2 files changed, 96 insertions, 68 deletions
diff --git a/usr/local/www/wizards/openvpn_wizard.inc b/usr/local/www/wizards/openvpn_wizard.inc index cc9f099..824d870 100644 --- a/usr/local/www/wizards/openvpn_wizard.inc +++ b/usr/local/www/wizards/openvpn_wizard.inc @@ -4,19 +4,14 @@ require_once("openvpn.inc"); function step1_submitphpaction() { global $stepid, $config; if ($_POST['authtype'] == "local") { + $stepid = 5; $config['ovpnserver']['step1']['type'] = "local"; - write_config(); - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=5"); - exit; } else if ($_POST['authtype'] == "ldap") { $stepid = 0; } else if ($_POST['authtype'] == "radius") { - $stepid = 1; + $stepid = 2; $config['ovpnserver']['step1']['type'] = "radius"; unset($config['ovpnserver']['step1']['uselist']); - write_config(); - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=2"); - exit; } } @@ -27,7 +22,7 @@ function step2_stepbeforeformdisplay() { $count = 0; $authlist = auth_get_authserver_list(); - $fields[0]['options']['option'] = array(); + $fields[1]['options']['option'] = array(); foreach ($authlist as $i => $auth) { if ($auth['type'] != "ldap") { $count++; @@ -36,31 +31,33 @@ function step2_stepbeforeformdisplay() { $opts = array(); $opts['name'] = $auth['name']; $opts['value'] = $auth['name']; - $fields[2]['options']['option'][] = $opts; + $fields[1]['options']['option'][] = $opts; } if ($count < 1) $stepid = 2; } function step2_submitphpaction() { - global $stepid, $config; + global $stepid; - $config['ovpnserver']['step2']['authserv'] = $_POST['authserv']; - unset($config['ovpnserver']['step2']['uselist']); - write_config(); - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3"); - exit; + if (isset($_POST['next'])) + $stepid++; } function step3_submitphpaction() { + global $stepid, $savemsg; if (empty($_POST['name']) || empty($_POST['ip']) || empty($_POST['port']) || empty($_POST['transport']) || empty($_POST['scope']) || empty($_POST['authscope']) || empty($_POST['nameattr'])) { - $message = "Please enter all information for authentication server."; - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}"); - exit; + $stepid--; + $savemsg = "Please enter all information for authentication server."; + } else if (count(($authcfg = auth_get_authserver($_POST['name']))) > 0) { + $stepid--; + $savemsg = "Please choose a different name because an authentication server with this name already exists."; + } else { + $_POST['uselist'] = "on"; + $stepid += 2; } - $_POST['uselist'] = "on"; } function step4_stepbeforeformdisplay() { @@ -70,7 +67,7 @@ function step4_stepbeforeformdisplay() { $count = 0; $authlist = auth_get_authserver_list(); - $fields[0]['options']['option'] = array(); + $fields[1]['options']['option'] = array(); foreach ($authlist as $i => $auth) { if ($auth['type'] != "radius") { $count++; @@ -79,63 +76,58 @@ function step4_stepbeforeformdisplay() { $opts = array(); $opts['name'] = $auth['name']; $opts['value'] = $auth['name']; - $fields[2]['options']['option'][] = $opts; + $fields[1]['options']['option'][] = $opts; } if ($count < 1) $stepid = 4; } function step4_submitphpaction() { - global $stepid, $config; + global $stepid; - $config['ovpnserver']['step2']['authserv'] = $_POST['authserv']; - unset($config['ovpnserver']['step2']['uselist']); - write_config(); - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=4"); - exit; + if (isset($_POST['next'])) + $stepid++; } function step5_submitphpaction() { - global $stepid; + global $stepid, $savemsg; if (empty($_POST['name']) || empty($_POST['ip']) || empty($_POST['port']) || - empty($_POST['passowrd'])) { - $message = "Please enter all information for authentication server."; - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=4&message={$message}"); - exit; - } - $_POST['uselist'] = "on"; + empty($_POST['secret'])) { + $stepid--; + $savemsg = "Please enter all information for authentication server."; + } else if (count(($authcfg = auth_get_authserver($_POST['name']))) > 0) { + $stepid--; + $savemsg = "Please choose a different name because an authentication server with this name already exists."; + } else + $_POST['uselist'] = "on"; } function step6_stepbeforeformdisplay() { global $stepid, $config; if (count($config['system']['ca']) < 1) { - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=6"); - exit; + $stepid++; } } function step6_submitphpaction() { - global $config; + global $stepid; - $config['ovpnserver']['step6']['authcertca'] = $_POST['authcertca']; - unset($config['ovpnserver']['step6']['uselist']); - write_config(); - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=7"); - exit; + if (isset($_POST['next'])) + $stepid++; } function step7_submitphpaction() { - + global $stepid, $savemsg, $_POST; + if (empty($_POST['name']) || empty($_POST['keylength']) || empty($_POST['lifetime']) || empty($_POST['country']) || empty($_POST['state']) || empty($_POST['city']) || empty($_POST['organization']) || empty($_POST['email']) || empty($_POST['cn'])) { - $message = "Please enter all information for the new CA authority."; - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=6&message={$message}"); - exit; - } - $_POST['uselist'] = "on"; + $stepid--; + $savemsg = "Please enter all information for the new CA authority."; + } else + $_POST['uselist'] = "on"; } function step8_stepbeforeformdisplay() { @@ -143,32 +135,28 @@ function step8_stepbeforeformdisplay() { if (count($config['system']['cert']) < 1 || (count($config['system']['cert']) == 1 && stristr($config['system']['cert'][0]['name'], "webconf"))) { - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=8"); - exit; + $stepid++; } } function step8_submitphpaction() { - global $config; + global $stepid, $_POST; - $config['ovpnserver']['step9']['authcertname'] = $_POST['authcertname']; - unset($config['ovpnserver']['step6']['uselist']); - write_config(); - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=9"); - exit; + if (isset($_POST['next'])) + $stepid += 1; } function step9_submitphpaction() { - global $stepid; + global $stepid, $savemsg, $_POST; if (empty($_POST['name']) || empty($_POST['keylength']) || empty($_POST['lifetime']) || empty($_POST['country']) || empty($_POST['state']) || empty($_POST['city']) || empty($_POST['organization']) || empty($_POST['email']) || empty($_POST['cn'])) { - $message = "Please enter all information for the new certificate."; - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=8&message={$message}"); - exit; - } - $_POST['uselist'] = "on"; + $stepid--; + $savemsg = "Please enter all information for the new certificate."; + } else { + $_POST['uselist'] = "on"; + } } function step10_stepbeforeformdisplay() { @@ -377,7 +365,7 @@ function step12_submitphpaction() { $server['protocol'] = $pconfig['step10']['protocol']; $server['interface'] = $pconfig['step10']['interface']; if (isset($pconfig['step10']['localport'])) - $server['localport'] = $pconfig['step10']['localport']; + $server['local_port'] = $pconfig['step10']['localport']; $server['description'] = $pconfig['step10']['descr']; $server['custom_options'] = $pconfig['step10']['advanced']; if (isset($pconfig['step10']['tlsauth'])) { @@ -430,6 +418,33 @@ function step12_submitphpaction() { $server['netbios_enable'] = $pconfig['step10']['nbtenable']; } $server['crypto'] = $pconfig['step10']['crypto']; + + if (isset($pconfig['step11']['ovpnrule'])) { + $rule = array(); + $rule['descr'] = gettext("OpenVPN {$server['description']} wizard rules."); + $rule['direction'] = "in"; + $rule['source']['any'] = TRUE; + $rule['source']['address']['any'] = TRUE; + $rule['destination']['network'] = $server['interface'] . "ip"; + $rule['destination']['port'] = $server['local_port']; + $rule['interface'] = $server['interface']; + $rule['protocol'] = $server['protocol']; + $rule['type'] = "pass"; + $rule['enabled'] = "on"; + $config['filter']['rule'][] = $rule; + } + if (isset($pconfig['step11']['ovpnallow'])) { + $rule = array(); + $rule['descr'] = gettext("OpenVPN {$server['description']} wizard rules."); + $rule['source']['any'] = TRUE; + $rule['source']['address']['any'] = TRUE; + $rule['destination']['address']['any'] = TRUE; + $rule['interface'] = "openvpn"; + $rule['protocol'] = "any"; + $rule['type'] = "pass"; + $rule['enabled'] = "on"; + $config['filter']['rule'][] = $rule; + } if (!is_array($config['openvpn']['openvpn-server'])) $config['openvpn']['openvpn-server'] = array(); diff --git a/usr/local/www/wizards/openvpn_wizard.xml b/usr/local/www/wizards/openvpn_wizard.xml index 06e250c..36532b9 100644 --- a/usr/local/www/wizards/openvpn_wizard.xml +++ b/usr/local/www/wizards/openvpn_wizard.xml @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. */ </copyright> -<totalsteps>8</totalsteps> +<totalsteps>12</totalsteps> <step> <id>1</id> <title>OpenVPN Remote Access Server Setup Wizard</title> @@ -89,6 +89,10 @@ </field> <field> <type>submit</type> + <name>Add new LDAP server</name> + </field> + <field> + <type>submit</type> <name>Next</name> </field> </fields> @@ -193,7 +197,6 @@ <name>Add new Server</name> </field> </fields> - <stepbeforeformdisplay>step3_stepbeforeformdisplay();</stepbeforeformdisplay> <stepsubmitphpaction>step3_submitphpaction();</stepsubmitphpaction> <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> <includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> @@ -219,6 +222,10 @@ </option> </options> </field> + <field> + <type>submit</type> + <name>Add new RADIUS server</name> + </field> <field> <type>submit</type> <name>Next</name> @@ -269,7 +276,6 @@ <type>submit</type> </field> </fields> - <stepbeforeformdisplay>step5_stepbeforeformdisplay();</stepbeforeformdisplay> <stepsubmitphpaction>step5_submitphpaction();</stepsubmitphpaction> <includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> </step> @@ -285,6 +291,10 @@ <bindstofield>ovpnserver->step6->authcertca</bindstofield> </field> <field> + <type>submit</type> + <name>Add new CA</name> + </field> + <field> <name>Next</name> <type>submit</type> </field> @@ -394,7 +404,7 @@ <step> <id>8</id> <title>OpenVPN Remote Access Server Setup Wizard</title> - <description>Create a certificate to be used by server.</description> + <description>Select certificate to be used with server.</description> <fields> <field> <type>cert_selection</type> @@ -403,6 +413,10 @@ <bindstofield>ovpnserver->step9->authcertname</bindstofield> </field> <field> + <type>submit</type> + <name>Add new Certificate</name> + </field> + <field> <name>Next</name> <type>submit</type> </field> @@ -507,7 +521,6 @@ </fields> <stepsubmitphpaction>step9_submitphpaction();</stepsubmitphpaction> <includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> - <javascriptafterformdisplay>enablechange();</javascriptafterformdisplay> </step> <step> <id>10</id> |