aboutsummaryrefslogtreecommitdiffstats
path: root/packages/squid_auth.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-10-05 14:11:33 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-10-05 14:11:33 +0000
commita0cb9388ff0e76467e2ec973103efac6a62a2712 (patch)
tree7fd5e637f28133a81ee5e11b4251ec6a5b356351 /packages/squid_auth.inc
parentef476b2fdb5bc9734cbfaeefe1eaddb70f2f6b14 (diff)
downloadpfsense-packages-a0cb9388ff0e76467e2ec973103efac6a62a2712.tar.gz
pfsense-packages-a0cb9388ff0e76467e2ec973103efac6a62a2712.tar.bz2
pfsense-packages-a0cb9388ff0e76467e2ec973103efac6a62a2712.zip
Squid updates from Michael Capp
Diffstat (limited to 'packages/squid_auth.inc')
-rw-r--r--packages/squid_auth.inc203
1 files changed, 167 insertions, 36 deletions
diff --git a/packages/squid_auth.inc b/packages/squid_auth.inc
index 7b29ce00..ae431f22 100644
--- a/packages/squid_auth.inc
+++ b/packages/squid_auth.inc
@@ -41,35 +41,15 @@ function global_eval_auth_options(){
switch ($auth_method) {
case "none":
- $filecontents = file('/usr/local/pkg/squid_auth.xml');
-
- $fout = fopen("/usr/local/pkg/squid_auth.xml","w");
- foreach($filecontents as $line) {
- if (stristr($line, "<url>/pkg.php?xml=squid_extauth.xml&amp;id=0</url>")) {
- fwrite($fout, " <url>/pkg_edit.php?xml=squid_extauth.xml&amp;id=0</url>\n");
- } else {
- fwrite($fout, $line);
- }
- }
-
+ dynamic_auth_content("pkg_edit");
dynamic_no_auth();
break;
case "local_auth":
- dynamic_auth_content();
+ dynamic_auth_content("pkg");
dynamic_local_auth();
break;
case "ldap_bind":
- $filecontents = file('/usr/local/pkg/squid_auth.xml');
-
- $fout = fopen("/usr/local/pkg/squid_auth.xml","w");
- foreach($filecontents as $line) {
- if (stristr($line, "<url>/pkg.php?xml=squid_extauth.xml&amp;id=0</url>")) {
- fwrite($fout, " <url>/pkg_edit.php?xml=squid_extauth.xml&amp;id=0</url>\n");
- } else {
- fwrite($fout, $line);
- }
- }
-
+ dynamic_auth_content("pkg_edit");
dynamic_ldap_auth();
break;
case "domain_auth":
@@ -134,7 +114,7 @@ function dynamic_no_auth() {
fwrite($fout, '<?xml version="1.0" encoding="utf-8" ?>' . "\n");
fwrite($fout, "<packagegui>\n");
fwrite($fout, " <name>squidextnoauth</name>\n");
- fwrite($fout, " <title>Services: Squid Advanced Proxy -> Extended Authentication Settings</title>\n");
+ fwrite($fout, " <title>Services: Proxy Server -> Extended Authentication Settings</title>\n");
fwrite($fout, " <configpath>installedpackages->package->squidextnoauth->configuration->settings</configpath>\n");
fwrite($fout, "\n");
fwrite($fout, " <aftersaveredirect>/pkg_edit.php?xml=squid_extauth.xml&amp;id=0</aftersaveredirect>\n");
@@ -211,7 +191,7 @@ function dynamic_local_auth() {
fwrite($fout, "\n");
fwrite($fout, "<packagegui>\n");
fwrite($fout, " <name>squidextlocalauth</name>\n");
- fwrite($fout, " <title>Services: Squid Advanced Proxy -> Extended Authentication Settings</title>\n");
+ fwrite($fout, " <title>Services: Proxy Server -> Extended Authentication Settings</title>\n");
fwrite($fout, " <version>2.5.10_4</version>\n");
fwrite($fout, " <configpath>installedpackages->package->squidextlocalauth->configuration->settings</configpath>\n");
fwrite($fout, "\n");
@@ -328,21 +308,172 @@ function dynamic_local_auth() {
config_unlock();
} /* end function dynamic_local_auth */
+function dynamic_ldap_auth() {
+ conf_mount_rw();
+ config_lock();
+
+ global $config;
+
+ $pkgfile = "/usr/local/pkg/squid_extauth.xml";
+
+ $fout = fopen($pkgfile, "w");
+
+ fwrite($fout, '<?xml version="1.0" encoding="utf-8" ?>' . "\n");
+ fwrite($fout, "\n");
+ fwrite($fout, "<packagegui>\n");
+ fwrite($fout, " <name>squidextldapauth</name>\n");
+ fwrite($fout, " <title>Services: Proxy Server -> Extended Auth Settings</title>\n");
+ fwrite($fout, " <version>2.5.11</version>\n");
+ fwrite($fout, " <configpath>installedpackages->package->squidextldapauth->configuration->settings</configpath>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <files></files>\n");
+ fwrite($fout, " <menu></menu>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <aftersaveredirect>/pkg_edit.php?xml=squid_extauth.xml&amp;id=0</aftersaveredirect>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <tabs>\n");
+ fwrite($fout, " <tab>\n");
+ fwrite($fout, " <text>General Settings</text>\n");
+ fwrite($fout, " <url>/pkg_edit.php?xml=squid_ng.xml&amp;id=0</url>\n");
+ fwrite($fout, " </tab>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <tab>\n");
+ fwrite($fout, " <text>Upstream Proxy</text>\n");
+ fwrite($fout, " <url>/pkg_edit.php?xml=squid_upstream.xml&amp;id=0</url>\n");
+ fwrite($fout, " </tab>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <tab>\n");
+ fwrite($fout, " <text>Cache Mgmt</text>\n");
+ fwrite($fout, " <url>/pkg_edit.php?xml=squid_cache.xml&amp;id=0</url>\n");
+ fwrite($fout, " </tab>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <tab>\n");
+ fwrite($fout, " <text>Network Access Control</text>\n");
+ fwrite($fout, " <url>/pkg_edit.php?xml=squid_nac.xml&amp;id=0</url>\n");
+ fwrite($fout, " </tab>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <tab>\n");
+ fwrite($fout, " <text>Traffic Mgmt</text>\n");
+ fwrite($fout, " <url>/pkg_edit.php?xml=squid_traffic.xml&amp;id=0</url>\n");
+ fwrite($fout, " </tab>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <tab>\n");
+ fwrite($fout, " <text>Auth Settings</text>\n");
+ fwrite($fout, " <url>/pkg_edit.php?xml=squid_auth.xml&amp;id=0</url>\n");
+ fwrite($fout, " </tab>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <tab>\n");
+ fwrite($fout, " <text>Extended Auth Settings</text>\n");
+ fwrite($fout, " <url>/pkg_edit.php?xml=squid_extauth.xml&amp;id=0</url>\n");
+ fwrite($fout, " <active/>\n");
+ fwrite($fout, " </tab>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " </tabs>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <fields>\n");
+ fwrite($fout, " <field>\n");
+ fwrite($fout, " <fielddescr>Base DN</fielddescr>\n");
+ fwrite($fout, " <fieldname>ldap_basedn</fieldname>\n");
+ fwrite($fout, " <description>This is the base where the LDAP search starts. All subsequent organizational units (OUs)will be included. Example: "ou=users,o=company" will search for users in and under the specified company.</description>\n");
+ fwrite($fout, " <type>input</type>\n");
+ fwrite($fout, " <size>50</size>\n");
+ fwrite($fout, " </field>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <field>\n");
+ fwrite($fout, " <fielddescr>LDAP Server</fielddescr>\n");
+ fwrite($fout, " <fieldname>ldap_server</fieldname>\n");
+ fwrite($fout, " <description>This is the LDAP server that the bind will be attempted against.</description>\n");
+ fwrite($fout, " <type>input</type>\n");
+ fwrite($fout, " <size>20</size>\n");
+ fwrite($fout, " </field>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <field>\n");
+ fwrite($fout, " <fielddescr>LDAP Type</fielddescr>\n");
+ fwrite($fout, " <fieldname>ldap_type</fieldname>\n");
+ fwrite($fout, " <description>This specifies the supported LDAP types.</description>\n");
+ fwrite($fout, " <type>select</type>\n");
+ fwrite($fout, " <options>\n");
+ fwrite($fout, " <option><name>Active Directory</name><value>active_directory</value></option>\n");
+ fwrite($fout, " <option><name>Novell eDirectory</name><value>novell_edirectory</value></option>\n");
+ fwrite($fout, " <option><name>LDAP v2</name><value>ldap_v2</value></option>\n");
+ fwrite($fout, " <option><name>LDAP v3</name><value>ldap_v3</value></option>\n");
+ fwrite($fout, " </options>\n");
+ fwrite($fout, " </field>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <field>\n");
+ fwrite($fout, " <fielddescr>LDAP Port</fielddescr>\n");
+ fwrite($fout, " <fieldname>ldap_port</fieldname>\n");
+ fwrite($fout, ' <description>This is the port that LDAP bind will attempt on. The default is "389".</description>' . "\n");
+ fwrite($fout, " <type>input</type>\n");
+ fwrite($fout, " <size>5</size>\n");
+ fwrite($fout, " </field>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <field>\n");
+ fwrite($fout, " <fielddescr>Bind DN Username</fielddescr>\n");
+ fwrite($fout, " <fieldname>bind_dn_username</fieldname>\n");
+ fwrite($fout, ' <description>If "anonymous bind" is not supported, please specify the bind username that can access the Base DN hierarchy.</description>' . "\n");
+ fwrite($fout, " <type>input</type>\n");
+ fwrite($fout, " <size>30</size>\n");
+ fwrite($fout, " </field>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <field>\n");
+ fwrite($fout, " <fielddescr>Bind DN Password</fielddescr>\n");
+ fwrite($fout, " <fieldname>bind_dn_password</fieldname>\n");
+ fwrite($fout, " <description>This is the associated password with the Bind DN Username previously specified.</description>\n");
+ fwrite($fout, " <type>password</type>\n");
+ fwrite($fout, " </field>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " </fields>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " <custom_add_php_command_late>\n");
+ fwrite($fout, ' require_once("/usr/local/pkg/squid_ng.inc");' . "\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " if ($password == $confirm_password) {\n");
+ fwrite($fout, ' mwexec("/usr/bin/htpasswd -b /usr/local/etc/squid/advanced/ncsa/passwd "' . $username . " " . $password . "\n");
+ fwrite($fout, " }\n");
+ fwrite($fout, "\n");
+ fwrite($fout, " global_write_squid_config();\n");
+ fwrite($fout, ' mwexec("/usr/local/sbin/squid -k reconfigure");' . "\n");
+ fwrite($fout, " </custom_add_php_command_late>\n");
+ fwrite($fout, "\n");
+ fwrite($fout, "</packagegui>\n");
+}
+
/* dynamically re-writes all squid xml files to handle adddeletecolumnitems properly */
-function dynamic_auth_content() {
+function dynamic_auth_content($pkgvar) {
- if ($handle = opendir('/usr/local/pkg')) {
- while (($file = readdir($handle)) != false) {
- if (stristr($file, "squid_") && stristr($file, ".xml")) {
+ if ($pkgvar == "pkg") {
+ if ($handle = opendir('/usr/local/pkg')) {
+ while (($file = readdir($handle)) != false) {
+ if (stristr($file, "squid_") && stristr($file, ".xml")) {
+
+ $filecontents = file("/usr/local/pkg/" . $file);
+
+ $fout = fopen("/usr/local/pkg/" . $file,"w");
+ foreach($filecontents as $line) {
+ if (stristr($line, "<url>/pkg_edit.php?xml=squid_extauth.xml&amp;id=0</url>")) {
+ fwrite($fout, " <url>/pkg.php?xml=squid_extauth.xml&amp;id=0</url>\n");
+ } else {
+ fwrite($fout, $line);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if ($handle = opendir('/usr/local/pkg')) {
+ while (($file = readdir($handle)) != false) {
+ if (stristr($file, "squid_") && stristr($file, ".xml")) {
- $filecontents = file("/usr/local/pkg/" . $file);
+ $filecontents = file("/usr/local/pkg/" . $file);
- $fout = fopen("/usr/local/pkg/" . $file,"w");
- foreach($filecontents as $line) {
- if (stristr($line, "<url>/pkg_edit.php?xml=squid_extauth.xml&amp;id=0</url>")) {
- fwrite($fout, " <url>/pkg.php?xml=squid_extauth.xml&amp;id=0</url>\n");
- } else {
- fwrite($fout, $line);
+ $fout = fopen("/usr/local/pkg/" . $file,"w");
+ foreach($filecontents as $line) {
+ if (stristr($line, "<url>/pkg.php?xml=squid_extauth.xml&amp;id=0</url>")) {
+ fwrite($fout, " <url>/pkg_edit.php?xml=squid_extauth.xml&amp;id=0</url>\n");
+ } else {
+ fwrite($fout, $line);
+ }
}
}
}